[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 ...
随机推荐
- ISP PIPLINE (五) Denoise
what is the Denoise? Denoise就是图像去噪,平滑图像,并保留图像细节. why does Denoise? 图像在采集并转换为数字信号的过程会引入一些噪声,这些噪声会让图片看 ...
- centos6.5安装nginx+python+uwsgi+django
nginx+uwsgi+django环境部署及测试 默认系统自带的python2.6.6 第一步(安装setuptools) wget https://pypi.python.org/packages ...
- Python数据分析基础PDF
Python数据分析基础(高清版)PDF 百度网盘 链接:https://pan.baidu.com/s/1ImzS7Sy8TLlTshxcB8RhdA 提取码:6xeu 复制这段内容后打开百度网盘手 ...
- 最大子矩阵和问题dp
给定一个矩阵 matrix,其中矩阵中的元素可以包含正数.负数.和0,返回子矩阵的最大累加和.例如,矩阵 matrix 为: 0 -2 -7 0 9 2 -6 2 -4 1 -4 1 -1 8 0 - ...
- angularjs ng-if 中的ng-model 值作用域问题
现象:最近做了一个需求,页面上使用了ng-if 条件做判断,导致通过使用 $scope 获取不到 ng-model 的值. 问题原因: ng-if这个指令单独开了一个作用域,它只可以继承,不可以进行往 ...
- Installation of CarbonData 1.1.0 with Spark 1.6.2
关键词:carbondata spark thrift 数据仓库 [Install thrift 0.9.3] 注意 要装thrift-java必须先装ant . 有人说要装boost,我在cento ...
- mobile_缩放
document.documentElement.clientWidth 不包含滚动条 window.innerWidth ...
- Centos 7 上使用nginx为Node.js配置反向代理时错误:(13: Permission denied) while connecting to upstream
错误来源:Centos 7 上使用nginx为Node.js配置反向代理时产生(13: Permission denied) while connecting to upstream的错误 nginx ...
- gvim 技巧
1.对齐 很多时候想对齐括号和“=”号,行数很多的时候就是体力活了.使用3条命令就可以完成对齐 :set ts=16 ##将tab设置为16 :%s/(/\t(/ ...
- js数组指定位置添加删除
示例参考:http://www.w3school.com.cn/jsref/jsref_splice.asp