rsync remote Sync Linux and Windows host

Source: Internet
Author: User
Tags rsync

First, preface

1. Rsync principle and Rsync+inotify trigger synchronization

http://nmshuishui.blog.51cto.com/1850554/1387048

2. This article explains

To ensure absolute reliability of the data:

First, all of the server's data is packaged and backed up in a local copy, as in the previous blog

Second, separate out a PC to do the backup machine, for the rsync client, timed to pull each rsync server back-up data packets every day.

Again, use rsync to sync Linux and Windows servers

3. Server description

Rsync Server: 192.168.200.16,192.168.200.18

Rsync Client: 192.168.1.186

These three servers are Linux,rsync synchronous Windows Server to Linux server in fourth

Ii. deployment of the rsync server
1. Zen Channel Server (192.168.200.16)
(1) Install the Super daemon

#yum –y Install xinetd

(2) Provision of configuration files for rsync services

#vim/etc/rsyncd.conf
#Global Settings uid = Nobodygid = Nobodyuse chroot = Nomax connections = 5timeout = 600pid File =/var/run/rsyncd. Pidlockfile =/var/run/rsyncd.locklog File =/var/log/rsyncd.log#module[chandao]path =/opt/backup/ignore Errors =  Yesread only = Nowrite = nohosts Allow = *hosts deny = *list = Yesuid = Rootgid = Rootauth users = dianyisecrets file =/ETC/CHANDAO.PASSWD

(3) Configuring Rsync Authentication file/ETC/CHANDAO.PASSWD

[[Email protected] ~] #echo "Dianyi:dianyi" >/etc/chandao.passwd [[email protected] ~] #cat/etc/chandao.passwddi Anyi:dianyi

(4) The permission to modify the/ETC/CHANDAO.PASSWD is 600

[[Email protected] ~] #chmod 600/etc/chandao.passwd[[email protected] ~]# ll/etc/chandao.passwd-rw-------1 root root 14 Jul 18:18/etc/chandao.passwd

(5) Configure service startup

[[email protected] ~]# chkconfig rsync on[[email protected] ~]# service xinetd start

(6) Check if port 873 is successfully monitored

[Email protected] ~]# SS-ANTLP | grep 873

(7) Check rsync running status

[Email protected] ~]# chkconfig--list

2. Zen Road Database Server (192.168.200.18)
(1) Install the Super daemon

#yum –y Install xinetd

(2) Provision of configuration files for rsync services

#vim/etc/rsyncd.conf
#Global Settingsuid = Nobodygid = Nobodyuse chroot = Nomax connections = 5timeout = 600pid File =/var/run/rsyncd.pidlockf ile =/var/run/rsyncd.locklog File =/var/log/rsyncd.log#module[db_chandao]path =/opt/backup/ignore Errors = Yesread onl y = Nowrite = nohosts Allow = *hosts deny = *list = Yesuid = Rootgid = Rootauth users = dianyisecrets file =/etc/db_ chandao.passwd

(3) Configuring Rsync Authentication file/ETC/DB_CHANDAO.PASSWD

[[Email protected] ~] #echo "Dianyi:dianyi" >/etc/db_chandao.passwd[[email protected] ~] #cat/etc/db_ Chandao.passwddianyi:dianyi

(4) The permission to modify the/ETC/DB_CHANDAO.PASSWD is 600

[[Email protected] ~] #chmod 600/etc/db_chandao.passwd[[email protected] ~]# ll/etc/db_chandao.passwd-rw-------1 root R Oot Jul 18:18/etc/db_chandao.passwd

(5) Configure service startup

[[email protected] ~]# chkconfig rsync on[[email protected] ~]# service xinetd start

(6) Check if port 873 is successfully monitored

[Email protected] ~]# SS-ANTLP | grep 873

(7) Check rsync running status

[Email protected] ~]# chkconfig--list

Iii. Deploying the Rsync client (192.168.1.186)
1. Set the password file for rsync client
(1) Password file for Zen Road

[[Email protected] ~] #echo Dianyi >/etc/chandao.passwd[[email protected] ~]# Cat/etc/chandao.passwddianyi

(2) password file of Zen Road database

[[Email protected] ~] #echo Dianyi >/etc/db_chandao.passwd[[email protected] ~]# Cat/etc/db_chandao.passwddianyi

