HOWTO Restore Files From Amanda: Difference between revisions
No edit summary |
|||
(15 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
How to restore files from an Amanda tape backup. | How to restore files from an Amanda tape backup. | ||
SSH to musashi for recovering files from a machine, and SSH to | SSH to musashi or hurricane for recovering files from a machine, and SSH to spitfire to recover files from users or projects. | ||
== Finding Where the Files you want to Restore are Located == | == Finding Where the Files you want to Restore are Located == | ||
Line 34: | Line 34: | ||
2007-05-03 inferno /srv/www 1 Daily03 2 OK | 2007-05-03 inferno /srv/www 1 Daily03 2 OK | ||
2007-05-04 inferno /srv/www 1 Daily04 2 OK | 2007-05-04 inferno /srv/www 1 Daily04 2 OK | ||
<br> | |||
'''Note:''' You cannot specify a low-level directory or a file. You have to use the same name that amanda used for the backup - typically a directory. For example, if a user deleted all their Firefox bookmarks/preferences, you '''cannot''' directly try to find '''''/home/gordp/.mozilla/firefox/xxx.gord''''', but rather you would have to find '''''/home/gordp'''''. This is because amanda only knows about having backed up '''''/home/gordp'''''. | |||
== Restoring Files == | == Restoring Files == | ||
Looking at the file-listing, you are interested in the '''most-recent''' level0 backup (to begin with), and the most-recent level1. None of the others (ie xxx ) are of any interest at all. We will only use DailyMusashi20, and DailyMusashi25 in the first example; Daily10 and Daily04 in the second example. | Looking at the file-listing, you are interested in the '''most-recent''' level0 backup (to begin with), and the most-recent level1. None of the others (ie xxx ) are of any interest at all. We will only use DailyMusashi20, and DailyMusashi25 in the first example; Daily10 and Daily04 in the second example. | ||
<br> | <br><br> | ||
If you had level2, level3 or higher, then they would get "layered" on top of the level0 and level1 restores. In this case, you would use the '''most recent''' level2, level3 or higher tapes. | |||
<br><br> | |||
Now that you know what tape the files are on, insert the first tape into the drive and ask for the files. Note: ''The files will be extracted into the current directory.'' | Now that you know what tape the files are on, insert the first tape into the drive and ask for the files. Note: ''The files will be extracted into the current directory.'' | ||
<br> | <br> | ||
Line 44: | Line 49: | ||
<font color=lime>amanda@hostname</font> <font color=blue>~ $</font> '''mkdir restore; cd restore''' | <font color=lime>amanda@hostname</font> <font color=blue>~ $</font> '''mkdir restore; cd restore''' | ||
<font color=lime>amanda@hostname</font> <font color=blue>~ $</font> '''amrestore -p /dev/nst0 209.87.56.16 /etc | tar xvf -''' | <font color=lime>amanda@hostname</font> <font color=blue>~ $</font> '''amrestore -p /dev/nst0 209.87.56.16 /etc | tar xvf -''' | ||
Or, another couple of examples using '''''amfetchdump''''' | |||
<font color=lime>amanda@hostname</font> <font color=blue>~ $</font> '''amfetchdump -d /dev/nst0 -p hurricane 209.87.56.56 /vservers/sr-hercules01/var/lib/mysql 20120606 | tar xvf -''' | |||
<font color=lime>amanda@hostname</font> <font color=blue>~ $</font> '''amfetchdump -d /dev/nst0 -p hurricane 209.87.56.5 /var/www 20120618 | tar xvf -''' | |||
Either command (amrestore or amfetchdump) will output the files and directories in the current folder. You can abort the process at anytime when your file has been recovered (CTRL-C). | |||
<br><br> | |||
If you need multiple tapes, simply rewind (below), eject (below), insert the next tape, and repeat the above '''amrestore''' command. | |||
<br><br> | |||
Now that the files have been extracted, you can copy them to their final destination. If the final destination is local to the amanda-server where you've just extracted the files, simply use '''cp''', probably with the '''-R''' option to recurse and copy subdirectories. | |||
<br><br> | |||
If the final destination is a remote-machine, use '''scp''', again with '''-r''' recursive option if you need subdirectories copied over also. | |||
<br><br> | |||
File ownerships will likely be wrong! use '''chown -R ''<user:group> <directory>''''' to correct this. | |||
<br> | |||
== Finish Up == | == Finish Up == | ||
Rewind a tape; as root: | Rewind a tape; as root: | ||
<font color=red>hostname</font> <font color=blue>/ #</font> '''mt -f /dev/st0 rewind''' ''(/dev/nst0'' is the '''non'''-rewinding device, although it may rewind anyway)'' | <font color=red>hostname</font> <font color=blue>/ #</font> '''mt -f /dev/st0 rewind''' ''('''/dev/nst0''' is the '''non'''-rewinding device, although it may rewind anyway)'' | ||
<font color=red>hostname</font> <font color=blue>/ #</font> '''mt -f /dev/nst0 eject''' | <font color=red>hostname</font> <font color=blue>/ #</font> '''mt -f /dev/nst0 eject''' |
Latest revision as of 21:17, 18 June 2012
How to restore files from an Amanda tape backup.
SSH to musashi or hurricane for recovering files from a machine, and SSH to spitfire to recover files from users or projects.
Finding Where the Files you want to Restore are Located
hostname / # su - amanda amanda@hostname ~ $ amadmin $backupname find $hostname/$ipaddress $directorypath
Worked Example: amanda@hostname ~ $ amadmin DailyMusashi find 209.87.56.16 /etc
You should see something like this:
2006-04-07 209.87.56.16 /etc/ 0 DailyMusashi20 24 OK 2006-04-10 209.87.56.16 /etc/ 1 DailyMusashi21 16 OK 2006-04-11 209.87.56.16 /etc/ 1 DailyMusashi22 19 OK 2006-04-12 209.87.56.16 /etc/ 1 DailyMusashi23 23 OK 2006-04-13 209.87.56.16 /etc/ 1 DailyMusashi24 29 OK 2006-04-18 209.87.56.16 /etc/ 1 DailyMusashi25 23 OK
Another example:
amanda@trainwreck ~ $ amadmin Daily find inferno /srv/www Scanning /holding... Scanning /holding... date host disk lv tape or file file status 2007-04-23 inferno /srv/www 0 Daily05 8 OK 2007-04-24 inferno /srv/www 1 Daily06 4 OK 2007-04-25 inferno /srv/www 1 Daily07 2 OK 2007-04-26 inferno /srv/www 1 Daily08 2 OK 2007-04-27 inferno /srv/www 1 Daily09 2 OK 2007-04-30 inferno /srv/www 0 Daily10 10 OK 2007-05-01 inferno /srv/www 1 Daily01 6 OK 2007-05-02 inferno /srv/www 1 Daily02 2 OK 2007-05-03 inferno /srv/www 1 Daily03 2 OK 2007-05-04 inferno /srv/www 1 Daily04 2 OK
Note: You cannot specify a low-level directory or a file. You have to use the same name that amanda used for the backup - typically a directory. For example, if a user deleted all their Firefox bookmarks/preferences, you cannot directly try to find /home/gordp/.mozilla/firefox/xxx.gord, but rather you would have to find /home/gordp. This is because amanda only knows about having backed up /home/gordp.
Restoring Files
Looking at the file-listing, you are interested in the most-recent level0 backup (to begin with), and the most-recent level1. None of the others (ie xxx ) are of any interest at all. We will only use DailyMusashi20, and DailyMusashi25 in the first example; Daily10 and Daily04 in the second example.
If you had level2, level3 or higher, then they would get "layered" on top of the level0 and level1 restores. In this case, you would use the most recent level2, level3 or higher tapes.
Now that you know what tape the files are on, insert the first tape into the drive and ask for the files. Note: The files will be extracted into the current directory.
NOTE: Make sure you have enough drive-space for the extraction to succeed! df -h
amanda@hostname ~ $ mkdir restore; cd restore amanda@hostname ~ $ amrestore -p /dev/nst0 209.87.56.16 /etc | tar xvf -
Or, another couple of examples using amfetchdump
amanda@hostname ~ $ amfetchdump -d /dev/nst0 -p hurricane 209.87.56.56 /vservers/sr-hercules01/var/lib/mysql 20120606 | tar xvf - amanda@hostname ~ $ amfetchdump -d /dev/nst0 -p hurricane 209.87.56.5 /var/www 20120618 | tar xvf -
Either command (amrestore or amfetchdump) will output the files and directories in the current folder. You can abort the process at anytime when your file has been recovered (CTRL-C).
If you need multiple tapes, simply rewind (below), eject (below), insert the next tape, and repeat the above amrestore command.
Now that the files have been extracted, you can copy them to their final destination. If the final destination is local to the amanda-server where you've just extracted the files, simply use cp, probably with the -R option to recurse and copy subdirectories.
If the final destination is a remote-machine, use scp, again with -r recursive option if you need subdirectories copied over also.
File ownerships will likely be wrong! use chown -R <user:group> <directory> to correct this.
Finish Up
Rewind a tape; as root:
hostname / # mt -f /dev/st0 rewind (/dev/nst0 is the non-rewinding device, although it may rewind anyway) hostname / # mt -f /dev/nst0 eject