[CentOS] rsync同步目录进行备份文件
2018-01-04 21:37
706 查看
操作不难,网上一堆。这里列几个
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.
[1] Configure on source host.
[2] Configure on destination host.
[3] It's OK. Execute rsync on Source Host like follows.
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.
[2] Configure on Source Host.
[3] It's OK. Execute rsync on Source Host like follows.
CentOS7
参考地址: https://www.server-world.info/en/note?os=CentOS_7&p=rsyncCopy 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
相关文章推荐
- Linux使用rsync客户端与服务端同步目录进行备份
- linux中部署rsync实现文件远程备份及同步(centos x64 6.8)
- rsync 排除指定目录或文件进行同步
- rsync 排除指定目录或文件进行同步
- 使用rsync进行CentOS服务器之间的目录同步
- CentOS 7.2 部署Rsync + Lsyncd服务实现文件实时同步/备份 (三)
- CentOS6.5环境下使用rsync增量同步备份文件的方法
- rsync+inotify目录文件实时同步备份 推荐
- CentOS安装和配置Rsync进行文件同步
- CentOS下(rsync+crontab)触发式实现服务器间的文件备份同步
- CentOS 6.3_ RSync实现文件定时备份同步配置与使用 推荐
- CentOS 6.3_ RSync实现文件定时备份同步配置与使用
- CentOS 6.3_ RSync实现文件备份同步配置排除故障
- linux使用rsync客户端与服务端同步目录进行备份
- 使用Rsync进行文件的同步与备份
- CentOS下rsync服务器安装与配置-数据同步-文件增量备份
- CentOS 7.2 部署Rsync + Lsyncd服务实现文件实时同步/备份 (二)
- CentOS 7.2 部署Rsync + Lsyncd服务实现文件实时同步/备份 (一)
- Linux使用rsync客户端与服务端同步目录进行备份
- Linux使用rsync客户端与服务端同步目录进行备份