What is Rsync

hr-ethadmin
Site Admin
Posts: 67
Joined: Fri May 31, 2013 1:04 pm

What is Rsync

Postby hr-ethadmin » Mon Oct 21, 2013 11:32 am

What is Rsync?

Rsync is a program, which is used for taking the backups on regular basis. However it can also be configured to upload large portals and any other data on the remote servers. It is very similar to rcp but with many more features. It is based on remote-update protocols, which means that it only sees the differences between the source and destination files and if the files has been changed, takes the backup otherwise leaves it without taking any backup. This difference may be the time stamp difference i.e. the date when it was modified or created is changed. By virtue of which it speeds up the file transfers even if it is of several gigabytes.

It can be used to copy files from remote machines to local machines and vice versa in which one of the machine must be local. It can also be utilized to take the backup locally to different partitions.

Command to check if Rsync is installed on the machine
# rpm -q Rsync
# rsync-2.4.1-2

It means that the Rsync installed on the machine is version 2.4.1-2. If it doesn't display and says not installed then you first have to install Rsync on the server side. Once installed you can use Rsync to any machine that you can use rsh to. Rsync uses rsh for its communications, unless both the source and destination are local.

To install Rsync give the command
#rpm -Uvh rsync-2.4.1-2.i386.rpm

In order to run an Rsync program you must have to run Rsync daemon at the server. This is accomplished either running the command
#rsync --daemon
or you can edit two files if you want rsyncd daemon to run when system boots.
1. Append the following text in /etc/services file, if not already there: rsync 873/tcp


2. Make an entry in /etc/inetd.conf by putting the line

rsync stream tcp nowait root /usr/bin/rsync rsyncd --daemon

Replace the "/usr/bin/rsync" with the path where you have installed the rsync. Its a good idea to run the rsync daemon during the boot time when you have to use rsync very often. During the boot time it initiates the rsyncd daemon through the super server i.e inetd.

Rsync configuration files

There are three configuration files to run rsync server viz.
1. /etc/rsyncd.conf,
2. /etc/rsyncd.pid
3. /etc/rsyncd.secrets
1. /etc/rsyncd.conf file configurations:

When you run Rsync with --daemon mode /etc/rsyncd.conf is the runtime configuration file through inetd daemon. This way rsync becomes an rsync server listening on TCP port 873. Connections from Rsync clients are accepted for either anonymous or authenticated Rsync sessions. The rsyncd.conf file controls authentication, access, logging and available modules.

File Format of rsyncd.conf:
The file consists of modules and parameters. A module begins with the name of the module in square brackets and continues until the next module begins. Modules contain parameters of the form 'name = value'. For more information about format you can read out the man pages of rysncd.conf

The contents of a /etc/rsyncd.conf file may be:

#### rsyncd.conf file ####
uid = username
gid = usergid
pid file = /etc/rsyncd.pid
syslog facility = daemon
[modulename] #Module name could be any name
path = /path/to/yourdata
comment = user related any info
auth users = anonymous username
hosts allow = x.x.x.x
secrets file =/etc/rsyncd.secrets
max connection = 0
use chroot = true
timeout = 60
#### End of configuration file ####

The file contains hundreds of options; we will only discuss only those, which are important and generally used. The file contains some global parameters like motd, syslog etc. Others are module related. In the above configuration, a square bracket represents the module for a particular dir, which is generally backed up. Comments are any user related info. The "auth users" gives the details of the users who can use this module. The "hosts allow" specifies the clients which can connect to server. "Secrets file" gives the username & password of the user connecting, "max connections" represents the maximum number of clients which can connect simultaneously. If "use chroot" is true, the Rsync server will chroot to the "path" before starting the file transfer with the client. Timeout option is for I/O timeout for this module.

2. The file /etc/rsyncd.secrets can be like this containing the username and password with a colon in between on the client side i.e.

username : yourpassword

3. To create an empty file /etc/rsyncd.pid to place the process related arguments.

Some examples of how you can run rsync from the client side are as follows:

#rsync -avzrpog username@hostname.domain::modulename /path/to/put-data --password-file=/root/password --safe-links

This will retrieve all the data from the module "modulename" at the host "hostname" to my local machine. The options -avzrog are used to get the data in an archive(a), verbose(v), recursive(r), preserver permissions(p),preserver owner(o),preserver group(g). Also for a server to check whether it is running Rsync server or not.

You can put such lines according to your requirement in a file and run through cron.

#rsync hostname.domain:: This will list out all the modules running on the server.

Return to “Hostripples dedicated Servers (Linux/Windows)”

Who is online

Users browsing this forum: No registered users and 1 guest