Home Server Amanda Backup Usage

Index.

There are many more commands, but these commands are most likely the ones you would need sometimes. The amanda wiki has much more documentation, and all commands have man pages too.

16-Nov-2011: initial release.
02-Dec-2012: added caveats.

 

Amadmin.

Some commands:

[amanda@homsrv ~]$ amadmin wpl holding list
[amanda@homsrv ~]$ amadmin wpl tape
The next Amanda run should go onto 2 new tapes.
The next 2 new tapes already labelled are: WPL-2, WPL-14
[amanda@homsrv ~]$ amadmin wpl force localhost root
amadmin: localhost:root is set to a forced level 0 at next run.
[amanda@homsrv ~]$ amadmin wpl hosts
localhost
websrv.amanda
gateway.amanda
[amanda@homsrv ~]$ amadmin wpl dles
localhost root
localhost boot
localhost media
localhost vbox
localhost users
localhost home
websrv.amanda root
websrv.amanda boot
websrv.amanda www
gateway.amanda root
gateway.amanda boot
[amanda@homsrv ~]$ amadmin wpl find gateway.amanda root

date                host           disk lv tape or file file part status
2011-11-09 21:18:22 gateway.amanda root  0 WPL-8          11  1/1 OK
2011-11-09 21:30:22 gateway.amanda root  1 WPL-9           3  1/1 OK
2011-11-11 21:23:50 gateway.amanda root  1 WPL-1           3  1/1 OK
2011-11-12 14:16:50 gateway.amanda root  1 WPL-10          3  1/1 OK
2011-11-12 14:21:35 gateway.amanda root  1 WPL-11          3  1/1 OK
2011-11-12 19:56:26 gateway.amanda root  1 WPL-12          3  1/1 OK
2011-11-12 20:48:02 gateway.amanda root  1 WPL-13         10  1/1 OK
[amanda@homsrv ~]$

 

Amlabel.

If you need to add a new tape you must create a tape and label. The command is this:

[amanda@homsrv ~]$ mkdir /mnt/amanda/vtapes/wpl/slot21
[amanda@homsrv ~]$ amlabel wpl WPL-21 slot 21
Reading label...
Found an empty tape.
Writing label 'WPL-21'...
Checking label...
Success!
[amanda@homsrv ~]$

Remember to ajust the number of tapes in /etc/amanda/wpl/amanda.conf.

If a tape is corrupted for some reason, just relabel it but insert the -f option to force overwriting the tape contents. All tape image files are erased too so you have a real clean tape after this command.

 

Amrecover.

Amrecover browses the database of Amanda index files to determine which tapes contain files to recover. Furthermore, it is able to recover files. Note that I give the -h parameter to amrecover, what follows is the hostname that is in the disklist which in our case is different then the real hostname. If you don’t do this, inside amrecover you must use the sethost command. Amrecover does understand the help command.

A typical session to restore a the root partition on host websrv.amanda where the rout partition is mounted on tempdir:

[root@websrv ~]# cd tempdir
[root@websrv tempdir]# amrecover -h websrv.amanda
AMRECOVER Version 3.3.0.svn.4392. Contacting server on 10.126.164.1 ...
220 homsrv AMANDA index server (3.3.0.svn.4392) ready.
Setting restore date to today (2011-11-13)
200 Working date set to 2011-11-13.
200 Config set to wpl.
200 Dump host set to websrv.amanda.
Use the setdisk command to choose dump disk to recover
amrecover> setdisk root
200 Disk set to root.
amrecover> add *
Added dir /var/ at date 2011-11-13-15-50-36
Added dir /usr/ at date 2011-11-13-15-50-36
Added dir /tmp/ at date 2011-11-13-15-50-36
Added dir /sys/ at date 2011-11-13-15-50-36
Added dir /srv/ at date 2011-11-13-15-50-36
Added dir /sbin/ at date 2011-11-13-15-50-36
Added dir /run/ at date 2011-11-13-15-50-36
Added dir /root/ at date 2011-11-13-15-50-36
Added dir /proc/ at date 2011-11-13-15-50-36
Added dir /opt/ at date 2011-11-13-15-50-36
Added dir /mnt/ at date 2011-11-13-15-50-36
Added dir /media/ at date 2011-11-13-15-50-36
Added dir /lost+found/ at date 2011-11-13-15-50-36
Added dir /lib/ at date 2011-11-13-15-50-36
Added dir /home/ at date 2011-11-13-15-50-36
Added dir /etc/ at date 2011-11-13-15-50-36
Added dir /dev/ at date 2011-11-13-15-50-36
Added dir /boot/ at date 2011-11-13-15-50-36
Added dir /bin/ at date 2011-11-13-15-50-36
amrecover> extract

Extracting files using tape drive changer on host 10.126.164.1.
The following tapes are needed: WPL-14

Extracting files using tape drive changer on host 10.126.164.1.
Load tape WPL-14 now
Continue [?/Y/n/s/d]? y
Restoring files into directory /root/tempdir
All existing files in /root/tempdir can be deleted
Continue [?/Y/n]? y

