- 论坛徽章:
- 0
|
1.在主站上,假设需要同步的目录为/web。配置如下
# vi /etc/rsyncd.conf
写入
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
motd file = /var/log/rsync/welcome.msg
uid = root
gid = root
read only = yes
list = yes
use chroot = no
max connections = 50
#下面是允许连接的ip,多个ip用逗号隔开
hosts allow = 111.111.111.112,111.111.111.113
#下面是拒绝所有连接ip,这个规则这样表示是除了允许的ip外其他ip都禁止连接
hosts deny = 0.0.0.0/0
[web]
path = /web
#下面是连接名字,随便写一个
comment = saming netgame update server
ignore errors = yes
transfer logging = yes
host allow = 111.111.111.112,111.111.111.113
host deny = 0.0.0.0/0
然后
#vi /etc/rc.d/rc.local
加入
rsync --daemon
重新启动即可
2.在另一台服务器执行
#vi /etc/rc.d/autobak
写入
rsync -zvrtopg --progress --delete 111.111.111.111::web /web/
#crontab -e
写入这个
00 * * * * /etc/rc.d/autobak
记得要打开cron这个服务
然后就好了,每个小时整点会自动备份第一台服务器的/web目录到第二台服务器的/web
这个是同步的,自动会删除主服务器上已经删除的东西。 |
|