How to setup an ideal rsync task between two Linux servers

                                            by Jephe Wu - http://linuxtechres.blogspot.com

 

Summary

There's some issue for syncing server a(source) to server b (dest.) which caused server b partition full, in order to solve the problem, we need to adjust some rsync parameters for cronjob task.


Original rsync task under root cronjob

*/30 * * * *  /usr/bin/rsync --numeric-ids -avr --exclude=.snapshot 192.168.1.10::share/* /share

Note: this has caused server b /share partition full due to it won't delete files on destination site.


In order to make a full sync working again, we will need to manually run task below which will delete first to free up space, then sync files again.

/usr/bin/rsync --numeric-ids -avr --delete --delete-before --ignore-errors --exclude=.snapshot 192.168.1.10::share/* /share


The rsync daemon config on server a is below:

[root@servera share]# more /etc/rsyncd.conf

reverse lookup = false

[share]
  path = /share
  numeric ids = yes
  max connections = 10
  list = true



After full sync completed, we will change cronjob to below:


*/30 * * * *  /usr/bin/rsync --numeric-ids -avr --delete --delete-before --ignore-errors --exclude=.snapshot 192.168.1.10::share/* /share >> /var/log/rsync-cron.log

Note: sometimes, you will encounter error message 'IO error encountered -- skipping file deletion' for rsync command, you can use '--ignore-errors' option as above to avoid this issue.



No comments:

Post a Comment