一、数据库备份
https://blog.csdn.net/vfsdfdsf/article/details/89331943
二、文件备份
2.1 安装cwRsyncServer_4.1.0_Installer.exe
正常安装,右键管理员权限安装,记住账户密码,安装结束后,会出现服务
然后配置文件
(注意:配置了端口是123,那么,入站和出站规则允许123端口)
uid = 0
gid = 0
port = 123
use chroot = false
strict modes = false
max connections = 3
pid file = /cygdrive/d/cygdrive-info/rsyncd.pid
lock file = /cygdrive/d/cygdrive-info/rsync.lock
log file = /cygdrive/d/cygdrive-info/log/rsyncd.log
hosts allow=111.222.333.444
auth users = usrename
secrets file = /cygdrive/d/cygdrive-info/rsync.passwd
[a]
path = /cygdrive/d/a
read only = false
transfer logging = yes
[b]
path = /cygdrive/d/b
read only = false
transfer logging = yes
rsync.passwd的内容为:username:1234
再对D盘的a,b文件夹添加用户管理权限SvcCWRSYNC
2.2 客户端安装cwRsync_4.1.0_Installer.exe
正常安装软件,然后在指定位置创建一个rsync.passwd文件,内容为:1234
在bin文件夹中创建test.bat脚本,运行脚本就OK,能够同步文件到指定的文件夹中
脚本代码
@echo off
echo.
echo start...
echo.
cd D:\cwRsync\bin
rsync -vzrtopg --port=123 --progress --delete usrename@666.666.666.666::a /cygdrive/d/aa --password-file=/cygdrive/d/rsync.passwd < D:\rsync.passwd
rsync -vzrtopg --port=123 --progress --delete usrename@666.666.666.666::b /cygdrive/d/bb --password-file=/cygdrive/d/rsync.passwd < D:\rsync.passwd
则可以同步这两个文件夹,注意,一定要在备份服务器中的d盘添加aa,bb文件夹
2.3 参数说明
https://www.cr173.com/html/119298_1.html
2.4 添加定时任务
每个小时同步一次,另外bat脚本可以再优化下,根据时间创建文件夹,这样,一个月的最开始就全量同步,这一个月内,增量同步
如果遇到定时任务无法从执行,需要修改下安全策略:
安全设置 — 本地策略 — 安全选项,找到 域控制器:允许服务器操作员计划任务,打开启用,然后电脑重启即可。
@echo off
echo.
echo start...
echo.
cd D:\cwRsync\bin
set year=%date:~0,4%
set month=%date:~5,2%
set day=%date:~8,2%
set Ym=%date:~,4%%date:~5,2%
set Ymd=%date:~,4%%date:~5,2%%date:~8,2%
rsync -vzrtopg --port=123 --progress --delete usrename@666.666.666.666::a /cygdrive/d/aa/%Ym% --password-file=/cygdrive/d/rsync.passwd < D:\rsync.passwd
三、遇到的问题
3.1 不能正常创建账户
(有安全软件的情况下)
先卸载,再关掉安全软件,右键管理员权限安装,修改密码,安装,会发现创建了一个账户,和administrator账户同级的账户,服务里面也会发现有个RsyncServer
如果没有发现服务,先看看自己能否手动创建一个用户,记录账户密码,重新安装软件的时候,使用这个账户密码
如果自己都不能创建用户,则需要去注册表中修改权限,让自己能够创建用户
3.2 一直提示 chroot failed
改动权限没有,最后发现,这个配置文件把注释也给作为了文件名,我当时都惊呆了
这么写,一直报错chroot failed
uid = 0
gid = 0
port = 123
use chroot = false
strict modes = false
max connections = 3
pid file = /cygdrive/d/cygdrive-info/rsyncd.pid
lock file = /cygdrive/d/cygdrive-info/rsync.lock
log file = /cygdrive/d/cygdrive-info/log/rsyncd.log
hosts allow=111.222.333.444
[a]
path = /cygdrive/d/a #我是个坑人的小注释
read only = false
transfer logging = yes
[b]
path = /cygdrive/d/b
read only = false
transfer logging = yes
把注释去掉,这么写,没问题了
uid = 0
gid = 0
port = 123
use chroot = false
strict modes = false
max connections = 3
pid file = /cygdrive/d/cygdrive-info/rsyncd.pid
lock file = /cygdrive/d/cygdrive-info/rsync.lock
log file = /cygdrive/d/cygdrive-info/log/rsyncd.log
hosts allow=111.222.333.444
[a]
path = /cygdrive/d/a
read only = false
transfer logging = yes
[b]
path = /cygdrive/d/b
read only = false
transfer logging = yes