Rsync For Beginners

What is Rsync in general ?

Rsync works like the rcp command in linux. It is used to copy files across machines. It uses efficient checksum algorithm that looks for modified files by time and size. It is used for two purposes:

Backup

Rsync is used to transfer file from the local to a remote machine. By default Rsync will use rsh, however you can instead use ssh for high security. Compressed files are transferred to save file transfer time and reduce the load on the network. It helps to transfer bulk files in minutes.

Mirroring

Rsync can synchronize file between two servers location(i.e) local and remote. By using the checksum algorithm it updates local files only if it is updated in remote server.

How to use Rsync

rsync -avze ssh -p2020 root@server.com:/sitepath/files   /localdata

This command transfer files from remote server to local machine.

a Archive. It is denotes all related files and documents. v Verbose.It will display status message as it is processing. z Compression.It achives better compression ratio. e It allows to chose alternative remote shell program for communication.

rsync -avze ssh -p2020 --exclude home/var/cache root@server.com:/sitepath/files /localdata

This command will transfer files from remote server to local machine by excluding cache folder.

rsync -avz /sitepath/files root@server.com:/localdata 

This command will transfer all file from local to remote server. It is uses default remote shell protocol.