0

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?

Grimlockz
  • 325
  • 1
  • 2
  • 11
  • Not exactly sure what you mean with the "secure" thing, but `ls -t` is newest first, it seems like you would want oldest first, which would be `ls -rt` – DerfK Jul 07 '11 at 13:27
  • @DerfK Secure is the main backup of all files prior to the incremental backups so this holds all the data – Grimlockz Jul 07 '11 at 13:30
  • It is unclear what results you are trying to obtain. Define "merge". – psusi Jul 07 '11 at 14:17
  • @psusi Trying to copy all the currents of the backups into one folder doing it in date order so any file that has been change will be over written by the newer file – Grimlockz Jul 07 '11 at 14:19
  • [rsnapshot](http://www.nongnu.org/rdiff-backup/) [rsync-snapshot](http://code.google.com/p/rsync-snapshot/) [flyback](http://code.google.com/p/flyback/) [rdiff-backup](http://www.nongnu.org/rdiff-backup/) [backuppc](http://backuppc.sourceforge.net/) ... – ptman Jul 14 '11 at 15:57

2 Answers2

1

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.

oker
  • 481
  • 2
  • 3
0

This should do the trick then:

mkdir /var/backups/merged
for f in `ls -t /var/backups/backup-*` ; do cp -an /var/backups/$f/* /var/backups/merged/ ; done
psusi
  • 3,347
  • 1
  • 17
  • 9