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?

5
  • 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 7, 2011 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 7, 2011 at 13:30
  • It is unclear what results you are trying to obtain. Define "merge".
    – psusi
    Jul 7, 2011 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 7, 2011 at 14:19
  • rsnapshot rsync-snapshot flyback rdiff-backup backuppc ...
    – ptman
    Jul 14, 2011 at 15:57

2 Answers 2

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.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .