服务器在线 - IDC服务商 - 服务器软件 - 网站地图 服务器在线,专注于服务器技术!

当前位置:主页 > 服务器系统 > Linux > 正文

Centos7使用rsync同步数据操作方法

时间:2019-11-05    来源:未知    投稿:admin    点击:

文章来源:超级云

服务端:

安装服务:

yum install xinetd rsync -y

vi /etc/rsyncd.conf                                # 编辑rsync配置文件:


 


# /etc/rsyncd: configuration file for rsync daemon mode
 
# See rsyncd.conf man page for more options.
 
# configuration example:
 
uid = root
gid = root
use chroot = no
max connections = 4
lock file=/var/run/rsyncd.lock
log file = /var/log/rsyncd.log
# 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
 
 
[host]
path=/www/backup
comment=host
 
ignore errors
read only=yes
write only=no
list=no
auth user=host
secrets file=/etc/rsyncd.passwd
hosts allow=222.187.56.246




创建密码文件:

vi /etc/rsync.passwd

host:passwdopendoor 

chmod 600 /etc/rsync.passwd
 

重启rsync,并开机启动。

systemctl restart rsyncd.service
systemctl enable rsyncd.service


防火墙开放873端口

 

 

客户端:

echo "password123" > /data/backup/rsyncpwd/004.passwd

chmod 600  /data/backup/rsyncpwd/004.passwd

添加计划任务:
crontab -e
10 3 * * 2 rsync -avz host@110.110.110.110::host --bwlimit=300 --password-file=/data/backup/rsyncpwd/003.pwd /data/beifen/kongjian/110.110.110.110/`date +"%Y%m%d"`

 

--bwlimit=300    #每秒传输k。

`date +"%Y%m%d"`  #以日期为文件夹

 

如果您的问题仍未解决,还可以加入服务器在线技术交流QQ群:8017413寻求帮助。