Rsync is an utility to (remote) synchronize files for backup/mirroring purposes.
The main advantages of the rsysnc is :
- Speed: Initially copies the whole content between local and remote system. Next time, it transfers only the changed blocks or bytes to the destination.
- Security: Encrypted form of data can be transferred using ssh protocol.
- Less Bandwidth: rsysnc uses compression and decompression of data block by block at both the end.
Rysync package must be installed on both remote system as well as local machine. Rsysncd listens the defaults TCP port 873, copying files via a remote shell such as rsh or ssh.
Syntax: #rsysnc [options] source path destination path
Example’s
Synchronize local directory |
|
Synchronize local to remote host |
|
Synchronize remote to local host |
|
In above command rsysnc uses:
- -z for enable compression,
- -v for verbose,
- -r for recursive.
- -a option, it preserves owner and groups, it preserve timestamp, symbolic links, permission, recursive mode.
Scheduling
You can schedule backup in cron using rsync command
0 0 * * * /usr/local/sbin/bkpscript.sh &> /dev/null
vi /usr/local/sbin/bkpscript.sh
rsync -avz -e ‘ssh -p2093′ /home/test/ root@192.168.1.150:/oracle/data/