目录
一、rsync部署
-
服务器:source 192.168.58.130 (进行数据备份的主机)
-
客户端:targetpc 192.168.58.131 (备份存储的主机)
push推数据
1、编写rsync配置文件
#192.168.58.131 # 在客户端上编写rsync配置文件,创建一个存放备份的同步目录 [root@targetpc ~]# vim /etc/rsyncd.conf # /etc/rsyncd: configuration file for rsync daemon mode # See rsyncd.conf man page for more options. # configuration example: # uid = nobody # gid = nobody # use chroot = yes # max connections = 4 # pid file = /var/run/rsyncd.pid # exclude = lost+found/ # transfer logging = yes # timeout = 900 # ignore nonreadable = yes # dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2 # [ftp] # path = /home/ftp # comment = ftp export area #在这些内容后面加上下面的内容
#加上 port=873 address = 192.168.58.131 uid = root gid = root use chroot = yes max connections = 4 pid file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock log file = /var/log/rsyncd.log motd file = /etc/rsyncd.motd hosts allow = 192.168.58.0/24 [data] path = /data/backup comment = bakcup data read only = false list = yes auth users = rsyncuser secrets file = /etc/rsync.passwd
#192.168.58.131 # 创建密码文件,格式 用户名:密码 # 设置密码文件权限为600或者700 [root@targetpc ~]# touch /etc/rsync.passwd [root@targetpc ~]# vim /etc/rsync.passwd rsyncuser:123456 [root@targetpc ~]# chmod 600 /etc/rsync.passwd
#192.168.58.131 # 创建欢迎信息文件 [root@targetpc ~]# echo "Welcome to Backup Server" > /etc/rsyncd.motd [root@targetpc ~]# systemctl start rsyncd [root@targetpc ~]# mkdir -p /data/backup [root@targetpc ~]# cd /data/backup
2、备份测试
#192.168.58.130 [root@source ~]# mkdir /data [root@source ~]# cd /data [root@source data]# touch 1.txt [root@source data]# mkdir aaa [root@source data]# rsync -avz /data/* rsyncuser@192.168.58.131::data Welcome to Backup Server Password: sending incremental file list 1.txt aaa/ sent 124 bytes received 43 bytes 9.03 bytes/sec total size is 0 speedup is 0.00 [root@source data]# touch 2.txt [root@source data]# ls 1.txt 2.txt aaa [root@source data]# rsync -avz /data/* rsyncuser@192.168.58.131::data Welcome to Backup Server Password: sending incremental file list 2.txt sent 137 bytes received 36 bytes 9.89 bytes/sec total size is 0 speedup is 0.00
3、检验结果
#192.168.58.131 [root@targetpc backup]# ls 1.txt 2.txt aaa [root@targetpc backup]# touch 3.txt [root@targetpc backup]# ls 1.txt 2.txt 3.txt aaa
#192.168.58.130 [root@source data]# rsync -avz --delete /data/ rsyncuser@192.168.58.131::data Welcome to Backup Server Password: sending increm
rsync部署及数据同步脚本编写

最低0.47元/天 解锁文章
2002

被折叠的 条评论
为什么被折叠?



