Rsync is used to perform the backup in linux. Rsync stands for remote sync.This is very good tool to synchronize the files and directories from one location to another in an effective way. Backup location could be on local server or on remote server.
rsync replicates the whole content between the source and destination directories. Next time, rsync transfers only the changed blocks or bytes to the destination location, which makes the transfer really fast. It also allows the encryption of data across the network using ssh protocol during transfer.
rsync uses compression and decompression of data block by block at the sending and receiving end respectively. So the bandwidth used by rsync will be always less compared to other file transfer protocols.
Syntax for using rsync is
#rsync options source_address destination_address
Some Example for using rsync are :-
1. To sync two directories in a local computer, use the following rsync -zvr command.
rsync -zvr /home/data /root/temp
In the above example
- -z is to enable compression
- -v is for verbose
- -r is for recursive.
2. To preserve timestamps during Sync using rsync -a
#rsync -azv /home/data /root/temp/
3. To Synchronize Files From Local to Remote
#rsync -avz /home/data email@example.com:/root/temp
If you want to synchronize it from remote to local, change the source to remote location and destination to local one.
4. rsync allows you to specify the remote shell which you want to use. You can use rsync ssh to enable the secured remote connection.
#rsync -avz -e ssh firstname.lastname@example.org:/home/data /root/tmp
If you want to put this command in crontab, then you can create ssh keys and share the public keys so that I will not prompt the password.
There are many option which we can try it out with rsync.
In conclusion, rsnyc is a very good and reliable backup tool that gives us speed, security and compression during data transfer. Please try this out
For more detail, please refer http://www.thegeekstuff.com/2010/09/rsync-command-examples/