AMANDA – Restore – Getting your data back
While it is useful to be conscientious and change the back up tapes daily. These will be worthless unless you keep the tape drive clean and you periodically test your backups.
On the server you have been instructed to set up a cron job that will run the backups. On the server it is also useful running the AMANDA Index server which will allow you to access the AMANDA indexes to allow you to restore your data. This may be done by running the command chkconfig amidxtape on.
To start the recovery of your data you need to enter the command-line ftp style access to the AMANDA archives.
If your backup server has gone up in flames and all you are left without any Indexes, it is possible to search the tapes to discover what data is available. The command for this is amrestore, which will also restore your data once found. Check man amrestore for more options.. To search a tape issue the command: amrestore -p /dev/tape no-such-host > /dev/null . The results of the command will appear as follows:
amrestore -p /dev/tape no-such-host > /dev/null
amrestore: 0: skipping start of tape: date 20040720 label DailySet43
amrestore: 1: skipping dataserver.example.co.uk._home_data_all.20040720.4
amrestore: 2: skipping dataserver.example.co.uk._raid_stuff.20040720.1
amrestore: 3: skipping dataserver.example.co.uk._raid_user.20040720.1
amrestore: 4: skipping dataserver.example.co.uk._raid_documentation.20040720.1
amrestore: 5: skipping dataserver.example.co.uk._raid_backup.20040720.4
amrestore: 6: skipping dataserver.example.co.uk._raid_config.20040720.1
amrestore: 7: skipping dataserver.example.co.uk._raid_user2.20040720.1
amrestore: 8: skipping server2.example.co.uk._dev_hda3.20040720.4
amrestore: 9: skipping dataserver.example.co.uk._etc.20040720.1
amrestore: 10: skipping dataserver.example.co.uk._raid_user3.20040720.2
amrestore: 11: skipping mx.example.co.uk._dev_hda2.20040720.3
amrestore: 12: skipping dataserver.example.co.uk._home_user3_ag.20040720.0
amrestore: 13: skipping mx.example.co.uk._dev_md0.20040720.0
amrestore: 14: skipping server2.example.co.uk._dev_hda1.20040720.4
amrestore: 15: skipping access.example.co.uk._dev_hda1.20040720.4
amrestore: 16: skipping dataserver.example.co.uk._home_user3_gn.20040720.0
amrestore: 17: reached end of information
Once we have this information I may move to a directory that I want the data extracted to and then extract the data. The recommended commands for extracting the data from the man page did not work for me.
I use the following to for example extract the directory /raid/user2 from dataserver.example.co.uk shown here as section 7 on the tape:
mt rewind;mt -f /dev/tape fsf 7;dd if=/dev/tape bs=32k skip=1 | gunzip | tar xvf –
So first we rewind the tape, we then fast forward to section 7 and read the tape to pipe to gunzip (most of my archives are zipped) and then to tar to extract them to the current directory.You could also try the following:
mt rewind; amrestore /dev/tape host.example.co.uk | tar xvf –
This ask for only the backups from host.example.co.uk and will drop the images from the tape in the current directory, called host.example.co.uk._dev_hda1.20040312.3 for example; this being partition /dev/hda1 from host.example.co.uk taken on the 12th December 2004. It is a third recursive dump and may not hold much data. You will then be able to extract the files manually using tar:
tar xvf host.example.co.uk._dev_hda1.20040312.3