Rsync synchronizes code files between Windows Linux

Source: Internet
Author: User
Tags windows web server rsync

Rsync synchronizes code files between Windows Linux

I. Environment
Windows:
Os:microsoft Windows Web Server SP1
ip:192.168.88.197

Linux:
Os:centos Release 6.4 (Final)
ip:192.168.88.238

Two. Install server-side software and configure it under Windows
1.cwRsyncServer (Installation process slightly), note that the installation process creates a user who starts the service
Start Cwsync
services.msc-Find Rsyncserver Change the startup type to automatic and start the service
2. Configure Cwrsync
Create a synchronization directory
Here my new directory is: E:\sync

Assigning rights to new directories
Right-click Directory Sync Select Secure Click Edit to add Svccwrsync and assign to all permissions

Configure the rsyncd.conf file with the following directory path
C:\Program Files (x86) \ICW

Modify to the following configuration
Use Chroot = False
Strict modes = False
Hosts allow = *
Log file = Rsyncd.log

# Module Definitions
# Remember Cygwin naming conventions:c:\work becomes/cygwin/c/work
#
[197bak]
Path =/cygdrive/e/sync #路径需要转换为这里真实路径为E: \sync
Read Only = True
List = no
Hosts allow=192.168.88.238 #允许那些IP同步, multiple IPs are separated by commas, allowing all directly to be *
Auth users = Qssync #同步验证用户名
Secrets file = Etc/rsyncd.secrets #指定密码文件路径
UID = 0
GID = 0

Create a password file
Note that the password file path is identical to the rsyncd.conf path
Etc/rsyncd.secrets (this path is a relative path)
The real physical path is C:\Program Files (x86) \icw\etc
Edit file Rsyncd.secrets format as follows
sync:abc23332c2014

Under Windows Backup code
The bat script is as follows Backup.bat
@echo off
Set P=c:\program Files\winrar
"%p%\rar" a E:\sync\code%date:~,4%%date:~5,2%%date:~8,2%%time:~,2%%time:~3,2%%time:~7,1%.rar D:\app\code >> Rar%date:~,4%%date:~5,2%%date:~8,2%%time:~,2%%time:~3,2%%time:~7,1%.log
forfiles/p "E:\sync"/d-7/C "cmd/c echo deleting @file ... && del/f @path" >>rar%date:~,4%%date:~5,2%%d Ate:~8,2%%time:~,2%%time:~3,2%%time:~7,1%.log

Three. Linux-side configuration (here Linux as client)
1. Install the Linux client (it is recommended to turn SELinux off) and configure
Yum Install rsync xinetd

Configuration
[Email protected] scripts]# Vim/etc/xinetd.d/rsync

# Default:off
# description:the Rsync server is a good addition to an FTP server, as it \
# allows CRC Checksumming etc.
Service rsync
{
Disable = no
Flags = IPV6
Socket_type = Stream
wait = no
user = root
Server =/usr/bin/rsync
Server_args =--daemon
Log_on_failure + = USERID
}
Change disable from Yes to No

Create a password file
Vim/etc/passwd.txt content is as follows
[Email protected] scripts]# Cat/etc/passwd.txt
abc23332c2014
The password here is consistent with the server side.

Create a synchronization script
[Email protected] scripts]# cat/export/scripts/rsync197.sh
#!/bin/sh
RSYNC-VZRTOPG--port=873--progress--delete--exclude-from '/export/scripts/exclude.txt ' [email protected]::197bak/ Data/197bak--password-file=/etc/passwd.txt
#exclude-from prevent some need for long-term retention. Do not need to synchronize the

Exclude.txt content is as follows
[Email protected] scripts]# Cat/export/scripts/exclude.txt
Bianfeng20140911.bak
Bianfeng


Set up a task plan
* * * */export/scripts/rsync197.sh >/export/scripts/rsync ' date +%f '. Log 2>&1

Rsync synchronizes code files between Windows Linux

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.