rsync服务器搭建,实现自动化备份

来源:互联网 发布:php trim 编辑:程序博客网 时间:2024/06/08 05:30

案例:

某电子商务企业有一个门户网站,Web服务器的操作系统是Linux,网站数据每天都会增加。为保证数据安全,需要建立一个远程容灾系统,将网站数据在每天凌晨330分备份到远程的容灾服务器上。由于数据量很大,每天只能进行增量备份,即仅仅备份当天增加的数据,当网站出现故障后,可以通过备份最大程度地恢复数据

rsync服务端配置:/etc/rsyncd.conf(需手动创建):

#全局配置

uid =nobody

gid =nobodyuse

chroot =no

maxconnections = 10

strictmodes = yes

pid file= /var/run/rsyncd.pid

lockfile = /var/run/rsyncd.lock

log file= /var/log/rsyncd.log

 

#模块配置

[webdata]

path =/webdata

comment = webdata file

ignoreerrors

readonly = no

writeonly = no

hostsallow = *

hostsdeny = 192.168.12.131

list =false

uid =root

gid =root

auth users = test

 

secretsfile = /etc/server.pass


/etc/server.pass文件内容为认证帐号密码信息

vim /etc/server.pass

test:testpass

启动守护进程:

rsync --daemon

 

 

ss -antp | grep rsync


rsync客户端:

 

 /usr/local/bin/rsync-vzrtopg  --delete  --progress--exclude        "*access*"  test@10.1.1.161::test/test --password-file=/etc/test.pass

/etc/test.pass内容为test用户密码

 

testpass