set owner/mode for '.'? [yn] y
amrecover> exit
200 Good bye.
[root@websrv tempdir]# ls -la
total 84
drwxr-xr-x 21 root root 4096 Oct 16 15:48 .
drwxr-x---  5 root root 4096 Nov 13 16:14 ..
drwxr-xr-x  2 root root 4096 Nov  9 12:37 bin
drwxr-xr-x  2 root root 4096 Aug 13 21:06 boot
drwxr-xr-x  2 root root 4096 Aug 13 21:24 dev
drwxr-xr-x 41 root root 4096 Nov 13 15:15 etc
drwxr-xr-x  2 root root 4096 Oct 10 01:25 home
drwxr-xr-x 10 root root 4096 Nov 12 16:35 lib
drwx------  2 root root 4096 Aug 13 21:06 lost+found
drwxr-xr-x  2 root root 4096 Oct 10 01:25 media
drwxr-xr-x  2 root root 4096 Oct 10 01:25 mnt
drwxr-xr-x  2 root root 4096 Oct 10 01:25 opt
drwxr-xr-x  2 root root 4096 Aug 13 21:14 proc
drwxr-x---  4 root root 4096 Nov 13 15:49 root
drwxr-xr-x  2 root root 4096 Apr  8  2011 run
drwxr-xr-x  2 root root 4096 Nov 12 16:35 sbin
drwxr-xr-x  2 root root 4096 Aug 13 22:17 srv
drwxr-xr-x  2 root root 4096 Aug 13 21:14 sys
drwxrwxrwt  8 root root 4096 Aug 29 16:49 tmp
drwxr-xr-x 10 root root 4096 Nov 12 20:43 usr
drwxr-xr-x 14 root root 4096 Nov  9 19:48 var
[root@websrv tempdir]#

 

Now a session to restore a web server directory:

[root@websrv ~]# cd /srv/http/
[root@websrv http]# amrecover -h websrv.amanda
AMRECOVER Version 3.3.0.svn.4392. Contacting server on 10.126.164.1 ...
220 homsrv AMANDA index server (3.3.0.svn.4392) ready.
Setting restore date to today (2011-11-13)
200 Working date set to 2011-11-13.
200 Config set to wpl.
200 Dump host set to websrv.amanda.
Use the setdisk command to choose dump disk to recover
amrecover> setdisk www
200 Disk set to www.
amrecover> add server2
Added dir /server2/ at date 2011-11-12-20-48-02
Added dir /server2/ at date 2011-11-13-15-50-36
amrecover> extract

Extracting files using tape drive changer on host 10.126.164.1.
The following tapes are needed: WPL-13
                                WPL-14

Extracting files using tape drive changer on host 10.126.164.1.
Load tape WPL-13 now
Continue [?/Y/n/s/d]? y
Restoring files into directory /srv/http
All existing files in /srv/http can be deleted
Continue [?/Y/n]? y

./server2/
./server2/css/
./server2/index.shtml
./server2/robots.txt
./server2/css/style.css
Extracting files using tape drive changer on host 10.126.164.1.
Load tape WPL-14 now
Continue [?/Y/n/s/d]?  y
./server2/
./server2/css/
amrecover> exit
200 Good bye.
[root@websrv http]# ls -la server2
total 20
drwxr-xr-x 3 root root 4096 Aug 29 22:49 .
drwxr-xr-x 5 root root 4096 Nov 13 16:29 ..
drwxr-xr-x 2 root root 4096 Aug 29 22:29 css
-rw-r--r-- 1 root root 2234 Aug 29 22:49 index.shtml
-rw-r--r-- 1 root root   26 Aug 29 22:29 robots.txt
[root@websrv http]#

Note that when amrecover asks to load a tape, you only have to reply y, the tapeserver will load the right tape from the autochanger. A long, a very long time ago, you should have needed to do something on the tapehost, but this is just not needed anymore but the question is still in amrecover for those people that really need to load a physical tape.

 

Bare metal restore.

The biggest problem with a bare metal restore is to get the root partition back and from there start to rebuild the rest of the machine. and with the root partition you have amanda back too if that was installed in the root partition. You also need the level 0 and incremental dumps of the root filesystem. You can put these on DVD’s, USB sticks or use the whole virtual tape drive.

Important to know:

  • Amanda tape images can be processed with standard *nix tools.
  • The first 32 k bytes is a header and contains text data.
  • The rest is compressed or uncompressed tar or dump data.
  • Tape images can span over multiple tapes.

 

You need to know where your data is. For that reason the emails that my servers write are also copied to an external (gmail or so) mail account. From these mails you can see the history of your backups. This is only useful if you must restore the machine that hosts the amanda database.

Once you know on which tapes your backups are, watch out for backups that are split over more then one tape. In that case you better reassemble the backup into one single file before you proceed. We must get all image data, but skip the 32 k bytes headers. The procedure looks like this:

[root@mach1 ~]# dd if=<tapeimg1> bs=32k skip=1 > rootfile
[root@mach1 ~]# dd if=<tapeimg2> bs=32k skip=1 >> rootfile

 

