centos搭建rsycnc服务端和客户端

安装

查看是否安装rsync
rpm -qa | grep rsync
在线安装rsync
yum -y install rsync
配置开机自启动
systemctl enable rsyncd.service

编辑配置文件

vim /etc/rsyncd.conf

# /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
read only = false

max connections = 100
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsync.log
exclude = lost+found/
transfer logging = yes
# timeout = 900
ignore nonreadable = yes
# dont compress   = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2

[databack]
    comment = backup data
    path = /data1 #备份文件存储的位置
    read only = false
    auth users = werben #登录用户
    secrets file = /etc/rsyncd.password #登录密码

配置密码:

echo "werben:123456" > /etc/rsyncd.password

chmod 600 /etc/rsyncd.password

systemctl restart rsyncd.service

# 关闭防火墙
systemctl disable firewalld
systemctl stop firewalld

#关闭selinux
setenforce 0
sed -i '/^SELINUX=/c SELINUX=disabled' /etc/selinux/config

将/data目录,备份到/data1目录

#将密码写到文件,执行备份的时候就不要在终端输入密码了
echo "123456" > /etc/werben.pwd
chmod 600 /etc/werben.pwd

rsync -avz --delete /data werben@127.0.0.1::databack --password-file=/etc/werben.pwd

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值