11.4 C
Mel Khamlichi
Mel Khamlichi
Founder of Osradar, from Amsterdam Netherlands

Use rsync to set up remote disaster recovery backup system


- Advertisement -

In the previous article, we mentioned rsync installation and the use of some of the parameters. If you don’t understand, please read the Synchronous data Using the rsync Command Linux in this article. We learned that rsync works in three modes. The main introduction here is the server model

Server mode:

This model is based on C/S mode, in which rsync enables a daemon in the background that runs permanently on the rsync server to receive file transfer requests, so that clients can either send files to or request them from the daemon. Rsync’s server mode is ideal for use with remote central backup servers or data remote repositories.


To ensure data security, the need for a remote disaster system, the site data at 3 o ‘clock in the morning every day disaster backup to a remote server, because the quantity is very big, every day can only incremental backup, backup only increase of data in the day, when the site after a failure, can be backup to restore data to a great extent.

Solution: this assumes there is A, B two Linux system, A system as A web server, B system as A system of remote disaster backup machine, thus A system is rsyncd server, B system is as A system of remote disaster backup, need to install it in A and B system software, in this way, the rsync daemon running on A system, and can through the system in B daemon crontab to specified by A system backup data regularly, so as to realize the data remote disaster.

System environment

Two virtual machines and Install rsync


Rsync service configuration

We first need to create rsync’s configuration directory and the necessary configuration files.

Create a profile if none exists

touch /etc/rsyncd.conf

man rsyncd.conf to check the instructions

man rsyncd.conf 
man rsyncd.conf

Editor configuration file Add content

[root@localhost ~]# vim /etc/rsyncd.conf
uid = rsync
gid = rsync
fake super = yes
use chroot = no
max connections = 2000
timeout = 600
pid file = /var/run/
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
ignore errors
read only = false
list = false
hosts allow =
auth users = rsync_backup
secrets file = /etc/rsync.passwd
comment = welcome to xiyuxingxia backup!
path = /backup/
  • Add user rsync service users, manage local directory
[root@localhost ~]# useradd -s /sbin/nologin  -M rsync
[root@localhost ~]# id rsync

Configure the remote connected account

Create a password file

echo "rsync_backup:kobe" > /etc/rsync.passwd  
(Rsync_backup for remote user kobe for password rsync.passwd for password configuration file)

Set permissions for the password file

[root@localhost etc]# chmod 600 /etc/rsync.passwd
[root@localhost etc]# ll /etc/rsync.passwd
Configure the remote connected account
Configure the remote connected account

Create a Shared directory and authorize rsync as the user service manager

[root@localhost ~]# mkdir -p /backup
[root@localhost ~]# chown -R rsync.rsync  /backup
[root@localhost ~]# ll /backup

Start the rsync service and check

[root@localhost ~]# systemctl start rsyncd
[root@localhost ~]# systemctl status  rsyncd
Start the rsync service and check
Start the rsync service and check

Configuration complete! Congratulations! After the above operation, a backup server is set up under Linux!!!

Client configuration

Generate the password file needed to connect to the server

[root@localhost ~]# echo "kobe" >/etc/rsync.passwd

Set permissions for the password file

[root@localhost ~]# chmod 600 /etc/rsync.passwd

Create a directory for local backups

[root@localhost ~]# mkdir -p /backup

Push the contents of the client backup to the backup server

rsync -avz /backup/  rsync_backup@  --password-file=/etc/rsync.passwd
rsync Push

Pull content from the server to the client

[root@localhost backup]# rsync -avz rsync_backup@ /backup/  --password-file=/etc/rsync.passwd
rsync pull

So, enjoy it.

- Advertisement -


Please enter your comment!
Please enter your name here

Donate to Osradar

Latest article