Sooner or later you will need to restore from your backup, and it doesn't hurt to create a situation where you do need to restore a file. I am going to show how I restore files which does work as I have had to use it for real.

Restore to /home/$USER

My backup of /home is filed under obnam-home on ’/media/boudiccas/backup/obnam-home’, with it's config being at ’/etc/obnam.conf’. It might seem to be long-winded having to lay out all the information but, what happens if something happens to you? You could get run over by a bus, or break a leg playing football, or, in other words, you don't know what is just around the corner for you, so you really need to be prepared. So write it down, or record it on the computer and print it out and store it with your important documents.

So, find out what file you want to restore, and what path should it go to, i.e. where was the file backed up from? You'll find that it will benefit you to have the details of your conf files written down and stored for future use, I recommend Zim wiki for this.

Mine are -

  • obnam --config=/etc/obnamvar.conf # backup of /var
  • obnam --config=/etc/obnametc.conf # backup of /etc
  • obnam --config=/etc/obnam-back4.conf # backup of a backup drive
  • obnam --config=/etc/obnam.conf # backup of /home/$USER

So to start with we run 'obnam generations' for getting a list of all the backups, which looks like this -

'81029    2013-09-04 14:00:19 .. 2013-09-04 14:13:27 (159964 files, 227689556415 bytes)
 81481   2013-09-04 16:00:14 .. 2013-09-04 16:08:35 (164574 files, 228598409365 bytes)  (checkpoint)'

which shows the generation number, date, and time.

So we're going to restore from backup 'init' from ./fluxbox, and the restore line is -

'obnam --generation=81029 restore /home/boudiccas/.fluxbox/init --to=/'

which restores it to its original position, over-writing any file there without prompting you for an overwrite, so be very careful that its overwriting what you want it to!

To fine-tune it even more, where we select the actual file to be restored we look at 'obnamhome.txt' if we cant remember exactly which file we want to restore. Obnamhome.txt is created as the logfile of obnam running and backing up /home/$USER as shown on 'obnam.conf'.

To restore from /etc backup

This is where the written record of where the conf files comes in handy. We want to restore 'fstab' to its original place, so the command will be -

'sudo obnam --config=/etc/obnametc.conf --generation=1399 restore /etc/fstab --to=/'

which gives this report -

sudo obnam --config=/etc/obnametc.conf --generation=1399 restore /etc/fstab --to=/
[sudo] password for boudiccas:
Restored 1 files, downloaded 862.0 B in 6s at 150.6 B/s average speed

It should be noted that there is a different generation number which is found at '~/cron/obnam/obnametc-ls-2013-09-04.txt' or for a historic restore from '~/cron/obnam/obnametc-gen-2013-09-04.txt'. In general, individual files are found in those files which have the 'ls' in their name, and the historic backup details in those with 'gen' in their name.

To restore from obnamvar or obnam-back4 you just change the command as required.



Comments

comments powered by Disqus