标签:linux rsync
架构的拓朴图如下:
部署实施:
Rsync服务端(备份服务器):
[root@localhost ~]# uname -r
3.10.0-327.el7.x86_64
#是否安装Rsync服务
[root@localhost ~]# rpm -qa | grep rsync
rsync-3.0.9-17.el7.x86_64
#建立用于备份的账户
[root@localhost ~]# useradd backup
[root@localhost ~]# passwd backup
#建立配置文件
[root@rabbitmq-server ~]# vim /etc/rsyncd.conf
uid = root
gid = root
use chroot = yes
address = 127.76.88.55
port = 873
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
[backup114]
path = /backup/61.177.274.152
read only = false
auth users = backup
secrets file = /etc/rsyuser.db
[backup2]
path = /backup/192.168.10.2
read only = false
auth users = backup
secrets file = /etc/rsyuser.db
[backup143]
path = /backup/183.3.277.122
read only = false
auth users = backup
secrets file = /etc/rsyuser.db
[backup107]
path = /backup/61.111.244.117
read only = false
auth users = backup
secrets file = /etc/rsyuser.db
#建立授权备份的账户文件
[root@rabbitmq-server ~]# vim /etc/rsyuser.db
backup:backup
[root@rabbitmq-server ~]#chmod 600 /etc/rsyuser.db
#建立备份目录
[root@rabbitmq-server backup]# mkdir /backup
[root@rabbitmq-server backup]#chown -R backup.backup backup
[root@rabbitmq-server backup]#mkdir -pv {61.177.274.152,192.168.10.2,183.3.277.122,61.111.244.117}
#启动服务
[root@rabbitmq-server ~]# rsync --daemon
Rsync客户端(客户端操作基本一致,只是备份目录需要根据实际情况决定):
#建立密码文件:
[root@localhost ~]# cat > /etc/rsync.pass
backup
[root@localhost ~]#chmod 600 /etc/rsync.pass
#建立备份脚本,并且保留20天的备份数据:
#!/bin/bash
cd /root
tar -zcf phpstudy$(date +%F).tar.gz /phpstudy
rsync -arz --password-file=/etc/rsync.pass /root/phpstudy$(date +%F).tar.gz backup@127.76.88.55::backup114/
find /root -mtime +20 -name "*.tar.gz" -exec rm -fr {} \;
本文出自 “一万年太久,只争朝夕” 博客,请务必保留此出处http://zengwj1949.blog.51cto.com/10747365/1947536
标签:linux rsync
原文地址:http://zengwj1949.blog.51cto.com/10747365/1947536