Remote Sync – Examples

I am mainly a developer and use server just to get my code online so I often forget how to use rsync. So here is my cheat sheet for rsync 🙂

  1. -v : verbose
  2. -r : copies data recursively (but don’t preserve timestamps and permission while transferring data
  3. -a : archive mode, archive mode allows copying files recursively and it also preserves symbolic links, file permissions, user & group ownerships and timestamps
  4. -z : compress file data
  5. -h : human-readable, output numbers in a human-readable format


Do a Dry Run with rsync

Use of this option (--dry-run) will not make any changes only do a dry run of the command and shows the output of the command, if the output shows exactly same you want to do then you can remove ‘–dry-run‘ option from your command and run on the terminal.


rsync --dry-run --remove-source-files -zvh backup.tar /tmp/backups/

Copy/Sync a Directory on Local computer


rsync -avzh /root/rpmpkgs /tmp/backups/

Copy a File from a Remote Server to a Local Server with SSH


rsync -avzhe ssh root@  /home/destination

Exclude multiple files and directories at the same time

rsync -avzh --exclude file1.txt --exclude dir3/file4.txt SOURCE/ DESTINATION/


More detailed examples are found here: Link and link

Leave a Reply

Your email address will not be published.