2, the permission to change the password file is 600

[Email protected] ~]# chmod 600/etc/chandao.passwd[[email protected] ~]# chmod 600/etc/db_chandao.passwd[[email Protec Ted] ~]# ll/etc/chandao.passwd/etc/db_chandao.passwd-rw-------1 root root 7 Jul 17:17/etc/chandao.passwd-rw------- 1 root root 7 Jul 16:19/etc/db_chandao.passwd

3. Test whether the Rsync client can pull successfully from the rsync server

[Email protected] ~]# RSYNC-VZRTOPG--password-file=/etc/chandao.passwd [email protected]::chandao/*/tmp

4. Rsync Synchronization Script

#!/bin/bash#func:rsync for chandao#date:first write on 2014.7.29#version:v1.0ntpdate  192.168.200.16 > /dev/null 2>&1date= ' date +%y-%m-%d ' dest_chandao=/opt/ backup/chandao/zentaodest_db=/opt/backup/chandao/db_chandaoremote_chandao=192.168.200.16remote_db= 192.168.200.18module_chandao=chandaomodule_db=db_chandao[email protected][email protected]main () {      rsync -vzrtopg --password-file=/etc/chandao.passwd [email  Protected] $remote _chandao:: $module _chandao/* $date *  $dest _chandao     if [  $? -eq 0 ];then         echo  "chandao-* $date * was rsynced " >>  /opt/log/chandao_rsync.log 2>&1;      else         echo  "chandao-* $date *  was not rsynced " >>  /opt/log/chandao_rsync.log 2>&1;          echo  "chandao rsync was faild "  | mail -s  "chandao  Backup "  $user 2;     fi     rsync -vzrtopg -- Password-file=/etc/db_chandao.passwd [email protected] $remote _db:: $module _db/* $date *  $dest _db      if [ $? -eq 0 ];then          echo  "db_chandao_* $date * was rsynced"  >>  /opt/log /chandao_rsync.log 2>&1;     else          echo  "db_chandao_* $date * was not rsynced"  >>  /opt/ log/chandao_rsync.log 2>&1;         echo  "Db_ Chandao rsync was faild  " | mail -s " Chandao backup "  $user 2;      fi}main

Iv. Scheduled Tasks

[Email protected] ~]# crontab-e# #rsync for CHANDAO20 * * */bin/sh/opt/scripts/rs_chandao.sh

Synchronize Windows data to the Linux backup machine
The main idea is still consistent with Linux.
rsync Server needs to configure 2 aspects: (1) configuration file (2) password file
Next is the rsync client configuration: (1) password file (2) permission set to
1. Download Cwrsync Server
when installed, the user and password are set to Dianyi, which is the user name and password that two machines use when using rsync to communicate with one another .
2, configure the rsync server on this Windows, remote Linux as rsync client to pull files on the Windows Server
(1) Modify the configuration file
add modules in C:\Program Files (x86) \icw\rsyncd.conf

Use chroot = falsestrict modes = falsehosts Allow = *log file = rsyncd.log# Module definitions# Remember cygwin naming con Ventions:c:\work Becomes/cygwin/c/work#[svn]path =/cygdrive/e/repositories #e代表e盘ignore errors = yesread only = not Ransfer logging = Yeswrite = nohosts Allow = *hosts deny = *list = Yesuid = 0 #这里的udi和gid不再是root或是nobody, but should be This is 0, if you do not fill in the report: @ERROR: Invalid uid nobodygid = 0auth users = dianyisecrets file = etc/svn.passwd

(2) Create a password file
Create a password file in C:\Program files (x86) \icw\etc svn.passwd
content is Dianyi:dianyi
(3) Activate rsync service
run-services.msc-rsyncserver Startup type: Automatic
(4) See if Port 873 is listening successfully
run -to-Netstat-ano
3. Configuring Rsync Client (remote linux:192.168.1.186)
(1) Create a password Authentication file

Vim/etc/svn.passwddianyi

(2) Set permissions

chmod 600/etc/svn.passwd

(3) test

# RSYNC-VZRTOPG--password-file=/etc/svn.passwd [email protected]::svn/*/opt/111/

5. Add the command to the script



This article is from the "Nmshuishui blog" blog, make sure to keep this source http://nmshuishui.blog.51cto.com/1850554/1532927

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.