[CentOS] rsync同步目录进行备份文件
操作不难,网上一堆。这里列几个
CentOS7
参考地址: https://www.server-world.info/en/note?os=CentOS_7&p=rsync
Copy files or directories from one location to an another host by rsync.
If you'd like to set rsync automatically by cron or others, it need to configure like follows because authentication is required without settings. For example, Copy files or directories under the [/root/work] on dlp.srv.world to [/home/backup] on www.srv.world.
+----------------------+ | +----------------------+
| dlp.srv.world |10.0.0.30 | 10.0.0.31| www.srv.world |
| +----------+----------+ |
| /root/work/* | -------------> | /home/backup/* |
+----------------------+ copy +----------------------+
[1] Configure on source host.
[root@dlp ~]# yum -y install rsync
[root@dlp ~]# vi /etc/rsync_exclude.lst # specify files or directories you'd like to exclude to copy
test
test.txt
[2] Configure on destination host.
[root@www ~]# yum -y install rsync
[root@www ~]# vi /etc/rsyncd.conf # any name you like
[backup]
# destination directory for copy
path = /home/backup
# hosts you allow to access
hosts allow = 10.0.0.30
hosts deny = *
list = true
uid = root
gid = root
read only = false [root@www ~]# mkdir /home/backup
[root@www ~]# systemctl start rsyncd
[root@www ~]# systemctl enable rsyncd
[3] It's OK. Execute rsync on Source Host like follows.
[root@dlp ~]# rsync -avz --delete --exclude-from=/etc/rsync_exclude.lst /root/work/ www.srv.world::backup # Add in cron if you'd like to run reguraly
[root@dlp ~]# crontab -e # for example, run at 2:00 AM in a day
00 02 * * * rsync -avz --delete --exclude-from=/etc/rsync_exclude.lst /root/work/ www.srv.world::backup
CentOS6
参考地址:
https://www.server-world.info/en/note?os=CentOS_6&p=rsync
http://www.centoscn.com/CentosServer/ftp/2015/1123/6442.html
Synchronizes files and directories from one location to another by rsync.
The example below is for automatical settings. Ecxample ⇒ Copy files and directories in /var/www/html on a HostA[10.0.0.31] to in /home/backup on HostB[10.0.0.30].
[1] Configure on Destination Host.
[root@dlp ~]# yum -y install rsync xinetd
[root@dlp ~]# vi /etc/xinetd.d/rsync # default: off
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable= no# change
flags= IPv6
socket_type= stream
wait= no
user= root
server= /usr/bin/rsync
server_args= --daemon
log_on_failure+= USERID
} [root@dlp ~]# /etc/rc.d/init.d/xinetd start
Starting xinetd:[ OK ]
[root@dlp ~]# chkconfig xinetd on [root@dlp ~]# mkdir /home/backup
[root@dlp ~]# vi /etc/rsyncd.conf # any name you like
[website]
# destination directory
path = /home/backup
# Hosts you allow to copy (specify source Host)
hosts allow = 10.0.0.31
hosts deny = *
list = true
uid = root
gid = root
read only = false [root@dlp ~]# /usr/bin/rsync --daemon
[2] Configure on Source Host.
[root@www ~]# yum -y install rsync
[root@www ~]# vi /etc/rsync_exclude.lst # specify files or directories you'd like to exclude to copy
test
test.txt
[3] It's OK. Execute rsync on Source Host like follows.
[root@www ~]# rsync -avz --delete --exclude-from=/etc/rsync_exclude.lst /var/www/html/ 10.0.0.30::website # Add in cron if you'd like to run reguraly
[root@www ~]# crontab -e # run at 2:00 AM in a day
00 02 * * * rsync -avz --delete --exclude-from=/etc/rsync_exclude.lst /var/www/html/ 10.0.0.30::website
[CentOS] rsync同步目录进行备份文件的更多相关文章
- 使用rsync同步目录
本文描述了linux下使用rsync单向同步两个机器目录的问题. 使用rsync同步后可以保持目录的一致性(含删除操作). 数据同步方式 从主机拉数据 备机上启动的流程 同步命令: rsync -av ...
- rsync同步目录及同步文件
最简单的只读同步工作. 一,服务端的配置 1,安装rsync(阿里云默认已有此程序) 略 2,生成文件rsyncd.conf,内容如下: #secrets file = /etc/rsyncd.sec ...
- rsync同步目录
-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X) -r, --recursive recurse into directories - ...
- 运维工作中常用到的几个rsync同步命令
作为一个运维工程师,经常可能会面对几十台.几百台甚至上千台服务器,除了批量操作外,环境同步.数据同步也是必不可少的技能.说到“同步”,不得不提的利器就是rsync. 下面结合本人近几年运维工作中对这一 ...
- rsync实现目录同步
rsync rsync是linux系统下的数据镜像备份工具.使用快速增量备份工具Remote Sync可以远程同步,支持本地复制,或者与其他SSH.rsync主机同步. 外文名 rsync 全 ...
- Centos7 rsync同步备份文件
Centos7 rsync同步备份文件 一.rsync主服务端 1,安装rsync 查看是否安装rsync [root@localhost /]# rpm -qa | grep rsync 在线安装r ...
- rsync+inotify 实现资源服务器的同步目录下的文件变化时,备份服务器的同步目录更新,以资源服务器为准,去同步其他客户端
测试环境: 资源服务器(主服务器):192.168.200.95 备份服务器(客户端):192.168.200.89 同步目录:/etc/test 同步时使用的用户名hadoop密码12345 实验目 ...
- Linux使用rsync客户端与服务端同步目录进行备份
一.服务端设置 1. 修改 server 端配置 # vi /etc/rsyncd.conf 修改: uid = nobody # 该选项指定当该模块传输文件时守护进程应该具有的uid.默认值为&qu ...
- 使用rsync, 向另外一台服务器同步目录和文件的脚本
#!/bin/bash #亚特兰蒂斯-同步目录#定时任务ini_file="/usr/local/sunlight/conf/rsync-file.ini"target_ip=&q ...
随机推荐
- 2019-2-21.NET中异常类(Exception)
.NET中异常类(Exception) 异常:程序在运行期间发生的错误.异常对象就是封装这些错误的对象. try{}catch{}是非常重要的,捕获try程序块中所有发生的异常,如果没有捕获异常的话, ...
- 一道简单的dp题 --- Greenhouse Effect CodeForces - 269B
题目链接: https://vjudge.net/problem/36696/origin 题目大意: 要求从1到m升序排列,点可以随意移动,问最少需要移动多少次, 思路: 动态规划 可以推出转移方程 ...
- Mac_配置jdk环境变量
进入命令行 cd ~ touch .bash_profile vi .bash_profile 输入内容jdk变量配置内容: JAVA_HOME=/Library/Java/JavaVirtualMa ...
- ECMA Script 6_数组的扩展_扩展运算符
1. 扩展运算符 内部调用的是数据结构的 Iterator 接口, 因此只要具有 Iterator 接口的对象,都可以使用扩展运算符 ... 如 map,,,, [...arr] 扩展运算符(spre ...
- Node.js_express_搭建一个服务器
原生 node 服务器 1. 导入 node.js 核心模块 / 自带模块 : http const http = require('http'); // HTTP 库所具有的功能已经赋给了 h ...
- php 获取 两个时间戳之间 相隔 【多少年】 【 多少个月】 【多少天】 【 多少个小时】 【多少分】【 多少秒 】
/** * 返回两个时间的相距时间,*年*月*日*时*分*秒 * @param int $one_time 时间戳一 大的时间戳 * @param int $two_time 时间戳二 小的时间戳 * ...
- js文档就绪函数
$(function(){ //执行的内容 }): $().ready(function(){ //执行的内容 }); $(document).ready(function(){ //执行的内容 }) ...
- style样式不换行
style="white-space:nowrap;"不自动换行<font color="" size=""></font ...
- Web开发——jQuery进阶
参考: 参考:http://www.ruanyifeng.com/blog/2012/12/asynchronous%EF%BC%BFjavascript.html 参考:Asynchronous J ...
- C# Collection 排序
Collection<int> aa = new Collection<int>(); aa.Add(1); aa.Add(2); aa.Add(3); aa.Add(1); ...