当前位置:网站首页>Centos7 rsync+crontab 定时备份
Centos7 rsync+crontab 定时备份
2020-11-10 10:41:00 【osc_8grrbqh4】
rsync 远程备份的功能
rsync常用选项:
-v: 详细信息输出
-z: 传输时进行压缩 --compress-level=NUM可按级别压缩
-a: 归档模式传输并保持文件属性相当于-rtopgDL
-r : 递归模式
-t : 保持文件的时间属性
-o: 保持文件属主属性
-p: 保持文件权限属性
-g: 保持文件属组属性
-D: 保持设备文件信息
-l : 保持文件软链接
-e: 使用指定协议
–include=PATTERN: 指定排除不需要传输的文件
–exclude-from=file: 从文件中读取需要排除的内容
-bwlimit=KBPS: 限速限制I / O带宽; 每秒KBytes
–delete: 删除源目录中不存在的文件使目标目录和源目录一致,慎用
crontab 周期计划任务
* * * * *
分 时 日 月 周
准备两台虚拟机测试
192.168.27.137 备份源
192.168.27.138 备份端
关掉防火墙 setenforce
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
备份源操作
安装rsync
[root@localhost ~]# yum -y install rsync
修改配置文件
[root@localhost ~]# vim /etc/rsyncd.conf
uid = nobody
gid = nobody
use chroot = yes
port 873
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
hosts allow = 192.168.27.0/24
[wwwroot]
path = /opt/aaa
comment = Document Root of www.51xit.top
read only =no
dont comperss = *.gz *.bz2 *.tgz *.zip *.rar *.z
auth users =tom
secrets file = /etc/rsyncd_users.db
[root@localhost ~]# mkdir /opt/aaa
设置账户 密码
[root@localhost ~]# vim /etc/rsyncd_users.db
tom:123
加权限
[root@localhost ~]# chmod 600 /etc/rsyncd_users.db
启动rsync 查看端口
root@localhost ~]# rsync --daemon
[root@localhost ~]# netstat -nlput |grep 873
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 13360/rsync
tcp6 0 0 :::873 :::* LISTEN 13360/rsync
备份端操作
安装rsync
[root@localhost ~]# yum -y install rsync
备份端只需设置用户密码
[root@localhost ~]# vim /etc/server.pass
123
加权限
[root@localhost ~]# chmod 600 /etc/server.pass
设置定时任务 每分钟执行一次
[root@localhost ~]# crontab -e
* * * * * rsync -az --password-file=/etc/server.pass tom@192.168.27.137::wwwroot /root/
[root@localhost ~]# crontab -l
* * * * * rsync -az --password-file=/etc/server.pass tom@192.168.27.137::wwwroot /root/
测试
在备份端的创建个测试
[root@localhost aaa]# cd /opt/aaa/
[root@localhost aaa]# touch a
在备份源等1分钟查看 是否同步
[root@localhost ~]# ls
a
版权声明
本文为[osc_8grrbqh4]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4311438/blog/4710549
边栏推荐
- 编码风格:Mvc模式下SSM环境,代码分层管理
- [paper reading notes] large scale heterogeneous feature embedding
- getIServiceManager() 源码分析
- [leetcode] 92 integer inversion
- CSDN bug5: to be added
- Yixian e-commerce prospectus of perfect diary parent company: focusing on marketing and ignoring R & D, with a loss of 1.1 billion in the first three quarters
- What does the mremote variable in servicemanagerproxy refer to?
- 图-无向图
- CSDN bug10: to be added
- 分布式文档存储数据库之MongoDB索引管理
猜你喜欢
JS solves the problem of automatic pagination in browser printing
Three ways to solve coursera video unable to watch
CSDN bug6: to be added
The solution of polar experience insensitive verification
Promote China manufacturing upgrade, 3D visualization of production line in automobile assembly workshop
Factory approach model
Using tail as time series to identify whales
delete、truncate、drop 有什么区别,误删数据怎么办
B. protocal has 7000eth assets in one week!
On fedlearner, the latest open source federated machine learning platform of byte
随机推荐
MultiBank Group宣布创纪录的财务业绩,2020年前三季度毛利达到9,400万美元
CUDA_ Get the specified device
Coding style: SSM environment in MVC mode, code hierarchical management
区块链论文集【三十一】
CSDN BUG1: to be added
Assign the corresponding key and value in the map to the object
[Python learning manual notes] 001. Preface to Python
从零开始学习 YoMo 系列教程:开篇
[paper reading notes] rosane, robust and scalable attributed network embedding for sparse networks
[paper reading notes] a multilayered informational random walk for attributed social network embedding
仅发送options请求,没有发送post解决方案
奸商加价销售mate40,小米可望在高端手机市场夺取更多市场
分布式文档存储数据库之MongoDB索引管理
极验无感验证破解
The length of the last word in leetcode
CSDN bug5: to be added
网络安全工程师演示:原来***是这样控制你的服务器的!(下)
Using tail as time series to identify whales
Getiservicemanager () source code analysis
CSDN bug8: to be added