simon / Rsync

Last active 1 month ago

Revision b16c3363736fff84386b9a9264ebe38c49aeb71d

rsync.md Raw

rsync

  • rsync saving ACLs and xattrs:

rsync -avPAX

  • rsync only files less than $x days old preserving directory path on remote host:

find . -type f -mtime -4 -print0 | rsync -0adv --files-from=- ./ root@target-host:/target/path/

  • rsync files created in the last 30 days:

rsync -avP --files-from=<(find . -type f -mtime -30 -exec basename {} \;) $(pwd)/ root@target:/path/

  • rsync with spaces in path (-s = protect-args):

rsync -avPs root@target:/path/to/'a file' /destination/

  • rsync full system backup:

rsync -chavzP --rsync-path="sudo rsync" --stats --exclude /dev/ --exclude /proc/ user@source:/ .

  • rsync only selected directories:

rsync -avP --include 'dir1/***' --include 'dir2/***' --exclude '*' /tmp/test/ root@remote:/tmp/test/