rsync推送备份服务器(Linux)

rsync推送备份服务器备份服务器操作需被备份的服务器操作批处理shell
备份服务器操作
#编辑配置文件
vi /etc/rsyncd.conf
uid = root #运行RSYNC守护进程的用户
gid = root #运行RSYNC守护进程的组
use chroot = no #不使用chroot
max connections = 200 # 最大连接数为200
timeout = 300
port = 873 #默认端口873
[backup] #这里是认证的模块名,在被备份服务器端需要指定
path = /home/backup/ #需要做备份的目录,不可缺少!
ignore errors #可以忽略一些无关的IO错误
read only = no# 只读
list = false #不允许列文件
auth users = abc #认证的用户名,如果没有这行则表明是匿名,此用户与系统无关
secrets file = /etc/rsync.pas #密码和用户名对比表,密码文件自己生成
hosts allow = 10.96.9.0/24,10.96.10.113#允许主机
hosts deny = 0.0.0.0/0 #禁止主机
#transfer logging = yes
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
12345678910111213141516171819202122
#添加访问用户密码文件
vi /etc/rsync.pas
abc:abc123
#用户:密码(用户对应rsyncd.conf)
chmod 600 /etc/rsync.pas
12345
#添加开机启动rsync进程
vi /etc/rc.local
/usr/bin/rsync --daemon
123
需被备份的服务器操作
vi /etc/rsync.pas
abc123
#密码(只添加密码)
chmod 600 /etc/rsync.pas
rsync -avz /backup(本地目录) (用户名)@IP::backup/(模块名) --password-file=/etc/rsync.pas(密码表路径)
123456
批处理shell
备份服务器操作(存储目录为/home/backup)
cp /etc/rsyncd.conf /etc/rsyncd.conf.bak
cat > /etc/rsyncd.conf << EOF
uid = root
gid = root
use chroot = no
max connections = 200
timeout = 300
port = 873
[backup]
path = /home/backup/
ignore errors
read only = no
list = false
auth users = abc
secrets file = /etc/rsync.pas
hosts allow = 0.0.0.0/0
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
EOF
echo abc:abc123 > /etc/rsync.pas
chmod 600 /etc/rsync.pas
/usr/bin/rsync --daemon
echo /usr/bin/rsync --daemon >> /etc/rc.local
1234567891011121314151617181920212223242526
需被备份的服务器操作
echo abc123 > /etc/rsync.pas
chmod 600 /etc/rsync.pas
12
需被备份的服务器操作(备份目录为/backup,改IP为备份服务器IP)
rsync -avz /backup abc@IP::backup/ --password-file=/etc/rsync.pas
---------------------
上一篇:在xml中调用自己用java代码定义的View


下一篇:caffe神经网络框架的辅助工具(将图片转换为leveldb格式)