当前位置:网站首页>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
边栏推荐
- 使用call、apply和bind解决js中烦人的this,事件绑定时的this和传参问题
- 实验2
- [论文阅读笔记] Network Embedding with Attribute Refinement
- CCR炒币机器人:新冠肺炎加速了监管机构对CBDC的兴趣
- [Python learning manual notes] 001. Preface to Python
- Leetcode 1-sum of two numbers
- GNU assembly language uses inline assembly to extend ASM
- The length of the last word in leetcode
- Detach ()
- 竞争性编程的思考:那些神话和令人震惊的事实[图]
猜你喜欢

B. protocal has 7000eth assets in one week!

【技术教程】Visual Studio 2017自建WebRTC中peerconnection_client程序报LNK2019 无法解析的外部符号错误

jt-day10

js解决浏览器打印自动分页的问题
![[论文阅读笔记] Large-Scale Heterogeneous Feature Embedding](/img/00/df94bfe594e17ab120c30fd6b31931.jpg)
[论文阅读笔记] Large-Scale Heterogeneous Feature Embedding

CSDN bug8: to be added
![[论文阅读笔记] Network Embedding with Attribute Refinement](/img/71/760f29f8a13b366cf3bad4fb48bd63.jpg)
[论文阅读笔记] Network Embedding with Attribute Refinement

CSDN BUG1: to be added

Assign the corresponding key and value in the map to the object
![Collection of blockchain theory [31]](/img/3b/00bc81122d330c9d59909994e61027.jpg)
Collection of blockchain theory [31]
随机推荐
对于程序员,那些既陌生又熟悉的计算机硬件
完美日记母公司逸仙电商招股书:重营销、轻研发,前三季度亏11亿
编码风格:Mvc模式下SSM环境,代码分层管理
Taulia推出国际支付条款数据库
Bifrost 位点管理 之 异构中间件实现难点(1)
Self writing performance testing tool (2)
Mongodb index management of distributed document storage database
What's the difference between delete, truncate, and drop, and what to do if you delete data by mistake
C + + STL container
Experiment 2
CSDN bug3: to be added
Difficulties in heterogeneous middleware implementation of Bifrost site management (1)
CSDN bug9: to be added
CCR coin robot: novel coronavirus pneumonia has accelerated the interest of regulators in CBDC.
CSDN bug8: to be added
Mongodb index management of distributed document storage database
[python学习手册-笔记]001.python前言
ASP.NET Core framework revealed [blog Summary - continuous update]
中央重点布局:未来 5 年,科技自立自强为先,这些行业被点名
Filezilla server配置FTP服务器中的各种问题与解决方法