On the care and feeding of amrestore

amrestore is the older, less interactive utility for file recovery that is best suited to recovering a whole filesystem, and in any case is required if the recover program needed by amrecover is not available on the backup server (eg for solaris clients).

Here is n annotated typescript showing the use of amrecover.

  1. Find out which server and filesystem the target files were backed up from. The easiest way is to use df, noting that the underlying device name is needed (starts /dev/), not an NFS export name (normally starts /export/).
    Script started on Thu May 30 16:52:43 2002
    [root@bilsdale tmp]# ssh pontop "df -k /export/www.people"
    root@pontop's password: 
    Filesystem            kbytes    used   avail capacity  Mounted on
    /dev/dsk/c0t2d0s1    1651541 1264948  221439    86%    /export/www.people
    
  2. On the backup server, locate the tape(s) containing the target files.
    [root@bilsdale tmp]# su - operator # run this as operator
    sh-2.04$ amadmin ncl find pontop c0t2d0s1
    Scanning /var/spool/amanda2...
      lost+found: skipping cruft directory, perhaps you should delete it.
    Scanning /var/spool/amanda...
      lost+found: skipping cruft directory, perhaps you should delete it.
      ncrr: skipping cruft directory, perhaps you should delete it.
    
    date       host   disk     lv tape or file file status
    ....
    2002-05-21 pontop c0t2d0s1  0 byerhope37     80 OK
    2002-05-22 pontop c0t2d0s1  1 byerhope38     33 OK
    ....
    sh-2.04$ logout # back to root user
    
  3. Locate the tapes required, and place them in the autoloader noting which tape is in which slot. A good way of working is to place the tapes required in slots 1 .. n and to leave the remaining slots containing the tapes needed for the next backup. This avoids the need for an extra trip to the macine room.

    To be on the safe side, take the current tape offline and force it back into its slot in the autoloader, then load the required tape with amtape:-

    [root@bilsdale tmp]# su - operator # run this as operator
    sh-2.04$ mt -f /dev/nst0 rewoffl
    /dev/nst0: Input/output error
    sh-2.04$ mtx -f /dev/sg2 unload
    Unloading Data Transfer Element into Storage Element 7...done
    sh-2.04$ amtape ncl slot 7
    amtape: changed to slot 7 on /dev/nst0
    sh-2.04$ logout # back to root user
    
  4. Ensure that your working directory contains enough space for a restored backup image (the holding paritition /var/spool/amanda is a good choice) and restore the backup image.:-
    [root@bilsdale amanda]# PATH=/usr/local/amanda/current/sbin:$PATH
    [root@bilsdale amanda]# export PATH
    [root@bilsdale amanda]# amrestore /dev/nst0 pontop c0t2d0s1
    amrestore:   0: skipping start of tape: date 20020412 label byerhope10
    ...
    amrestore:  75: restoring pontop.c0t2d0s1.20020412.0
    ...
    amrestore:  91: reached end of tape: date 20020412
    

    For large filesystems, it may be nessary to use the split command as well:-

    amrestore -p /dev/nst0 pontop c0t2d0s1 | split --bytes=2000m - pontop.c0t2d0s1.
    
  5. Run an interactive restore in the dump image in the staging partition. Catenate the results of using split if needed (not shown here):-
    [root@bilsdale amanda]# /sbin/restore ifv pontop.c0t2d0s1.20020412.0 
    Verify tape and initialize maps
    Tape block size is 32
    Note: Doing Byte swapping
    Dump   date: Sat Apr 13 00:25:33 2002
    Dumped from: the epoch
    Level 0 dump of /export/www.people on pontop:/dev/dsk/c0t2d0s1
    Label: none
    Note: Doing Quad swapping
    Extract directories from tape
    Initialize symbol table.
    /sbin/restore > ls
    ...
    233553 a.user/                  495937 another.user/
    ...
    /sbin/restore > cd a.user
    /sbin/restore > ls
    ./c.r.ritson:
    233553 ./             250632 cgi-bin/       484162 home.informal/
         2 ../            478466 home.formal/   233542 index.html 
    233546 .AppleDouble/  233567 home.info      233684 index.html- 
    478489 MOMexcludes    233807 home.info- 
    
    /sbin/restore > add home.formal
    Make node ./a.user
    Make node ./a.user/home.formal
    ...
    /sbin/restore > extract
    Extract requested files
    You have not read any tapes yet.
    Unless you know which volume your file(s) are on you should start
    with the last volume and work towards the first.
    Specify next volume #: 1
    ...
    extract file ./a.user/home.formal/index.html
    ...
    Add links
    Set directory mode, owner, and times.
    set owner/mode for '.'? [yn] n
    /sbin/restore > quit
    
  6. Lastly, run amcheck to ensure the correct tape is loaded ready for the next nightly backup. Change the tapes in the autoloader if needed.
    [root@bilsdale amanda]# su - operator
    sh-2.04$ amcheck -s ncl
    Amanda Tape Server Host Check
    -----------------------------
    Holding disk /var/spool/amanda2: 6971800 KB disk space available, using 6255000 KB
    Holding disk /var/spool/amanda: 32030448 KB disk space available, using 28884720 KB
    amcheck-server: slot 7: date 20020412 label byerhope10 (active tape)
    amcheck-server: slot 1: date 20020404 label byerhope04 (exact label match)
    NOTE: skipping tape-writable test
    Tape byerhope04 label ok
    Server check took 170.367 seconds
    
    (brought to you by Amanda 2.4.2p2)
    sh-2.04$ logout
    [root@bilsdale amanda]# 
    Script done on Thu May 30 17:45:22 2002
    

    C.R.Ritson@newcastle.ac.uk
    10 June 2002