CentOS 使用rsync进行远程备份

服务器和客户机都需要安装启用rsync服务

安装rsync软件

  #yum install rsync

服务器端设置

  设置/etc/rsyncd.conf

#global settings

pid file = /var/run/rsyncd.pid
port = 873
lock file = /var/run/rsyncd.lock
log file = /var/log/rsync.log
gid = root
uid = root

[auth_data]
path = /tmp/rb
use chroot = no
max connections = 15
read only = no
write only = no
list = no
ignore errors = yes
timeout = 120
auth users = test
secrets file = /etc/rsyncd.passwd

  设置客户端连接要使用的账号/etc/rsyncd.passwd

  echo "test:test" > /etc/rsyncd.passwd  ##设置账户-密码

  chmod 600 /etc/rsyncd.passwd

  mkdir -p /tmp/rb

  启动服务:  #rsync --daemon

  查看是否已启动:#netstat -tlnp | grep 873

客户机端设置

  设置连接服务器rsync需要用到的密码:/home/user/rsyncd.passwd  只需要输入密码

  echo "test" > /home/hadoop/rsyncd . passwd
  chmod 600 /home/user/rsyncd . passwd

  连接测试(不用输入密码的方式,脚本可以用):

  rsync -avz --progress --password-file=/home/user/rsyncd.passwd [email protected]::auth_data /home/user/auth_data  ##下载到客户端

  rsync -avz --progress --password-file=/home/hadoop/rsyncd.passwd /home/hadoop/auth_data [email protected]::auth_data  ##上传到服务端

猜你喜欢

转载自www.cnblogs.com/lysn/p/11239522.html