4

I have incremental rsync backups of a folder, created with:

rsync --delete -a -v --backup --backup-dir="../backup_`date +%Y-%m-%d`" /orig /backups/dest

so I have a copy of current /orig on /backups/dest and modified files on /backups/backup_YYYY_MM_DD/

my question is there's any easy way to restore the backup as it was on specific date?

Lluís
  • 425
  • 1
  • 4
  • 21

2 Answers2

2

As the various backup dirs only contain the changed files by the last current backup, the restore procedure is somewhat complex: you need to restore the current full backup and re-apply the various file-level backup, up to the required (past) date.

Can I suggest you a better backup method? Please use the --link-dest option combined with proper rotation.

Even better, give a look at rsnapshot and its doc

shodanshok
  • 44,038
  • 6
  • 98
  • 162
0

I think:

rsync -a --delete /backups/backup_YYYY__MM__DD/orig/ /orig/

should suffice.

Take care of the trailing slash at the end of the source directory pathname.

HTH

phep
  • 414
  • 5
  • 15
  • `/backups/backup_YYYY_MM_DD/orig` only contains the modified files since last backup – Lluís Jun 14 '13 at 09:40
  • 1
    Oh I see. I made some more testing. I'm afraid you've got to re-apply all of the backups you made up the desired backup. Something along the lines : `rsync -a ..../backup_n /orig` then `rsync -a ..../backup_n-1 /orig`, ... You'd have been better using rsnapshot, probably. – phep Jun 14 '13 at 09:57
  • I already had thought about restoring each backup folder, but rsync will not delete newly added files, so I could get a restored folder with files that were not at the original one. You are right, would be easier to restore an rsnapshot backup – Lluís Jun 14 '13 at 10:08
  • finally did a `rsync` for each backup until date, then erased newer files with `find -mtime` – Lluís Jun 14 '13 at 12:33
  • I'm afraid that doing so you also delete files that have just been modified after the "good" backup instead of reverting them to their previous "good" state. – phep Jun 14 '13 at 12:49
  • I don't think so, since every change made after desired restoration date has its previous state backed up, and rsync preserves modification time – Lluís Jun 15 '13 at 13:45