Outils pour utilisateurs

Outils du site


informatique:rsync

Table des matières

rsync

rsync -avz -e ssh remote_user@remote.com:/home/remote_folder/ /home/rsync/from_remote

À noter la présence ou l'absence du slash '/' à la fin du répertoire source qui détermine si c'est le répertoire lui-même qui sera synchronisé (sans le /) ou bien son contenu (avec le /).

Si l'on veut passer des options à la commande ssh on ajoute des guillemets '“':

rsync -avz -e "ssh -i ~/.ssh/une_cle_privee" remote_user@remote.com:/home/remote_folder/ /home/rsync/from_remote

Quelques options pour la commande rsync:

    -v, --verbose increase verbosity (-v -vv -vvv)
    -q, --quiet decrease verbosity
    --progress show progress during transfer

    -n, --dry-run show what would have been transferred
    -z, --compress compress file data

    -a, --archive archive mode. It is a quick way of saying you want recursion and want to preserve everything.
    -r, --recursive recurse into directories
    -R, --relative use relative path names
    -t, --times preserve times
    -c, --checksum always checksum

    -u, --update update only (don't overwrite newer files)
    -W, --whole-file copy whole files, no incremental checks
    -I, --ignore-times Normally rsync will skip any files that are already the same length and have the same time-stamp. This option turns off this behavior.
    --size-only only use file size when determining if a file should be transferred
    --existing only update files that already exist

    --delete delete files that don't exist on the sending side
    --delete-after delete after transferring, not before
    --force force deletion of directories even if not empty

    --exclude=PATTERN exclude files matching PATTERN

    --daemon run as a rsync daemon
    --password-file=FILE get password from FILE

Tips & tricks

Synchro de machine

rsync -aP / root@5.196.33.193:/ -e="ssh -i /root/.ssh/syncdevartefacts" 
--exclude=/tmp/* --exclude=/proc/* --exclude=/sys/* --exclude=/dev/*
--exclude=/etc/network/interfaces --exclude=/etc/resolv.conf
--exclude=/root/* --exclude=/etc/mtab --exclude=/boot/*
--exclude=/etc/fstab --exclude=/net/*
informatique/rsync.txt · Dernière modification: 26/10/2015 17:53 par cyrille