tech:notes_rsync
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| tech:notes_rsync [2025/06/25 15:13] – Jean-Baptiste | tech:notes_rsync [2026/07/16 12:07] (Version actuelle) – Jean-Baptiste | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag> | ||
| + | |||
| + | # Notes rsync | ||
| + | |||
| + | Voir aussi | ||
| + | * SyncThing | ||
| + | * https:// | ||
| + | * `gzip --rsyncable` | ||
| + | |||
| + | Voir : | ||
| + | * [[reseau_linux_pile_tcp_ip_rto_min_scripts|Mesures - rsync]] | ||
| + | |||
| + | ### CD / ISO | ||
| + | |||
| + | Source https:// | ||
| + | |||
| + | ~~~ | ||
| + | Veuillez utiliser au moins les options --times --links --hard-links --partial --block-size=8192. | ||
| + | Cela conservera la date de dernière modification, | ||
| + | (le plus adapté pour les images de CD) sera utilisé. | ||
| + | Lorsque la date de dernière modification et la taille d'un fichier n'ont pas été modifiées, | ||
| + | rsync ignore le fichier, aussi --times est réellement nécessaire | ||
| + | ~~~ | ||
| + | |||
| + | ### Machine distante vers machine distante | ||
| + | |||
| + | ~~~bash | ||
| + | rsync -ax backup:/ | ||
| + | ~~~ | ||
| + | |||
| + | ~~~ | ||
| + | The source and destination cannot both be remote. | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | ssh -A remotehostA rsync / | ||
| + | ~~~ | ||
| + | |||
| + | Une autre solution consiste à utiliser SSHFS **Mais les UID/GID ne sont pas préservés** | ||
| + | |||
| + | #### Pb SSHFS Transport endpoint is not connected | ||
| + | |||
| + | ~~~bash | ||
| + | fusermount -uz /data | ||
| + | ~~~ | ||
| + | |||
| + | `/ | ||
| + | ~~~ | ||
| + | user_allow_other | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | sshfs -o allow_other, | ||
| + | ~~~ | ||
| + | |||
| + | Pour debug ajouter l' | ||
| + | ~~~bash | ||
| + | sshfs -d -o allow_other, | ||
| + | ~~~ | ||
| + | |||
| + | ### Gros fichiers avec plein de zéros, iso... | ||
| + | |||
| + | Voir l' | ||
| + | ~~~ | ||
| + | -S, --sparse | ||
| + | ~~~ | ||
| + | |||
| + | ~~~ | ||
| + | $ ls -lsh | ||
| + | total 22G | ||
| + | 16K drwx------ 2 root root 16K août 9 10:42 lost+found | ||
| + | 7,7G -rw-r--r-- 1 jibe jibe 120G août 9 11:18 VM152-SUPPMSM-V-clone.img | ||
| + | 14G -rw-r--r-- 1 jibe jibe 14G févr. 24 09:15 VM152-SUPPMSM-V-clone.qcow2 | ||
| + | ~~~ | ||
| + | |||
| + | ### Copie dossier | ||
| + | |||
| + | Ne pas oublier le barre oblique (slash) à la fin | ||
| + | ~~~bash | ||
| + | rsync -ax / | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ### Utilisation de l' | ||
| + | |||
| + | ~~~bash | ||
| + | rsync -anv --files-from=push.lst / /tmp/plop/ | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ### rsync avec find | ||
| + | |||
| + | ~~~bash | ||
| + | # rsync --files-from=< | ||
| + | # find ~/DATA/ -name ' | ||
| + | |||
| + | cd ~/DATA/ | ||
| + | find . -type f -name ' | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ### Diff - diffing | ||
| + | |||
| + | ~~~bash | ||
| + | diff -r --exclude=' | ||
| + | ~~~ | ||
| + | |||
| + | Équivalent avec rsync | ||
| + | ~~~bash | ||
| + | rsync -rcvn --itemize-changes --delete --exclude=' | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ### Droits | ||
| + | |||
| + | chmod - exemple cd iso9660 | ||
| + | |||
| + | chmod \\ | ||
| + | **F** pour File \\ | ||
| + | **D** pour Directory | ||
| + | |||
| + | ~~~bash | ||
| + | rsync -a -H --delete --chmod=Fu+rw, | ||
| + | ~~~ | ||
| + | |||
| + | Cependant dans le cas d'un ISO CD/DVD nous préférerons : | ||
| + | ~~~bash | ||
| + | fakeroot rsync -a -H --delete /mnt/iso /tmp/iso | ||
| + | ~~~ | ||
| + | |||
| + | chown - exemple synchro dokuwiki | ||
| + | ~~~bash | ||
| + | rsync -axP --chown=999: | ||
| + | ~~~ | ||
| + | |||
| + | ### Options SSH | ||
| + | |||
| + | ~~~bash | ||
| + | rsync -o StrictHostKeyChecking=no -o CheckHostIP=no | ||
| + | #rsync -e "ssh -o StrictHostKeyChecking=no -o CheckHostIP=no" | ||
| + | ~~~ | ||
| + | |||
| + | ### Exclusion | ||
| + | |||
| + | ** Le chemin des fichiers à exclure est relatif au répertoire que l'on sauvegarde. ** | ||
| + | |||
| + | ~~~bash | ||
| + | # FAUX | ||
| + | rsync --archive --verbose --stats --info=progress2 --delete --delete-excluded --exclude="/ | ||
| + | |||
| + | # Exclus tous les /tmp | ||
| + | rsync --archive --verbose --stats --info=progress2 --delete --delete-excluded --exclude="/ | ||
| + | |||
| + | # OK | ||
| + | rsync --archive --verbose --stats --info=progress2 --delete --delete-excluded -filter=" | ||
| + | ~~~ | ||
| + | |||
| + | **La racine "/" | ||
| + | |||
| + | Source https:// | ||
| + | |||
| + | |||
| + | Exclure les fichiers cachés | ||
| + | ~~~bash | ||
| + | rsync -ax --exclude=" | ||
| + | ~~~ | ||
| + | |||
| + | ### Liste bande passante / ressources | ||
| + | |||
| + | Liste bande passante / ressources | ||
| + | `--bwlimit=KBps` | ||
| + | ~~~bash | ||
| + | / | ||
| + | |||
| + | # systemd-run -p IOWeight=10 rsync -axvn --bwlimit=20480 /home/jean/ backup1:/ | ||
| + | ~~~ | ||
| + | |||
| + | Voir aussi | ||
| + | |||
| + | ~~~bash | ||
| + | renice +19 -p $$ >/ | ||
| + | ionice -c3 -p $$ >/ | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | ntop -A | ||
| + | sudo / | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Rsync en mode daemon | ||
| + | |||
| + | |||
| + | Voir : | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | Man Fr (old) | ||
| + | * http:// | ||
| + | |||
| + | Man recent | ||
| + | * https:// | ||
| + | |||
| + | |||
| + | ### Activation | ||
| + | |||
| + | `/ | ||
| + | ~~~bash | ||
| + | RSYNC_ENABLE=true | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | systemctl enable --now rsync | ||
| + | systemctl status rsync | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | rsync rsync:// | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | Exemple de fichier de conf | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | `/ | ||
| + | ~~~ini | ||
| + | uid = swift | ||
| + | gid = swift | ||
| + | log file = / | ||
| + | pid file = / | ||
| + | |||
| + | reverse lookup = false | ||
| + | |||
| + | |||
| + | [account] | ||
| + | max connections = 2 | ||
| + | path = /srv/node | ||
| + | read only = false | ||
| + | lock file = / | ||
| + | |||
| + | [container] | ||
| + | max connections = 4 | ||
| + | path = /srv/node | ||
| + | read only = false | ||
| + | lock file = / | ||
| + | |||
| + | [object] | ||
| + | max connections = 8 | ||
| + | path = /srv/node | ||
| + | read only = false | ||
| + | lock file = / | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Autres | ||
| + | |||
| + | Installeur Debian Calamares | ||
| + | ~~~ | ||
| + | Running (" | ||
| + | ~~~ | ||
| + | |||
| + | ## Pb | ||
| + | |||
| + | |||
| + | ### Pb de taille | ||
| + | |||
| + | Source : https:// | ||
| + | |||
| + | `rsync -ax --delete` ne fait pas forcément le sparce, et ne préserve pas les hardlinks | ||
| + | |||
| + | Pour vérifier que la copie fait bien la même taille | ||
| + | ~~~bash | ||
| + | #echo `find . -type f -ls | awk ' | ||
| + | echo `find / | ||
| + | echo `find / | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | rsync --delete -v -axHSc / | ||
| + | ~~~ | ||
| + | |||
| + | | Option | ||
| + | | --------------------- | ------------------------------------------- | | ||
| + | | **-c** | ||
| + | | **-H** | ||
| + | | **-S**\\ **--sparse** | handle sparse files efficiently | ||
| + | |||
| + | |||
| + | |||
| + | ### Pb : failed to set times on / No such file or directory | ||
| + | |||
| + | ~~~bash | ||
| + | sshfs SRV_DEST:/ | ||
| + | rsync -ax --bwlimit=20480 SRV_SRC01:/ | ||
| + | ~~~ | ||
| + | |||
| + | ~~~ | ||
| + | rsync: failed to set times on "/ | ||
| + | ~~~ | ||
| + | |||
| + | Solution : Tester avec l' | ||
| + | ~~~bash | ||
| + | rsync -ax -J --bwlimit=20480 SRV_SRC01:/ | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ### Pb clef USB sync | ||
| + | |||
| + | Sur clef USB le système peut bufferiser beaucoup trop. | ||
| + | La copie se met en pause un certain temps puis reprend. | ||
| + | Si on interrompt le rsync le " | ||
| + | |||
| + | Dans ce cas il est possible d' | ||
| + | |||
| + | Note : sur du FAT il est possible d' | ||
| + | |||
