How To:Recover Data

From The Open Source Backup Wiki (Amanda, MySQL Backup, BackupPC)
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

First of all, you should know that there are three ways to get at your data in Amanda:

  • amrecover(8), which lets you restore particular files or directories and is the most automated
  • amfetchdump(8), which can get you a dump of an entire DLE, but does not know how to look inside
  • amrestore(8), which knows how to pull data off of Amanda devices, but leaves the rest up to you. This is really only useful for bare-metal restores

This page uses amrecover. The other two tools are well-covered in their manpages and in other How Tos.

Invoking amrecover

Amrecover is interactive, and runs on the client, as root. Assuming your server is named 'backupbox1' and the configuration is named 'CompanyBackups', you can run

# amrecover CompanyBackups -s backupbox1

If this works, great, skip to the next section.

In many cases, this doesn't work because amrecover is the only Amanda utility that connects from the Amanda client to the Amanda server. You'll need to do the same kind of work you did to get the Amanda server talking to the Amanda clients, only in reverse. If you're using bsdtcp, this will involve some work with xinetd or the equivalent, and some attention to the .amandahhosts file. See amanda-auth(7) and amanda-client.conf(5) for the background documentation.

A nice shortcut is to simply use local authentication, and run amrecover on the Amanda server (assuming you're running Amanda-2.6.1 or later):

# amrecover CompanyBackups -o auth=local -s localhost

Finding Your Files

You should now be at the amrecover prompt:

amrecover>

The 'help' command will show you a list of all commands. You'll need to narrow in on the exact files that you want to recover. First, set the hostname of the system you'd like to recover:

amrecover> sethost buildslave
200 Dump host set to buildslave.

You can use the 'listhost' command to see a list of all hosts in the disklist(5). Next, set the disk on that host:

amrecover> setdisk /etc
200 Disk set to /etc.

Now, you can start exploring using 'ls' and 'cd':

amrecover> ls
..
2011-01-01-03-15-01 modprobe.d/
2011-01-01-03-15-01 mail/
..
amrecover> cd mail
/etc/mail
amrecover> ls
2011-01-01-03-15-01 spamassassin/
2011-01-01-03-15-01 .
2010-12-29-03-15-01 aliases.db
2010-12-29-03-15-01 aliases

You can see the history of dumps of this DLE with 'history':

amrecover> history
200- Dump history for config "CompanyBackups" host "buildslave" disk /etc
201- 2011-01-01-03-15-01 1 Daily015:1
201- 2010-12-31-03-15-01 0 Daily014:2
...

and set the date you'd like to recover with 'setdate':

amrecover> setdate 2010-12-31
200 Working date set to 2010-12-31.

Adding files or directories to the list for recovery using 'add':

amrecover> add aliases
Added file /mail/aliases

when you've put together the whole list of files you want to restore, run 'extract':

amrecover> extract
Extracting files using tape drive changer on host euclid.
The following tapes are needed: Daily014
Extracting files using tape drive changer on host euclid.
Load tape Dailiy014 now
Continue [?/Y/n/s/d]? 

note that Amanda figured out which tapes it would need (only one in this case), and that it's promising to use the changer on the server (euclid). There's a little bit of funny business involved here: on the server, the amrecover_changer parameter should be set to "changer", and amrecover should be told to use a device named "changer". If this isn't the default, hit 'd' at this 'Continue' prompt and type "changer":

Continue [?/Y/n/s/d]? d
New device name [?]: changer
Using tape "changer" from server euclid.

Otherwise, continue:

Restoring files into directory /root
./mail/aliases
amrecover> 

that's it - the file is now recovered at /root/mail/aliases!