RSYNC a remote sync Utility
Definition of Remote SYNC (rsync):
RSYNC is a very flexible network-enabled syncing tool and refers to the network protocol developed to utilize this tool. It stands for “remote sync”, is a remote and local file synchronization tool.
INSTALLATION
It is installed by default in ubuntu system and in case, it is not there, it can be installed using the following steps:
- login to the terminal of the system
- switch to root
- run command
- apt-get install rsync
- this will install the rsync into your machine
- same step has to repeat on the remote machine in case of remote sync
[bibblio style=”bib–row-3 bib–default bib–hover bib–white-label bib–font-arial bib–size-18″ query_string_params=e30=]
Syntax of RSYNC
- local Rsync:
say we have two directories and we need to perform rsync the syntax becomes as :
rsync dir1 dir2
it will create a difference copy from dir2 to dir1, when we say difference copy tit means that rsync always gets the diff of content.
Flags used :
-a – for recursive rsync
-r similar to -a for recursive rsync
-P
-n
-v verbrose
-z compression
example : rsync -azP source destination
2.Remote Rsync
- from remote – to – local
rsync -a user@remote_host:/home/path/dir1 local_path
- user is the user for the remote
- remote_host : IP for the server
- /home/path – till directory which is required to do sync
- local_path – path in the local system to perform rsync
2. from local – to – remote
rsync -a local_path user@remote_host:/home/path/dir1
Complete RSYNC
In order to keep two directories truly in sync, it is necessary to delete files from the destination directory if they are removed from the source. By default, rsync does not delete anything from the destination directory.
We can change this behaviour with the –delete option. Before using this option, use the –dry-run option and do testing to prevent data loss:
rsync -a –delete source destination
This is very nice utility when we need to frequently do work on different servers and it saves a lot of time in doing WINSCP/FTP
Also Click to Read : SSH without password and Mysql Connection Error