Tape images that fit on a single tape can be used directly. Each tape image has some human readable text in the header, this is  very convenient for us because it shows the restore command that you need to extract the data:

[root@lx02 slot8]# dd if=00015.localhost.root.0 bs=32k count=1
AMANDA: SPLIT_FILE 20111113014501 localhost root  part 1/-1  lev 0 comp .
gz program /bin/tar
ORIGSIZE=4414700
DLE=<<ENDDLE
<dle>
  <program>GNUTAR</program>
  <disk>root</disk>
  <diskdevice>/</diskdevice>
  <level>0</level>
  <auth>bsdtcp</auth>
  <compress>FAST</compress>
  <record>YES</record>
  <index>YES</index>
  <datapath>AMANDA</datapath>
  <exclude>
    <file>./tmp*</file>
    <file>./var*</file>
  </exclude>
</dle>
ENDDLE
To restore, position tape at start of file and run:
        dd if=<tape> bs=32k skip=1 | /bin/gzip -dc | /bin/tar -xpGf - ... 

1+0 records in
1+0 records out
32768 bytes (33 kB) copied, 0.0623663 s, 525 kB/s
[root@lx02 slot8]#

The restore command shows that this is a gzipped tar archive. So using the information in the tape images, you don’t need amanda to restore data.

If you restore incremental tapes over a full dump, all changes will overwrite the older data, just take care that the order is correct. What you miss (or actually not) is deleted files, they are restored during the process and never deleted again. This can be a problem during restore if the destination filesystem is tight on space.

 

To find the root backups on host localhost  without the knowledge of the tape history:

[root@lx02 ~]# cd /mnt/amanda/vtapes/mbse/
[root@lx02 mbse]# ls -lart slot*/*.localhost.root.*
-rw------- 1 amanda amanda 2147516416 Nov  1 02:05 slot9/00017.localhost.root.0
-rw------- 1 amanda amanda  665480323 Nov  1 02:05 slot9/00018.localhost.root.0
-rw------- 1 amanda amanda   32435119 Nov  2 02:04 slot11/00015.localhost.root.1
-rw------- 1 amanda amanda   56159447 Nov  3 01:54 slot13/00014.localhost.root.1
-rw------- 1 amanda amanda 2147516416 Nov  4 02:13 slot15/00019.localhost.root.0
-rw------- 1 amanda amanda  683330863 Nov  4 02:14 slot15/00020.localhost.root.0
-rw------- 1 amanda amanda 2147516416 Nov  5 02:11 slot17/00017.localhost.root.0
-rw------- 1 amanda amanda  687947096 Nov  5 02:11 slot17/00018.localhost.root.0
-rw------- 1 amanda amanda   86410078 Nov  6 02:05 slot19/00016.localhost.root.1
-rw------- 1 amanda amanda 2147516416 Nov  7 02:14 slot21/00019.localhost.root.0
-rw------- 1 amanda amanda  687769792 Nov  7 02:14 slot21/00020.localhost.root.0
-rw------- 1 amanda amanda 2147516416 Nov  8 02:10 slot1/00017.localhost.root.0
-rw------- 1 amanda amanda  688154575 Nov  8 02:10 slot1/00018.localhost.root.0
-rw------- 1 amanda amanda   20199623 Nov  9 01:49 slot3/00015.localhost.root.1
-rw------- 1 amanda amanda   20115396 Nov 10 01:49 slot4/00014.localhost.root.1
-rw------- 1 amanda amanda   19941096 Nov 11 01:56 slot6/00017.localhost.root.1
-rw------- 1 amanda amanda   28965941 Nov 12 01:49 slot7/00015.localhost.root.1
-rw------- 1 amanda amanda 2835566020 Nov 13 02:12 slot8/00015.localhost.root.0
[root@lx02 mbse]#

 

It doesn’t hurt to practice this once, better safe then sorry.

 

Caveats.

When you made a backup using dump on a system that has the dump program on a different location then on the machine where you restore that backup, it doesn’t work with amrecover. This is because in the archive header is the path hard-coded to the dump program that was used to make the backup. It looks like this:

AMANDA: SPLIT_FILE 20121202014501 localhost root  part 1/-1  lev 0 comp .gz pro
gram /sbin/dump
ORIGSIZE=5605120
DLE=<<ENDDLE
<dle>
  <program>DUMP</program>
  <disk>root</disk>
  <diskdevice>/</diskdevice>
  <level>0</level>
  <auth>bsdtcp</auth>
  <compress>FAST</compress>
  <record>YES</record>
  <index>YES</index>
  <datapath>AMANDA</datapath>
</dle>
ENDDLE
To restore, position tape at start of file and run:
   dd if=<tape> bs=32k skip=1 | /usr/bin/gzip -dc | /sbin/restore -xpGf - ...

 

When on the target system dump is /usr/sbin/dump the amrecover program complains and doesn’t work. You can restore using the correct path, or make a copy of the dump and restore (yes, both) programs to the right location. But lookout, recently tar packages also have a restore program that can be overwritten by this action.