Windows Linux 之间rsync同步CODE文件
发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,Windows Linux 之间rsync同步CODE文件一.环境Windows:OS:Microsoft Windows Web Server 2008 SP1IP:192.168.88.197Li
千家信息网最后更新 2025年12月02日Windows Linux 之间rsync同步CODE文件Windows Linux 之间rsync同步CODE文件
一.环境
Windows:
OS:Microsoft Windows Web Server 2008 SP1
IP:192.168.88.197
Linux:
OS:CentOS release 6.4 (Final)
IP:192.168.88.238
二. Windows 下安装服务端软件并配置
1.cwRsyncServer(安装过程略),注意安装过程会创建一个启动服务的用户
启动cwsync
services.msc-找到RsyncServer 将启动类型改成自动,然后启动一下服务
2.配置cwrsync
创建同步目录
这里我新建的目录为: E:\sync
为新建目录赋权
右击目录sync选择安全点击编辑将SvcCWRSYNC添加进去并赋给所有权限
配置rsyncd.conf文件,目录路径如下
C:\Program Files (x86)\ICW
修改为如下配置
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同步,多个IP用逗号分隔,允许所有直接是*
auth users = qssync #同步验证用户名
secrets file = etc/rsyncd.secrets #指定密码文件路径
UID = 0
GID = 0
创建密码文件
注意密码文件路径要和rsyncd.conf路径一致
etc/rsyncd.secrets(这个路径是相对路径)
真实物理路径为C:\Program Files (x86)\ICW\etc
编辑文件rsyncd.secrets格式如下
sync:Abc23332c2014
windows 下备份CODE
BAT脚本如下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%%date:~8,2%%time:~,2%%time:~3,2%%time:~7,1%.log
三.linux 端配置(这里Linux作为客户端)
1.安装Linux客户端(建议将selinux关闭)并配置
yum install rsync xinetd
配置
[root@zjqs-05 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
}
将disable 由yes 改成no
创建密码文件
vim /etc/passwd.txt 内容如下
[root@zjqs-05 scripts]# cat /etc/passwd.txt
Abc23332c2014
这里的密码跟server端一致
创建同步脚本
[root@zjqs-05 scripts]# cat /export/scripts/rsync197.sh
#!/bin/sh
rsync -vzrtopg --port=873 --progress --delete --exclude-from '/export/scripts/exclude.txt' sync@192.168.88.197::197bak /data/197bak --password-file=/etc/passwd.txt
#exclude-from 防止有些需要长期保留的。不需要同步的
exclude.txt内容如下
[root@zjqs-05 scripts]# cat /export/scripts/exclude.txt
bianfeng20140911.bak
bianfeng
建立任务计划
02 02 * * * /export/scripts/rsync197.sh >/export/scripts/rsync`date +%F`.log 2>&1
一.环境
Windows:
OS:Microsoft Windows Web Server 2008 SP1
IP:192.168.88.197
Linux:
OS:CentOS release 6.4 (Final)
IP:192.168.88.238
二. Windows 下安装服务端软件并配置
1.cwRsyncServer(安装过程略),注意安装过程会创建一个启动服务的用户
启动cwsync
services.msc-找到RsyncServer 将启动类型改成自动,然后启动一下服务
2.配置cwrsync
创建同步目录
这里我新建的目录为: E:\sync
为新建目录赋权
右击目录sync选择安全点击编辑将SvcCWRSYNC添加进去并赋给所有权限
配置rsyncd.conf文件,目录路径如下
C:\Program Files (x86)\ICW
修改为如下配置
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同步,多个IP用逗号分隔,允许所有直接是*
auth users = qssync #同步验证用户名
secrets file = etc/rsyncd.secrets #指定密码文件路径
UID = 0
GID = 0
创建密码文件
注意密码文件路径要和rsyncd.conf路径一致
etc/rsyncd.secrets(这个路径是相对路径)
真实物理路径为C:\Program Files (x86)\ICW\etc
编辑文件rsyncd.secrets格式如下
sync:Abc23332c2014
windows 下备份CODE
BAT脚本如下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%%date:~8,2%%time:~,2%%time:~3,2%%time:~7,1%.log
三.linux 端配置(这里Linux作为客户端)
1.安装Linux客户端(建议将selinux关闭)并配置
yum install rsync xinetd
配置
[root@zjqs-05 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
}
将disable 由yes 改成no
创建密码文件
vim /etc/passwd.txt 内容如下
[root@zjqs-05 scripts]# cat /etc/passwd.txt
Abc23332c2014
这里的密码跟server端一致
创建同步脚本
[root@zjqs-05 scripts]# cat /export/scripts/rsync197.sh
#!/bin/sh
rsync -vzrtopg --port=873 --progress --delete --exclude-from '/export/scripts/exclude.txt' sync@192.168.88.197::197bak /data/197bak --password-file=/etc/passwd.txt
#exclude-from 防止有些需要长期保留的。不需要同步的
exclude.txt内容如下
[root@zjqs-05 scripts]# cat /export/scripts/exclude.txt
bianfeng20140911.bak
bianfeng
建立任务计划
02 02 * * * /export/scripts/rsync197.sh >/export/scripts/rsync`date +%F`.log 2>&1
路径
文件
配置
同步
密码
目录
服务
一致
内容
客户
客户端
用户
脚本
过程
之间
安全
任务
会创
备份
多个
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
软件开发营销策划书前言
自学软件开发容易学会吗
大型网站需要什么服务器配置
常州品牌网络技术咨询热线
服务器回收天津虚拟主机
创造与魔法服务器拥挤是人多嘛
软件开发质监部门好吗
灵武app软件开发
凡科互联网科技股份有限公司叶枫
体育馆服务器
数字贸易的网络安全
坎宫骑剑服务器互通吗
网络技术公司最新招聘
mq 服务器
5g软件开发专业发展前景
软件开发行业投资测算
安徽戴尔服务器虚拟化优化云主机
软件开发关闭软件要输入密码
苹果13备份无法连接服务器
必火网络安全学院地址
厦门点餐系统软件开发
数据库安全性控制的提问
网络安全要学网络协议吗
access数据库 论坛
记录为管理服务器
怎么给服务器加远程许可
网络安全热线电话是多少
网络安全的程度
wow进游戏如何看自己的服务器
数据库管理员工资标准