记 rsync 同步增量备份的一个案例

发布于 2019-08-06  389 次阅读


源服务器(172.18.10.2)
备份服务器(172.18.10.3)
系统 : Centos 7.6

说明:
源服务器的 /data/confluence 、/data/dbbackup 目录
rsync 到
备份服务器/data/backup/172.18.10.2/confluence、/data/backup/172.18.10.2/dbbackup

源服务器
安装rsync
yum install -y rsync
systemctl start rsyncd
systemctl enabel rsyncd

echo "backup:123456" >> /etc/rsyncd.pass
chmod 600 /etc/rsyncd.pass

编辑配置文件
vi rsyncd.conf
uid = root
gid = root
use chroot = no
max connections = 10
pid file = /var/run/rsyncd.pid
log file = /var/log/rsync.log
transfer logging = yes
timeout = 900
ignore nonreadable = yes
dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2

[backup-confluence]
path = /data/confluence
comment = backup
read only = yes
write only = no
list = yes
strict modes = no
ignore errors
auth users = backup
secrets file = /etc/rsyncd.pass
[backup-mysql]
path = /data/dbbackup
comment = backup-mysql
read only = yes
write only = no
list = yes
strict modes = no
ignore errors
auth users = backup
secrets file = /etc/rsyncd.pass

设置防火墙
firewall-cmd --zone=public --add-port=873/udp --permanent
firewall-cmd --zone=public --add-port=873/tcp --permanent
firewall-cmd --reload

备份服务器
安装rsync
yum install -y rsync
systemctl start rsyncd
systemctl enabel rsyncd

生成密码文件.pass
echo "123456" >> /etc/rsyncd.pass
chmod 600 /etc/rsyncd.pass

生成目录
mkdir -p /data/backup/172.18.10.2/{confluence,dbbackup}

设置防火墙
firewall-cmd --zone=public --add-port=873/udp --permanent
firewall-cmd --zone=public --add-port=873/tcp --permanent
firewall-cmd --reload

执行
rsync -vzrtopg --delete --progress --password-file=/etc/rsyncd.pass backup@172.18.10.2::backup-mysql /data/backup/172.18.10.2/dbbackup
rsync -vzrtopg --delete --progress --password-file=/etc/rsyncd.pass backup@172.18.10.2::backup-confluence /data/backup/172.18.10.2/confluence


一沙一世界,一花一天堂。君掌盛无边,刹那成永恒。