当前位置:网站首页>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
边栏推荐
- CSDN bug5: to be added
- Bifrost 位点管理 之 异构中间件实现难点(1)
- 【技术教程】Visual Studio 2017自建WebRTC中peerconnection_client程序报LNK2019 无法解析的外部符号错误
- csdn bug5:待加
- [论文阅读笔记] RoSANE, Robust and scalable attributed network embedding for sparse networks
- 消防知识线上答题活动小程序复盘
- 【技术教程】C#控制台调用FFMPEG推MP4视频文件至流媒体开源服务平台EasyDarwin过程
- 关于centos启动报错:Failed to start Crash recovery kernel arming的解决方案
- The length of the last word in leetcode
- What does the mremote variable in servicemanagerproxy refer to?
猜你喜欢
随机推荐
Coding style: SSM environment in MVC mode, code hierarchical management
大专学历的我工作六年了,还有机会进大厂吗?
Raspberry pie drum set WiFi
Using tail as time series to identify whales
CSDN bug6: to be added
lodash.js Source code flatten
delete、truncate、drop 有什么区别,误删数据怎么办
[leetcode] 92 integer inversion
Simple use of JMeter
CSDN bug11: to be added
csdn bug1:待加
[论文阅读笔记] Large-Scale Heterogeneous Feature Embedding
[elixir! 0073] beam built-in memory database ETS
使用call、apply和bind解决js中烦人的this,事件绑定时的this和传参问题
Key layout of the Central Government: in the next five years, self-reliance and self-improvement of science and technology will be the priority, and these industries will be named
[paper reading notes] rosane, robust and scalable attributed network embedding for sparse networks
CSDN bug5: to be added
小度“破圈”提速,IoT迎来新故事
The solution of polar experience insensitive verification
CUDA_ Host memory