Use rsync to mirror or backup directories and files between servers other

Source: Internet
Author: User
Tags ssh rsync
Home: rsync.samba.org
Environment: Redhat Linux 6.2, rsync 2.4.3 (download source compiles best),
Two Linux servers 192.168.11.7 (test) (rsync server), 192.168.11.2 (proxy) (rsync client)

Steps:

1. Download the latest rsync 2.4.3 source files compiled, see rsync.samba.org, as far as I know, only 2.4.3 support
Exclude options when mirroring--include and--exclude, compiled with an execution file rsync, just the execution file

2. Edit the configuration file/etc/rsyncd.conf as follows:
Log file =/var/log/rsyncd.log
PID file =/var/run/rsyncd.pid
Lock file =/var/run/rsync.lock

[Test]
Path =/test
Comment = Test folder
UID = root
Ignore errors
Read Only = yes
List = no
Auth users = Sun
Secrets file =/etc/test.scrt

Note: Defines a directory that needs to be mirrored for/test, requires a password connection, file in/etc/test.scrt,
Note the properties and permissions of the file-rw-------1 root test.scrt

[root@test/etc]# MORE/ETC/TEST.SCRT
Test:tset


3. Start Server Background rsync
# rsync--daemon
and add this line to/etc/rc.d/rc.local
# echo "Rsync--daemon" >>/etc/rc.d/rc.local

4. Set the client cron job on the server 192.168.11.2. Self-action backup or mirroring per night
0 * * 1-5/root/.test.sh
Note: Automatically run/root/.test.sh for backup every nine o'clock in the evening from Monday to Friday

#more/root/.test.sh
#!/bin/sh
Date= ' Date +%w '

Rsync-tvzrp-e ssh--progress--delete test@192.168.11.7::test/shopu/test/$DATE--password
-file=/etc/test >/var/log/test/test. $DATE
Mail-s "Test Backup is done" Myemailaddress </var/log/test/test. $DATE

[root@proxy/root]# More/etc/test
Tset
[root@proxy/root]# ls/etc/test-l
-RW-------1 Root 4 21:40/etc/test


Note: E-SSH indicates that the connection is encrypted with SSH, and server test is required to support SSH

5. Can be used for the following purposes:
A. Back up an entire directory on the primary server from another server, and exclude a subdirectory and file
B. Mirrors the home directory of the main Web server, suitable for image sites, with--delete to remove local files that are not on the server
It's really like, unlike Wget,wget. The local file does not download each file that the link points to according to the URL link of the site
Delete
Server data Synchronization server-side Cwrsync_server_2.1.5_installer.zip

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.