RSYNC a remote sync Utility

Definition of Remote SYNC (rsync):

Is a very flexible network-enabled syncing tool. It can also refer to the network protocol developed to utilize this tool. It stands for “remote sync”, is a remote and local file synchronization tool.

 




 

INSTALLATION

The term comes by default in ubuntu system and in case, not their then 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

 

Syntax of RSYNC

  1. local Rsync:

say we have two directories and we need to perform rsync the syntax becomes as :

Test example for rsync (remote sync)

rsync dir1 dir2

it will create a difference copy from dir2 to dir1, when we say difference copy their comes the beauty of rsync and i.e 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

  1. 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 lot of time in doing WINSCP/FTP

Also Click to  Read : SSH without password   and  Mysql Connection Error

Related

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate »
[huge_it_videogallery id="2"]
Close