rsync is a fast file copying tool. It can copy locally, to/from another host over any remote shell, or to/from a remote rsync daemon. It offers a delta-transfer algorithm, which reduces the amount of data sent over the network by sending only the differences between the source files and the existing files in the destination. Rsync is widely used for backups and mirroring and as an improved copy command for everyday use.
--progress- show progress while transferring data.
--delete- delete files in destination directory, if they not exist in a source.
-v- verbose output.
-a- archive and sync recursively. Preserves symbolic links, special and device files, modification times, group, owner, and permissions.
-r- copies data recursively (but don’t preserve timestamps and permission while transferring data).
-z- compress file data.
-h- human-readable output.
-n- dry run.
Sync (copy) a file:
rsync -zh backup.tar.gz /tmp/backups/
Sync contents of dir1 to dir2:
rsync -a dir1/ dir2
Trailing slash (/) at the end of folder name used to sync the folder content.
Dry run. Check what will be done:
rsync -anv dir1/ dir2
Include only specific file type to sync:
rsync -av dir1/ dir2 --include '*.rpm' --exclude '*'
Exclude specific file type from sync:
rsync -avz dir1/ dir2 --exclude '*.conf'
Copy (sync) file from remote machine, to local:
rsync -vzh [email protected]:/home/srvadmin/backup.tar.gz tmp/ --port 666
Copy (sync) file from local machine, to remote:
rsync -vzh backup.tar.gz [email protected]:/home/srvadmin --port 666
Check out the manual page to read more about