Rsync is an open source utility for efficiently transferring and synchronizing files from one host to an another host. This tool is powerful because it can be a server and client. Rsync usually used to automate backup data from server to backup server.
The advantages of using rsync:
Save Bandwidth and Supports Resume
Flexibel
Fast
Easy Setup
Options | Function |
---|---|
-v, --verbose | increase verbosity |
-a, --archive | archive mode |
-r, --recursive | recurse into directories |
-u, --update | skip files that are newer on the receiver |
-e, --rsh=COMMAND | specify the remote shell to use |
-z, --compress | compress file data during the transfer |
-h, --human-readable | output numbers in a human-readable format |
let's go ahead and follow the tutorial to gain experience on Rsync.
This is the prerequisites before you start the tutorial.
In this tutorial used VPSServer.com[2] service to create two host using Ubuntu OS but you can also using this tutorial for other distro such as CentOS, Fedora, Debian, etc.
Rsync installation is very easy just by following the command
for Debian / Ubuntu
root@host-ubuntu:~# apt-get install rsync
for Fedora / CentOS / Scientific
root@host-centos:~# yum install rsync
That's it. Now you have rsync in your server :)
root@host01:~# mkdir primary
root@host01:~# touch primary/file{1..3}
check the folder and files, then fill the files with text
root@host01:~# ls primary/ root@host01:~# echo "im in file1" > primary/file1 && echo "im in file2" > primary/file2 && echo "im in file3" > primary/file3 root@host01:~# cat primary/file1 root@host01:~# cat primary/file2 root@host01:~# cat primary/file3
root@host01:~# rsync -avzh primary/ /tmp/secondary
Check the synchronize files
root@host01:~# ls /tmp/secondary/ root@host01:~# cat /tmp/secondary/file1 root@host01:~# cat /tmp/secondary/file2 root@host01:~# cat /tmp/secondary/file3
root@host01:~# rsync -avz primary/ root@185.144.157.99:/tmp/secondary/
Check the synchronize files
root@host02:~# ls /tmp/secondary/ root@host02:~# cat /tmp/secondary/file1 root@host02:~# cat /tmp/secondary/file2 root@host02:~# cat /tmp/secondary/file3
root@host01:~# rsync -avzhe ssh root@185.144.157.99:/tmp/secondary/ /root/secondary/
Check the synchronize files
root@host01:~# ls /root/secondary/ root@host01:~# cat /root/secondary/file1 root@host01:~# cat /root/secondary/file2 root@host01:~# cat /root/secondary/file3
root@host01:~# rsync -avzhe ssh primary/ root@185.144.157.99:/home/secondary
Check the synchronize files
root@host02:~# ls /home/secondary/ root@host02:~# cat /home/secondary/file1 root@host02:~# cat /home/secondary/file2 root@host02:~# cat /home/secondary/file3
root@host01:~# rsync -avzhe ssh --progress primary/ root@185.144.157.99:/root/secondary
root@host01:~# rsync --bwlimit=100 -avzhe ssh primary/ root@185.144.157.99:/opt/secondary
That's it. Installation and basic operation of Rsync. I hope you can understand rsync from this tutorial. If you encounter any bugs or documentation errors, please comments below :)
[1]: https://www.vpsserver.com/
[2]: https://www.vpsserver.com/
comments (0)