Linux – Merge incremental rsync backups

backupbashlinuxrsyncscripting

I need to merge my incremental backups into the secure folder (which is the main backup folder) in order of date.

Someone has helped with the script to rsync the documents each night via a cron job:

$ for f in `ls -t /var/backups`; do rsync -aL "/var/backups/$f" /var/www/live/documents/; done

Current folder:

backup-2011-07-02  backup-2011-06-27  backup-2011-06-22  backup-2011-06-17
backup-2011-07-06  backup-2011-07-01  backup-2011-06-26  backup-2011-06-21  backup-2011-06-16
backup-2011-07-05  backup-2011-06-30  backup-2011-06-25  backup-2011-06-20  backup-2011-06-15
backup-2011-07-04  backup-2011-06-29  backup-2011-06-24  backup-2011-06-19  backup-2011-06-14
backup-2011-07-03  secure             backup-2011-06-23  backup-2011-06-18

Example folder structure:

backup-2011-07-03/secure/docs
secure/docs

In each of these folders is the folder secure in which are the folders and files that need to be merged

I not sure the best way to write a script to merge all the backups in order of date into the secure folder.

Any ideas?

Best Answer

It is not what you ask for, but you can actually have everyday a full backup with rsync, while it will upload and take as much storage as normal incremental back up. It is done with hard links. I have done a script that automates that and I use it daily on multiple machines. You can grab it with description here: http://okrasz-techblog.blogspot.com/2011/02/backing-up-with-rsync.html

Note - when backup is done it will update last_full_backup.txt with backup directory. This is in case backup was interrupted.