Friday 13 July 2012

File Synchronization with rsync

The magic of synchronization is very helpful for backups, keeping web servers synchronization. It is very fast than copying of files and takes low bandwidth, using one command only.

Installation of rsync


Mostly linux flavours contains pre installed rsync. If this service is not installed we can install with package manager. In the case of ubuntu below command is used:
aptitude -y install rsync
Below command is used to copy local to server:
local /home/kevin/source to /home/kevin/destination which resides on the server: server.mysite.com:
rsync -az --progress --size-only /home/kevin/source/* server.mysite.com:/home/kevin/destination/
prefix with sync explained:
1) -r
recursive
2) a
archive, preserves all attributes like ownership, timestamps, etc
3) z
compress, saves bandwidth but is harder on your CPU so use it for slow/expensive connections only
4) --progress
shows you the progress of all the files that are being synced
5) --size-only
compare files based on their size instead of hashes (less CPU, so faster)

No comments:

Post a Comment