操作不难,网上一堆。这里列几个

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同步目录进行备份文件的更多相关文章

  1. 使用rsync同步目录

    本文描述了linux下使用rsync单向同步两个机器目录的问题. 使用rsync同步后可以保持目录的一致性(含删除操作). 数据同步方式 从主机拉数据 备机上启动的流程 同步命令: rsync -av ...

  2. rsync同步目录及同步文件

    最简单的只读同步工作. 一,服务端的配置 1,安装rsync(阿里云默认已有此程序) 略 2,生成文件rsyncd.conf,内容如下: #secrets file = /etc/rsyncd.sec ...

  3. rsync同步目录

    -a, --archive archive mode; equals -rlptgoD (no -H,-A,-X) -r, --recursive recurse into directories - ...

  4. 运维工作中常用到的几个rsync同步命令

    作为一个运维工程师,经常可能会面对几十台.几百台甚至上千台服务器,除了批量操作外,环境同步.数据同步也是必不可少的技能.说到“同步”,不得不提的利器就是rsync. 下面结合本人近几年运维工作中对这一 ...

  5. rsync实现目录同步

    rsync rsync是linux系统下的数据镜像备份工具.使用快速增量备份工具Remote Sync可以远程同步,支持本地复制,或者与其他SSH.rsync主机同步. 外文名 rsync 全     ...

  6. Centos7 rsync同步备份文件

    Centos7 rsync同步备份文件 一.rsync主服务端 1,安装rsync 查看是否安装rsync [root@localhost /]# rpm -qa | grep rsync 在线安装r ...

  7. rsync+inotify 实现资源服务器的同步目录下的文件变化时,备份服务器的同步目录更新,以资源服务器为准,去同步其他客户端

    测试环境: 资源服务器(主服务器):192.168.200.95 备份服务器(客户端):192.168.200.89 同步目录:/etc/test 同步时使用的用户名hadoop密码12345 实验目 ...

  8. Linux使用rsync客户端与服务端同步目录进行备份

    一.服务端设置 1. 修改 server 端配置 # vi /etc/rsyncd.conf 修改: uid = nobody # 该选项指定当该模块传输文件时守护进程应该具有的uid.默认值为&qu ...

  9. 使用rsync, 向另外一台服务器同步目录和文件的脚本

    #!/bin/bash #亚特兰蒂斯-同步目录#定时任务ini_file="/usr/local/sunlight/conf/rsync-file.ini"target_ip=&q ...

随机推荐

  1. c++中一个多态的实例

    #include <iostream> #include <fstream> #include <vector> #include <algorithm> ...

  2. 04-Python入门学习-流程控制

    一.流程控制if 语法1: if 条件:  code1  code2  code3  .... age=180 height=163 weight=75 sex='female' is_beautif ...

  3. git 强制覆盖分支

    假设要用develop覆盖master分支,如下操作 git checkout master git reset --hard develop //先将本地的master分支重置成develop gi ...

  4. file_get_contents 在本地测试可以, 但在服务器上报错403

    解决方法: Most likely if you don't get any content while accessing an webpage, probably it doesn't want ...

  5. 阿里云 ACP 考试学习过程分享

    目录 考证意义 学习方法 ACP 报名 学习安排[重要] 考试当天 其他 经验贴 考证意义 证多不压身,证比项目经历更具有说服力,证是行业的标准认证.更多时候,是有证的人说,"证其实不重要& ...

  6. Nmap 进阶使用 [ 脚本篇 ]

    0×01 前言 因为今天的重点并非nmap本身的使用,主要还是想借这次机会给大家介绍一些在实战中相对比较实用的nmap脚本,所以关于nmap自身的一些基础选项就不多说了,详情可参考博客端口渗透相关文章 ...

  7. javascript的数组之pop()

    pop()方法从数组中删除最后一个元素,并返回该元素的值.此方法更改数组的长度. let a = [1, 2, 3]; a.length; a.pop(); console.log(a); // [1 ...

  8. <c:forEach var="role" items="[entity.Role@d54d4d, entity.Role@1c61868, entity.Role@6c58db, entity.Role@13da8a5]"> list 集合数据转换异常

    <c:forEach var="role" items="[entity.Role@d54d4d, entity.Role@1c61868, entity.Role ...

  9. android 自定义Button,抛弃写shape文件

      标签: android 控件  自定义 2017年05月27日 17:52:13 611人阅读 评论(0) 收藏 举报 分类: 自定义View(2) 作者同类文章 X 版权声明:本文为博主原创文章 ...

  10. ApiKernel

    using System; using System.Runtime.InteropServices; using System.Text; using HANDLE = System.IntPtr; ...