lunes, 3 de agosto de 2015

Rsync en Centos 7

Copy files or directories from one location to an another host by rsync.
Basic usage of rsync is here.
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.server.world to [/home/backup] on www.server.world.
+----------------------+          |          +----------------------+
|   dlp.server.world   |10.0.0.30 | 10.0.0.31|   www.server.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.server.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.server.world::backup

Fuente:
http://www.server-world.info/en/note?os=CentOS_7&p=rsync

No hay comentarios:

Publicar un comentario