博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[CentOS] rsync同步目录进行备份文件
阅读量:7009 次
发布时间:2019-06-28

本文共 3440 字,大约阅读时间需要 11 分钟。

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

 

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 copytesttest.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 copypath = /home/backup# hosts you allow to accesshosts allow = 10.0.0.30hosts deny = *list = trueuid = rootgid = rootread 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 day00 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 directorypath = /home/backup# Hosts you allow to copy (specify source Host)hosts allow = 10.0.0.31hosts deny = *list = trueuid = rootgid = rootread 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 copytesttest.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 day00 02 * * * rsync -avz --delete --exclude-from=/etc/rsync_exclude.lst /var/www/html/ 10.0.0.30::website

 

转载地址:http://cittl.baihongyu.com/

你可能感兴趣的文章
Java中的多线程,线程池
查看>>
发布系统背景和saltstack的基本操作
查看>>
软件下载站
查看>>
appium - 连接设备
查看>>
C#获取一个文件的相关信息
查看>>
linux驱动系列之文件压缩解压小节(转)
查看>>
POJ 1180 斜率优化DP(单调队列)
查看>>
Zend Studio 12 生成 WSDL
查看>>
重新学struct,边界对齐,声明……与Union的区别
查看>>
Centos6.8防火墙配置
查看>>
JAVA学习心得
查看>>
【夯实Mysql基础】记一次mysql语句的优化过程
查看>>
VBPR: Visual Bayesian Personalized Ranking from Implicit Feedback-AAAI2016 -20160422
查看>>
servlet injection analysis
查看>>
RNN 与 LSTM 的应用
查看>>
Linux服务器性能查看分析调优
查看>>
微信支付技术解决方案
查看>>
Vim 使用入门
查看>>
(原)centos7安装和使用greenplum4.3.12(详细版)
查看>>
深入学习Heritrix---解析CrawlController(转)
查看>>