Data mirroring Backup tool for Rsync Linux system

Source: Internet
Author: User
Tags readable

Rsync is a data-mirroring backup tool for Linux systems, and--remote sync is visible from the name of the software. Rsync supports most Unix-like systems, which are well tested on Linux, Solaris, and BSD. The latest version of Rsync can be obtained from http://rsync.samba.org/rsync/. It has the following characteristics:
1, can be mirrored to save the entire directory tree and file system.
2, can easily do to maintain the original file permissions, time, soft and hard links and so on.
3, without special permission can be installed.
4, the optimized process, the file transfer efficiency is high.
5, you can use RCP, ssh and other means to transfer files, of course, you can also through a direct socket connection.
This article describes how to use the Rsync service for remote backup from Linux to Windows and Linux
First, configure the server side
Software download
RYSNC's home address is: http://rsync.samba.org/, you can download RYSN installation software from here.
Compiling the installation
The build-and-install of rsync is simple and requires only the following simple steps (installed on both servers):
$ tar xvf rsync-2.6.3.tgz
$ CD rsync-2.6.3
$./configure
$ make
$ make Install
However, it is important to note that rsync must be installed on both the primary and synchronization servers, where rsync is run in server mode on the primary server, and Rsync is run on a client-side basis. This will run the Rsyn daemon on the primary server, running the client on synchronization with Crond to synchronize the content that needs to be synchronized on the primary server.
Configuring the Rsync server Side
For the rsync server, the most important and complex is its configuration. The rsync server configuration file is/etc/rsyncd.conf, which controls authentication, access, logging, and so on. The file is made up of one or more module structures. A module definition starts with the module name in square brackets until the next module definition starts or the file ends, and the module contains a parameter definition in the format name= value. Each module actually corresponds to a directory tree that needs to be backed up, for example, in our instance environment, there are three directory trees that need to be backed up:/www/and/mirror/file0/and/mirror/file1/directories, then you need to define three modules in the configuration file, corresponding to three directory trees respectively. A configuration file is a unit of behavior, meaning that each new line represents a new comment, module definition, or parameter assignment.

For example, create a RSYNCD profile/etc/rsyncd.conf on 168 with the following content:
UID = Nobody # Backup in what capacity, User ID
GID = Nobody # Backup in what capacity, group ID
#注意这个用户ID和组ID, if it is convenient, it can be set to root so that rsync can almost
#以读取任何文件和目录了, but it also poses a security risk. The recommended setting is to read only what you want to prepare
#份的目录和文件即可.
#use chroot = No
Max connections = 0 # Maximum number of connections No limit
PID file =/var/log/rsync/rsyncd.pid
Lock file =/var/log/rsync/rsync.lock
Log file =/var/log/rsync/rsyncd.log
[Attachment] # Specify the name of the Certified backup module
Path =/www/htdocs/pub/attachment/# directory that needs to be backed up
Comment = BACKUP Attachment # comment
Ignore errors # Ignoring some unrelated IO errors
Read Only = False # set to not read-only
List = False # does not allow column files
#hosts allow = 210.51.0.80 #允许连接服务器的主机IP地址
#hosts deny = 0.0.0.0/0.0.0.0 #禁止连接服务器的主机IP地址
Auth users = Msyn # authenticated user name, if no this line, indicates is anonymous
Secrets file =/etc/rsyncd.scrt # Authentication file name, used to store the password
[98htdocs]
UID = nobody
GID = Nobody
Path =/www/htdocs/
#ignore errors
Read Only = False
List = False
#hosts allow = 210.51.0.98
#hosts deny = 202.108.211.38
#hosts deny = 0.0.0.0/0.0.0.0
Auth users = Msyn
Secrets file =/etc/rsyncd.scrt
[98html]
UID = ejbftp
GID = Nobody
Path =/www/htdocs/pub/html/
#ignore errors
Read Only = False
List = False
#hosts allow = 210.51.0.98
#hosts deny = 0.0.0.0/0.0.0.0
Auth users = 98syn
Secrets file =/etc/rsync98.scrt
Here respectively, [attachment], [98htdocs], [98html] three modules, respectively, corresponding to three need to backup the tree. Three modules authorized by the backup users are Msyn,msyn,98syn, the user information is saved in the file/etc/rsyncd.scrt and/ETC/RSYNC98.SCRT, the contents are as follows:
[Email protected]/etc]# CAT/ETC/RSYNCD.SCRT
Msyn:xxxxxxxxx
And the file can only be read and written by the root user, note that for security purposes, the properties of this file must be primary readable, otherwise rsync will refuse to run. We can set it to a property of 600:
[Email protected]/etc]# chmod 600/ETC/RSYNCD.SCRT
Once these files are configured, you will need to start the RSYNCD service on the primary server:
[Email protected]/etc]#/usr/local/bin/rsync--daemon

After executing the above command, Rsync is ready to start. The Rsync default service port is 873, and the server receives the client's anonymous or authenticated backup request on that port.
Second, configure the client
1. Execute rsync client command under Linux
The next step is to run the Rsync client startup command:
[[email protected]/]/usr/bin/rsync-vlzrtogp--progress--delete[email protected]:: 98html/usr/local/apache/htdocs/pub/html/--PASSWORD-FILE=/ETC/RSYNC98.SCRT
The above command line in the-VZRTOPG V is representative of verbose (verbose), Z is the representative of the zip (compression), R is representative of recursive (recursion), TOPG is to keep the original attributes of the file, such as the main, time parameters. --progress is the display of detailed progress,--delete is that if the server side delete the file, then the client will also delete the file, to maintain true consistency.
[Email protected]::98html means that the command is a backup of the 98html module in Server x.x.x.168, where 98syn means a 98syn user is used to back up the module. ---PASSWORD-FILE=/ETC/RSYNC98.SCRT to specify the password file, so that it can be used in the script without the need to interactively enter the authentication password, it is important to note that this password file permission property to be set only to execute this command of the current user readable, In this case, the 98syn user. The contents of the backup are stored in the/usr/local/apache/htdocs/pub/html/directory of the backup machine.
In this way, the Rsync synchronization service is set up, and finally we can automate the backup by crontab timed execution of the commands executed by the client, or write some scripts so that the Rsync synchronization service is built more perfectly.
2. Windows configuration Client
In order to use the Rsync tool in a Windows environment, we need to downloadCwrsyncTool, which is a version of Rsync for Windows.
Now that we can run the Rsync tool in a Windows environment, for example, use the following command to connect to the server and start backing up directories and files:
RSYNC-VZRTOPG--progress--delete[email protected]:: 98html. \bak\
Should be able to see:
Password
Prompt to enter a password, you should see the start backup after you enter the password correctly.
There are several possible causes of this error, one is that you did not enter the correct user name or password, and the second is that your server-side store password file does not have the correct permissions, that is, your password file is not similar to the permissions of the child:
-RW-------1 root root
You can read the password from the file by:
RSYNC-VZRTOPG--progress--delete[email protected]:: 98html. \bak\--PASSWORD-FILE=.\RSYNC98.SCRT
Can be written as a batch, to do Windows scheduled tasks inside, can be timed execution to achieve automatic backup.
You can also download the cwRsync-1.2.8 version here:Cwrsync_1.2.8_installer.exe

Data mirroring Backup tool for Rsync Linux system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.