rsync server set up
[Beinan @ beinnaIBM: ~] $ rsync – list-only linuxsir@linuxsir.org:: linuxsirhome CODE>
STRONG>
4.2 module definition;
gid = root
try this?
[beinan @ beinnaIBM: ~] $ echo “222222″> rsync.password CODE> [beinan @ beinnaIBM: ~] $ rsync-avzP-delete-password-file = rsync.password linuxsir@linuxsir.org :: linuxsirhome linuxsirhome
timeout = 300
linuxsir.org rsync 2002-2007
[beinan @ beinnaIBM: ~] touch / etc / rsyncd / rsyncbeinan.password
hosts allow = 192.168.1.0/255.255.255.0 10.0.1.0/255.255.255.0
then we will have the / home directory to create linuxsirhome and beinanhome two directories, meaning that the server linuxsirhome data synchronization to the backup server / home / linuxsirhome Next, beinan synchronize data to / home / beinanhome / directory. Create a directory on the archive according to years; daily backups are archived;
and in our example rsyncd.secrets reads as follows similar; in the document that some systems do not support long password, they set about trying to it. In addition rsyncd.secrets file permissions to other user groups is unreadable. If you set wrong, rsync may not work.
Some features of rsync include
motd file = / etc / rsyncd / rsyncd.motd
selective chain to maintain symbolic links, hard links, file belongs to, access, equipment and time;
[linuxsirhome]
[beinan @ beinnaIBM: ~] echo “222222″> / etc / rsyncd / rsynclinuxsir.password
[root @ linuxsir :~]#/ usr / local / bin / rsync – daemon – config = / etc / rsyncd / rsyncd.conf CODE>
Note: STRONG> use chroot, in the transmission file, the server daemon In the chroot to the file system directory, so the advantage of the system may be installed to protect the possibility of invasion vulnerability. Disadvantage is the need superuser privileges. In addition to the symbolic link file will be excluded. In other words, you rsync server, if there are symbolic links, you run the client on the backup server data synchronization, synchronize only the symbolic link name down, and does not synchronize the contents of symbolic links; this need to try their own ;
Of course you can write a script to automatically start rysnc boot server, you try to look up the document, this simple. I use slackware have a similar script. I feel as a direct hand in running, or write this command in the rc.local file, so the same can be run automatically;
gid = nobdoy CODE>
linuxsirhome linuxsir home data
UL>
# uid = nobody
transfer logging = yes CODE>
Note: STRONG> This is not need password; In fact, this is more important, because the server via crond Scheduled Tasks or necessary;
log format =% t% a% m% f% b
[beinan @ beinnaIBM : ~] $ touch rsync.password
comment on this
STRONG>
[beinan @ beinnaIBM: ~] mkdir / etc / rsyncd /
[beinan @ beinnaIBM: ~] $ rsync – list-only linuxsir@linuxsir.org:: CODE > < br /> Note: STRONG> password is worth noting here, for security, you can not write the system user password here. Such as your system user linuxsir password is abcdefg, for safety, you can rsync the linuxsir to 222,222. This is the password for samba user authentication principle is similar;
* can use rsh, ssh or direct sockets as the transport
Note: STRONG> in / etc / cron.daily / created two files beinan.sh and linuxsir.sh, and is the authority is 755. Create two password files, linuxsir user using rsynclinuxsir.password, and beinan user using rsyncbeinan.password, permissions are 600;
comment = linuxsir home data Note: Comments may define their own, to write anything you like , write relevant content on line;
UL>
-a parameter, the equivalent-rlptgoD,-r is recursive-l from the linked file, meaning that copies of the linked file;-p to keep documents that the original authority;-t keep the old time;-g keep the old user group;-o keep the old owner;-D equivalent of a block device file;
Note: STRONG > server-side transfer files to send to which users and groups to perform, the default is nobody. If the nobody user and user group permissions problems you may encounter some files from the server could not pull down. So I lazy, for convenience, use the root. However, you can define the directory to be synchronized when the user specified in the module definition to solve the access problem.
UL>
timeout = 300 CODE> UL>
module defines what is it? Which mainly defines the directory server to be synchronized. Each module must be in [name] form. The name is the rsync client to see the name, in fact, a bit like the Samba server share name. The server is a real synchronized data to the specified path. We can according to their needs, to specify more than one module. Each module to specify user authentication, password files, but exclude is not required; the following examples in front of the module configuration file:
rsyncd.conf rsync server is the main configuration file, we come to a simple example; example, we want backup server / home and / opt, in the / home, I want to beinan and samba directory excluded;
Note: STRONG> is a must for auth users on the server of the real system users, if you want to use more than one user, then in order, comma-separated list; example auth users = beinan, linuxsir
[root @ linuxsir: beinan] # slackpkg install rsync Note: Slackware packages online installation;
5.1 start rsync server;
auth users = beinan
# transfer logging = yes
STRONG>
Note: STRONG> motd file is to define the server information, to write their own rsyncd.motd contents of the file. When users log in to see this information. For example I wrote:
CODE> log file = / var / log / rsync.log CODE>
can update whole directory trees and file systems, and;
secrets file = / etc / rsyncd / rsyncd.secrets Note: The password exists which documents;
exclude = beinan / samba / CODE>
Note: STRONG>
STRONG>
rsyncd.motd file;
3.2 rsync server configuration file rsyncd.conf;
STRONG>
list = no
max connections = 5 CODE>
[beinan @ beinnaIBM: ~ ] chmod 600 / etc / rsyncd / rsyncbeinan .* CODE>
5.2 rsync servers and firewalls;
# log file = / var / log / rsync.log
[root @ linuxsir: ~] # iptables-A INPUT-p tcp-m state – state NEW-m tcp – dport 873-j ACCEPT
the first line is a comment, is to specify the content, so can his mind.
-rw ——- 1 root root 14 2007-07-15 10:21 / etc / rsyncd / rsyncd.secrets
[beinan @ beinnaIBM: ~] echo “333333″> / etc / rsyncd / rsyncbeinan.password CODE>
[root @ linuxsir: / home / beinan / sync-xxx] #. / configure – prefix = / usr; make; make install Note: The use of source package compiled and installed, you have to install gcc and other compilation issued by the job; CODE> UL>
[root @ linuxsir: ~] # mkdir / etc / rsyncd Note: The / etc directory to create a rsyncd directory, we used to store and rsyncd.secrets rsyncd.conf file;
Note: STRONG> This command means is that, with linuxsir user logged into the server, the linuxsirhome data, synchronize a local directory linuxsirhome on. Of course, the local directory is your own definition, such as linuxsir also possible; when you are on the client, the current operation of the directory does not linuxsirhome this directory, the system will automatically create for you; when there linuxsirhome this directory, You should pay attention to it write permissions.
Note: The module, which provides us with a link name, link to where it, in this module, the link to the / home directory; use [name] form;
use chroot = yes < br /> Username: Password CODE>
for the installation concerned, without any special permission requirements;
For multiple files, the files within the assembly line to reduce the delay to wait; < br /> [beinan @ beinnaIBM: ~] $ chmod 600 rsync.passwod
other Linux distributions, please use the appropriate package management to install; if the source package, that is, using the following methods;
comment = linuxsir home
Note: STRONG> This is a file transfer logs;
6.1 rsync server on the list provided by the synchronization content;
heavyweight application server, so network data backup or extremely important. We can be configured on the production server, rsync server. We can put a computer with rysnc machine as a backup server. So that the backup server, start at 4 am every day synchronize data on the server; and each backup is a full backup. Sometimes broken hard drive, or server data is deleted, a full backup is still quite important. This is equivalent to a daily backup of data for the server to do a mirror, when the accident occurred when the production server, we can easily restore the data, can minimize data loss; is not the case? ?
This time we added an option-password-file = rsync.password, this is when we linuxsir rsync server synchronize user login data, passwords will read rsync.password this document. This file will contain only linuxsir user password. We are doing;
[beinan]
add the following contents:
beinan: 333333 CODE>
Step Two: Modify the server configuration file crond < / STRONG>
ignore errors CODE> UL>
UL>
ignore errors
[beinan @ beinnaIBM: ~] touch linuxsir.sh beinan.sh < br /> can use rsh, ssh or direct transfer port as input port;
our editorial beinan.sh, the content is:
# limit access to private LANs
-v transmission the progress of time and other information, and relationship-P bit, see for yourself. You can see the document;
# linuxsir.org beinan home backup
1 What is rsync;
exclude = beinan / samba /
set up rsync server is relatively simple to write a configuration file rsyncd.conf. File writing is also a rule, we can refer to the documentation on rsync.samba.org do; course, we must first install the software because as rsync; UL>
* optionally preserves symbolic links, hard links , file ownership, permissions, devices and times
uid = nobody
The second line means that every morning 4:10, when running / etc / cron.daily.rsync executable script task under ;
[root @ linuxsir: ~] # touch / etc / rsyncd / rsyncd.motd CODE>
[root @ linuxsir: ~] # touch / etc / rsyncd / rsyncd.conf Note: Creating rsyncd.conf, which is the rsync server configuration file;
[beinan @ beinnaIBM: ~] touch / etc / rsyncd / rsynclinuxsir.password
[beinan @ beinnaIBM: ~] chmod 755 / etc / cron.daily.rsync / *. sh
Linux firewall with iptables, so we let you at least on the server side rsync server port defined by the client should also be let through.
STRONG>
[root @ linuxsir: ~] # chmod 600 / etc / rsyncd / rsyncd.secrets Note: In order to password security, we set the permissions 600;
Note: STRONG> you can specify a single IP, you can specify an entire network segment, to improve security. Format between the ip and ip, ip, and between segments, use a space between the segments and segment separated;
uid = root
forwarded to the microblogging
[beinan @ beinnaIBM: ~] mkdir / home / beinanhome CODE>
hosts allow = 192.168.1.0/255.255.255.0 10.0.1.0/255.255.255.0 CODE>
# gid = nobody
[root @ linuxsir: ~] # ls-lh / etc / rsyncd / rsyncd.secrets
/ usr / bin / rsync-avzP – password-file = / etc / rsyncd / rsyncbeinan.password linuxsir@192.168. 1.171:: beinan / home / beinanhome / $ (date m-% d-% y CODE>
[root @ linuxsir: ~] # iptables-L look at the firewall is not open 873 port; CODE> UL>
Note: exclude is excluded from the meaning, that is, make the / home directory under the beinan and samba excluded; beinan / and samba / directory with spaces between the separate;
secrets file = / etc / rsyncd / rsyncd.secrets
< br />
hosts deny =*
# Run daily cron jobs at 4:10 every day backup linuxsir data: < br />-P transfer process;
# limit access to private LANs
read only = yes
< br /> rsync is a file transfer program for Unix systems. rsync uses the “rsync algorithm” which provides a very fast method for bringing remote files into sync. It does this by sending just the differences in the files across the link, without requiring that both sets of files are present at one of the ends of the link beforehand.rsync is a Unix file system synchronization and transmission tools. rsync is using “rsync algorithm” provides a remote file server, client and quick way to synchronize files.
/ usr / bin / rsync-avzP – password-file = / etc / rsyncd / rsynclinuxsir.password linuxsir@192.168.1.171:: linuxsirhome / home / linuxsirhome / $ (date m-% d- % y CODE>
#! / bin / sh
Next we modify the rsyncd.conf file and rsyncd.secrets and rsyncd.motd time;
ignore errors Note: Ignore IO errors, please check the detailed documentation;
max connections = 5
address = 192.168.1.171
# See rsync (1) and rsyncd.conf (5) man pages for help CODE> # This line is required by the / etc / init.d / rsyncd script
[beinan @ beinnaIBM: ~] $ rsync-avzP – delete linuxsir@linuxsir.org:: linuxsirhome linuxsirhome CODE>
ignore errors
[beinan @ beinnaIBM: ~] cd / etc / cron.daily.rsync
software installation is too simple, and now Linux major distributions provide the package, of course, you could compile your own installation, in the present circumstances, I do not need much;
First of all: we look at the rsync server which can be used to provide data source;
for heavyweight server, the network should have a backup server, only local backup is not enough, there are still the best network backup hosts so that data security can only be guaranteed. After all data on the server or on a local not safety, such as disk broken, remove the data by hackers hack into the server. In fact, the value of the server itself is not large, it is important that the value of data.
6.3 tells rsync client to automatically synchronize data with server;
[root @ linuxsir: / home / beinan] # cd sync-xxx
supports anonymous rsync file synchronization is an ideal imaging tool;
rsync server set up is simple, probably after we installed rsync, and did not find the configuration file, and start the program rsync server, rsync because each administrator may use different, so the general release of the software is installed get away, allowing administrators to use and according to their own direction to set up rsync server; because the rsync application more widely, in the same host backup, can also work between the different hosts. Between different hosts backup, must be set up rsync server.
* requires no special privileges to install
path = / opt Note: The specified file directory location;
comment = optdir
UL> < br /> [root @ linuxsir: ~] # touch / etc / rsyncd / rsyncd.secrets Note: Create rsyncd.secrets, this is the user password file;
[beinan @ beinnaIBM: ~] $ rsync – avzP – delete – password-file = rsync.password linuxsir@linuxsir.org:: linuxsirhome linuxsirhome CODE>
Note: STRONG> read only read-only selection, that is, allow client to upload files to the server. There is also a write only option, they try to do anything with it;
comment = optdir
the rsync server, there are several more global definition of the relevant health, according to our earlier configuration file rsyncd.conf file;
This time we introduce a – delete option, said the data on the client is fully consistent with the server side, if linuxsirhome directory on the server does not exist in the file, delete it. Ultimate goal is to linuxsirhome data directory on the server completely consistent; to be careful with the time, it is best not to have been important, according to the number of the directory as local update directory, otherwise it will delete all your data;
pid file = / var / run / rsyncd.pid Note: tell process writes / var / run / rsyncd.pid file;
log format =% t% a% m% f% b
2 rsync server reason;
first step: Create the password file synchronization script and STRONG>
4 set up rsync server is an example;
STRONG>
[beinan @ beinnaIBM: ~] mkdir / etc / cron.daily.rsync
* supports anonymous rsync which is ideal for mirroring
pid file = / var / run / rsyncd.pid
Description: STRONG>
[beinan]
[beinan @ beinnaIBM: ~] $ rsync-avzP linuxsir@linuxsir.org: : linuxsirhome linuxsirhome
path = / home
[root @ linuxsir: beinan] $ sudo apt-get install rsync Note: In debian, ubuntu and other online installation methods;
[beinan @ beinnaIBM: ~] mkdir / home / linuxsirhome
read only = yes CODE>
syslog facility = local3
STRONG>
10 4 * * * / usr / bin / run-parts / etc / cron.daily.rsync 1> / dev / null CODE>
UL>
[linuxsirhome]
3.1 rsync installation;
< CODE> #! / bin / sh
STRONG>
list = no
Note: STRONG> If you can not find the rsync command, rsync is installed you should know in which the. Such as rsync executable command may be installed in the / usr / local / bin directory; is the following command;
our editorial linuxsir.sh, the content is as follows:
linuxsir.org rsync 2002-2007
auth users = linuxsir Note: User authentication is linuxsir, there must be a user on the server;
port = 873 Note: The specified port is running, the default is 873, you can specify your own;
It is defined rysnc server information, that is, the user login information. Example, let users know who the server is available, etc.; similar to ftp server logs, we see linuxsir.org ftp … …. Of course, this definition of the global variables are not necessary, you can use the # Note out, or deleted; I am here to write the contents of a rsyncd.motd:
STRONG>
rsync includes the following features:
secrets file = / etc / rsyncd / rsyncd.secrets
# linuxsir.org home backup
port = 873
forwarded to microblogging address = 192.168.1.171 Note: specify the server IP address;
STRONG>
4.1 globally defined;
Note: STRONG> client maximum number of connections;
STRONG>
# Distributed under the terms of the GNU General Public License v2
6 clients via rsync to synchronize the data;
path = / opt
in my opinion point of view, if the same host in the Backup file, use the copy tool like cp. No need to use such a relatively complex tool rsync, cp is also easy to use, of course, this is a personal point of view;
start the rsync server is quite simple,-daemon is to rsync in server mode;
auth users = linuxsir
Note: STRONG> You can put linuxsir.sh and beinan.sh the content into a single file, for example, are written linuxsir.sh in;
list = yes Note: list means that the rsync server to provide directory synchronization data module is displayed on the server listed. The default is yes. If you do not want listed, no; if no is relatively safe, at least people do not know your server, which provides a directory. You know on the line;
# This will log every file transferred – up to 85,000 per user, per sync
motd file = / etc / rsyncd / rsyncd.motd CODE> < br /> STRONG>
[beinan @ beinnaIBM: ~] crontab-e CODE>
STRONG>
# Minimal configuration file for rsync daemon
linuxsir.org rsync server
list = yes
3 set up rsync server process;
* can update whole directory trees and filesystems
auth users = beinan note: there will be sections on the server the user;
path = / home Note: specify the file directory location, which must be specified;
# This will give you a separate log file
In addition to a large number of files from one server to another server, rsync does not do a transfer tool. Companies have a file server, the configuration is CPU Intel Celeon 333Mhz, Memory 128M, hard disk IDE 80Gx3 = 240G, which is only the first hard drive 12G partition install the system, as with a 256M swap partition, the space I have used other stored data, by LVM volumes to manage disk space, I scored a 180G of space for data storage, then data storage capacity has reached more than 160 G. What happened was the server space is limited, did not do a local backup. Can add up more hard disk, because the machine did not do RAID, a broken hard disk, all data will be destroyed without any security protection. In this case, in order to ensure the security of data, I was forced to do a file server with Raid5 support. Data files in the choice of how to complete the transfer to the new server, I think a lot of tools, and finally thought of rsync. I spent ten minutes setting up and debugging of rsync, and then start the file transfer, because too many files on the file server, the old file server configuration and low, I spent about two or three days it was able to put all the file transfer is completed.
CODE> UL>
linuxsir: 222222 < br /> [root @ linuxsir :~]#/ usr / bin / rsync – daemon – config = / etc / rsyncd / rsyncd.conf CODE>
5 start rsync server and firewall set;
* internal pipelining reduces latency for multiple files
Password: password linuxsir here to enter, is to provide server-side, in the previous example, we use 222 222, the password is not displayed; lost after a good carriage; CODE>
[root @ linuxsir: / home / beinan] # tar xvf sync-xxxx.tar.gz or sync-xxx.tar.bz2 < br />
Note: STRONG> in front of rsync available data sources, which we wrote in the rsyncd.conf [linuxsirhome] module. The “linuxsir home data” by [linuxsirhome] module comment = linuxsir home data provided; Why did not beinan data source list come from? Because we [beinan] has put a list = no.
STRONG>
we can refer to rsyncd.conf.html STRONG>. Specific steps are as follows;
Note: STRONG> rsync server logs;
[root @ linuxsir: beinan] # yum install rsync Note: Fedora, Redhat and other system installation methods; CODE >
password file: / etc / rsyncd / rsyncd.secrets content formats;
6.2 rsync client synchronization data;
Then we modify / etc / rsyncd / rsynclinuxsir.password and rsyncbeinan.password content;
STRONG>
use chroot = yes CODE>
syslog facility = local3
secrets file = / etc / rsyncd / rsyncd.secrets < br />-z transmission compression;
