Restoring
- Overview of process
- First, locate what backups are available to restore from, using --list-backups, and select the best one, for some definition of "best" ^_^
- Second, locate the files within that backup you require using --list-backup --backup-id
- Third, use "--produce-tar --starting-directory | tar xvfp -" to extract the files
- Strictly speaking, you can use --produce-tar with a pipe to "tar tvf -" in the second step
too, but it's much slower.
- Example restore:
- First we list all backups that finished (the last column is None for an unfinished backup). For the sake of discussion, assume the
green backup id is the "best" one:
- # ~/src/home-svn/backshift/trunk/backshift --save-directory /mnt/backshift-incremental-test/save-directory --list-backups | awk ' { if ($4 != "None") print }' | sort
- 1305581966.39_openindiana_export_mon-may-16-14-39-26-2011_6244d94b726da6c6 Mon-May-16-14:39:26-2011 2 Mon-May-16-14:39:26-2011
- 1305583872.56_openindiana_export_mon-may-16-15-11-12-2011_8cfbd6e4f5d87142 Mon-May-16-15:11:12-2011 2 Mon-May-16-15:11:13-2011
- 1305609181.37_openindiana_slash_mon-may-16-22-13-01-2011_04be24c2e608ec32 Mon-May-16-22:13:01-2011 160326 Tue-May-17-13:18:34-2011
- 1305609205.38_openindiana_export_mon-may-16-22-13-25-2011_20abd67bf8d07db3 Mon-May-16-22:13:25-2011 17177 Tue-May-17-04:12:41-2011
- Next we identify what file we need (the red path is its directory):
- # ~/src/home-svn/backshift/trunk/backshift --save-directory /mnt/backshift-incremental-test/save-directory --list-backup --backup-id 1305609205.38_openindiana_export_mon-may-16-22-13-25-2011_20abd67bf8d07db3 2>&1 | egrep -i 'xz.*local-script'
- -rw-r--r-- strombrg/staff 249 2011-05-16 10:32 export/home/strombrg/src/xz/local-script
- Note that in the preceding step, if we already knew the directory, but not the filename, we
could've used the following much more rapidly:
- # ~/src/home-svn/backshift/trunk/backshift --save-directory /mnt/backshift-incremental-test/save-directory --list-backup --backup-id 1305609205.38_openindiana_export_mon-may-16-22-13-25-2011_20abd67bf8d07db3 --starting-directory /export/home/strombrg/src/xz 2>&1
- -rw-r--r-- strombrg/staff 216 2011-05-16 10:07 export/home/strombrg/src/xz/Notes
- -rw-r--r-- strombrg/staff 626 2011-05-16 10:41 export/home/strombrg/src/xz/last-archives
- -rw-r--r-- strombrg/staff 249 2011-05-16 10:32 export/home/strombrg/src/xz/local-script
- drwxr-xr-x strombrg/staff 0 2011-05-16 10:11 export/home/strombrg/src/xz/old/
- -rw-r--r-- strombrg/staff 1023720 2011-04-01 03:11 export/home/strombrg/src/xz/xz-5.0.2.tar.bz2
- -rw-r--r-- strombrg/staff 1270541 2011-04-12 03:49 export/home/strombrg/src/xz/old/xz-5.1.1alpha.tar.gz
- Finally, we extract the file we want:
- # ~/src/home-svn/backshift/trunk/backshift --save-directory /mnt/backshift-incremental-test/save-directory --backup-id 1305609205.38_openindiana_export_mon-may-16-22-13-25-2011_20abd67bf8d07db3 --starting-directory /export/home/strombrg/src/xz --produce-tar | tar xvf - export/home/strombrg/src/xz/local-script
- export/home/strombrg/src/xz/local-script
- Note that during the restore, backshift didn't write to your filesystem; tar did (except on Windows, where some temp files are
written briefly).
- BTW, the above example is for a local restore. If you wanted to do a remote restore (on example.com) instead,
the last step would look like:
- # ~/src/home-svn/backshift/trunk/backshift --save-directory /mnt/backshift-incremental-test/save-directory --backup-id 1305609205.38_openindiana_export_mon-may-16-22-13-25-2011_20abd67bf8d07db3 --starting-directory /export/home/strombrg/src/xz --produce-tar --nonrecursive | ssh example.com 'cd / && tar xvf - export/home/strombrg/src/xz/local-script'
- Also, if you want to extract a file from the root of a large directory hierarchy, you can:
- Note the --nonrecursive option, which also works with --list-backup.
- # backshift --save-directory /mnt/save-directory --backup-id 1305609205.38_openindiana_export_mon-may-16-22-13-25-2011_20abd67bf8d07db3 --starting-directory /export/home/strombrg/src/xz --nonrecursive --produce-tar | tar xvf - export/home/strombrg/src/xz/local-script