Server installation package:
rsync(centos7 )
rsync,rsync-daemon(centos8)
Client:
simply install rsync can (in terms of centos8)
Server-side configuration
1. Profiles
vim /etc/rsyncd.conf
uid = root
gid = root
use chroot = no
#最大的链接数,0表示不去控制他
max connections = 0
ignore errors
#备份时排除哪个文件夹
exclude = lost+found/
#日志
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
#是否做反向dns解析
reverse lookup = no
#允许哪个ip访问
hosts allow = 192.168.8.0/24
#可以多账号添加不同的文件夹[文件夹名]
[backup]
#存放路径
path = /backup/
comment = backup
read only = no
#同步时用的虚拟账户
auth users = rsyncuser
#密码存放位置
secrets file = /etc/rsync.p
2. The server side is ready directory
mkdir / backup
3. Verify that the file generating
echo "rsyncuser: 123"> /etc/rsync.pass
the chmod 600 /etc/rsync.pass
4.systemctl enable --now rsyncd
Client Configuration
1. Create verification file
echo "123"> /etc/rsync.pass
chmod 600 /etc/rsync.pass
2. Client Test
rsync -avz --delete --password-file = / etc / rsync.pass / data rsyncuser @ ip :: backup
Above to achieve a full backup, in order to achieve automatic backup, will write a regular job or write a script with inotify.
Timing task:
the crontab -e
# 30 a synchronization minutes
* / 30 * * * * / usr / bin / rsync -avz --delete --password-file = / etc / rsync.pass / data rsyncuser @ ip :: backup server