Basic sync

rsync -ivaz --delete --progress --stats --exclude='bak' --exclude='mail' /source/ /destin/

-i: –itemize

-v: –verbose

-a: -rtp…

-z: –compress


rsync --existing -nucRPhivaz --stats --delete /source/ /destination/

-n: –dry-run

-u: –update

-c: –checksum

-R: –relative, create directories in the destination if they don’t exist

-P: –progress –partial

-h: –human-readable

--delete: delete files not present in the source

--stats: give some statistics

--existing: don’t create new files in the destination, only transfer files that exist in the destination


rsync --ignore-existing -nucRPhivaz --stats --delete /source/ /destination/

--ignore-existing: if a file exist in destination, don’t update it

Sync by ssh, including only one type of files

rsync -uPhivaz --stats  --include='*/' --include='*.dat' --exclude='*'  user@server.org:/path/to/remote/dir/ /path/to/local/dir/

First include all subdirectories, then all \*.dat files, and then exclude all others


Clone a partition

  • First unmount all external partitions from /home
umount /home/user/dir1; umount /home/user/dir2;
  • Then, the rsync command
rsync -havxHAWXS --numeric-ids --info=progress2 > ~/rsync.out 2> ~/rsync.err

-h : human readable numbers

-a : all files, with permissions, etc..

-v : verbose, mention files

-x : stay on one file system

-H : preserve hard links (not included with -a)

-A : preserve ACLs/permissions (not included with -a)

-W (–whole-file) : to avoid calculating deltas/diffs of the files.

-X : preserve extended attributes (not included with -a)

-S : account for sparse files.

--numeric-ids: to avoid mapping uid/gid values by user/group name.