当前位置:网站首页>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
边栏推荐
- Bartender2021 realizes secure remote label printing, new year-end release
- js解决浏览器打印自动分页的问题
- Mongodb index management of distributed document storage database
- Bartender2021实现安全远程标签打印,年终全新发布
- 分布式文档存储数据库之MongoDB索引管理
- 图-无向图
- 高通骁龙875夺安卓处理器桂冠,但外挂5G基带成为它的弊病
- C++ STL容器篇
- Three ways to solve coursera video unable to watch
- CSDN BUG1: to be added
猜你喜欢
csdn bug11:待加
Explanation of Z-index attribute
Mongodb index management of distributed document storage database
Ineuos industrial interconnection platform, web configuration (ineuview) increases the function of importing and exporting engineering views, as well as optimization and repair. Release: v3.2.1
浅谈字节最新开源联邦机器学习平台Fedlearner
Oschina: my green plants are potatoes, ginger and garlic
csdn bug7:待加
Collection of blockchain theory [31]
CSDN bug3: to be added
OSChina 周二乱弹 —— 我养的绿植分别为土豆,生姜,蒜
随机推荐
假如需要一百万个对象
[论文阅读笔记] Network Embedding with Attribute Refinement
Getiservicemanager () source code analysis
Using tail as time series to identify whales
ServiceManagerProxy中mRemote变量指的什么?
编码风格:Mvc模式下SSM环境,代码分层管理
Promote China manufacturing upgrade, 3D visualization of production line in automobile assembly workshop
奸商加价销售mate40,小米可望在高端手机市场夺取更多市场
消防知识线上答题活动小程序复盘
从大专生到蚂蚁金服CTO,他写下“支付宝”第一行代码:逆风的方向,更适合飞翔!...
商品管统——采购需求合并到采购单
Experiment 2
坚持追查7年,近10亿美元比特币终被美国政府没收充公
上线1周,B.Protocal已有7000ETH资产!
利用尾巴作为时间序列进行处理来识别鲸鱼
csdn bug5:待加
Commodity management - merge purchase demand into purchase order
Collection of blockchain theory [31]
[论文阅读笔记] RoSANE, Robust and scalable attributed network embedding for sparse networks
Fire knowledge online answer activity small program