re: "have you thought about rsync" -- that's been mentioned in previous posts in this thread. Those of us who have posted our own methods prefer something that gives us multiple backups and not just a single sync. In principle, rsync can do that sort of thing too (the classic rsync incrementals based on hard links), but the amount of data involved in backing up the metadata is small enough that rsync is no big advantage. gtar, cpio, or just cp or scp in an appropriate script work as well.

---

Since I've made a few changes since I last posted my scripts, I thought I would post them again. I've moved my cron entries from the amanda user to the root user so that I can tack other scripts on the same line and have them run sequentially. When the amdump is completed, it goes to the metadata backup. When the metadata backup is completed, it goes to the tape unload. And, I don't have to script in any wait. They just run after the preceding thing on the cron line is completed.

amchanger is a short script I wrote to incorporate the path to mtx, the path to the tape library device, and the configuration for Amanda. So, I can just call amchanger with the configuraton and the command I want to issue. I often use it with `amchanger daily status` to check what tapes are in the library. In the cron entries I use it with the full path and unload. Anyway, the script is below. It works on all my amanda servers without modification for the specifics of the server (the tape library often ends up on a different scsi device).

I began using amchanger unload in the cron after about the third time I had to disassemble a library, remove the drive, and manually wind out the tape. This situation would occur when a thunderstorm induced power outage lasted too long for the UPS and dropped power suddenly to the tape library. It turns out there is no way of preparing the tape library for that other than doing the unload. Although I have nut running, tape drives are unresponsive enough that if it is actually backing up, it won't respond quickly enough to unload in a power outage before the UPS runs out. So, by unloading the tape whenever it is not in use, I at least significantly reduce my exposure to afternoon and evening thunderstorms.

daily-amanda-config is my script to back up the metadata. The backup is three-fold. First, it backs up to a different drive on the same server. Then it tars that up and scp's it over to another server. I have a separate set of keys for doing these backups which are restricted in the authorized_keys file on the other server to only allow this one use. On the other server, these metadata backups are in the amanda home directory and get backed up to tape by amanda. So I end up having two copies on separate disks on this server, one copy on disk on another server, and copies on tape from both this server and the other server. Similar backups are done for each of the amanda servers. In each case the scp is going to a server in another building.

----

following are my root cron entries for amanda on one of my servers:

0 15 * * 1-5 su - amanda -c "/usr/local/sbin/amcheck -m daily" > /dev/null; /usr/local/bin/amchanger daily unload > /dev/null 2>&1

45 22 * * 1-5 su - amanda -c "/usr/local/sbin/amdump daily" > /dev/null; /usr/local/adm/backup/daily-amanda-config; /usr/local/bin/amchanger daily unload

45 0 * * 0-1 su - amanda -c "/usr/local/sbin/amdump daily -o reserve=100 -o tapedev=\"\" -o tpchanger=\"\"" > /dev/null; /usr/local/adm/backup/daily-amanda-config

----

following is my daily-amanda-config backup script. It's actually a slightly more general script that I use in other applications as well. I could probably change it further and just do a full every day. It doesn't use that much space on this server.

#!/bin/ksh
#
# Daily-amanda backup script - copies critical amanda configuration and indexes.
# Based on Daily-office backup script copied from marlin 04/24/2007 Chris H.
#
# Script used for daily archives of particular directories to /archive
# (which is a separate partition on a different drive).
#
# Tape backups then catch all this, of course.
#
# ---------------------------------------------------

# CAREFUL -- basename must be unique for all these!
DIRLIST="/usr/local/etc/amanda";
ARCH=/archive;
DAY=`date '+%a'`;

# set archive partition to read/write (it is normally mounted read only)
mount -o remount,rw,logging ${ARCH};

case "$DAY" in
  Sun|Mon|Tue|Wed|Thu|Fri)
    echo "\nDaily incremental backup of Amanda configuration and indexes for 
Biology";
    echo 
"------------------------------------------------------------------------\n";;
  Sat)
    echo "\nSaturday full backup of Amanda configuration and indexes for 
Biology";
    echo 
"--------------------------------------------------------------------\n";;
esac

for DIR in ${DIRLIST}
do
  BASE=`basename ${DIR}`;
  ADIR=${ARCH}/${BASE}/${DAY};
  if cd ${ADIR} ; then
    if cd ${DIR} ; then
      /usr/ucb/echo -n "Backing up ${DIR} to ${ADIR}:   ";
      case "$DAY" in
#      # removed the 3 day incremental and added Sun,Mon,Tue to 1 day 
incrementals
#      # Chris H. 7/11/2007
#      Tue)
#        # delete previous contents and then do incrementals from Saturday
#        rm -r ${ADIR}; mkdir ${ADIR};
#        find . -mtime -3 | cpio -oa 2>/dev/null | ( cd ${ADIR} && cpio -imd );;
      Sun|Mon|Tue|Wed|Thu|Fri)
        # delete previous contents and then do incrementals
        rm -r ${ADIR}; mkdir ${ADIR};
        find . -mtime -1 | cpio -oa 2>/dev/null | ( cd ${ADIR} && cpio -imd );;
      Sat)
        # delete previous contents and then do full copies
        rm -r ${ADIR}; mkdir ${ADIR};
        find . | cpio -oa 2>/dev/null | ( cd ${ADIR} && cpio -imd );;
      *)
        echo "Wha? DAY=\"${DAY}\" in mormyrid daily amanda chron.";;
      esac
    else
      echo "Wha? unable to cd to ${DIR} in mormyrid daily amanda chron.";
    fi
  else
    echo "Wha? unable to cd to ${ADIR} in mormyrid daily amanda chron.";
  fi
done

echo "\n";
df -k ${ARCH};

# tar it up & send it to marlin
cd ${ARCH};
echo "\n\nMaking tar file of ${ARCH}/amanda/${DAY}/";
tar -cf amanda-${DAY}.tar amanda/${DAY};
rm amanda-${DAY}.tar.gz;
gzip amanda-${DAY}.tar;
chown amanda:amanda amanda-${DAY}.tar.gz;
echo "\nscp'ing amanda-${DAY}.tar.gz to marlin:/usr/local/etc/amanda/mormyrid/";
# note: in the script the following is all one line. I broke it up to avoid 
line wrap in the email.
su - amanda -c "scp -i /usr/local/etc/amanda/.ssh/id_rsa_dailyconfig -o \
    BatchMode=yes \
    ${ARCH}/amanda-${DAY}.tar.gz \
    marlin.bio.mor.nsm:/usr/local/etc/amanda/mormyrid/" \
> /dev/null;
echo "";

# for some reason, Solaris 9 doesn't allow `mount -o remount,ro /mountpoint`
# set it back to read only with umount and then mount with the -r option.
# unfortunately, the umount could fail if someone has a process in that 
directory.
# that won't hurt the backups, but could leave the partition in rw mode.
cd /;
umount ${ARCH};
mount -r ${ARCH};
# done.

----

following is my amchanger script. Maybe some others with multiple amanda servers and tape libraries will find this useful.

#!/bin/ksh
#
# amchanger
# simple script to get around having to remember full paths to mtx and tape 
library device.
#    Chris H., 9/13/2010

PATHTOMTX=/usr/local/sbin/mtx;
AMHOME=/usr/local/etc/amanda/

if (( $# < 2 )); then
  echo "usage: amchanger CONF paramaters";
else
  CONF=$1;
  CONFIGDIR=${AMHOME}${CONF};
  CONFIGFILE=${CONFIGDIR}/amanda.conf
  if [[ ! -d ${CONFIGDIR} ]]; then
    echo "${CONF} does not indicate an Amanda configuration directory.";
    echo "usage: amchanger CONF parameters";
  else
    if [[ ! -f ${CONFIGFILE} ]]; then
      echo "There is no amanda.conf in ${CONFIGDIR}.";
      echo "usage: amchanger CONF parameters";
    else
      PATHTODEV=`grep '^changerdev' ${CONFIGFILE} | awk '{ print $2 }' | tr -d 
'"'`;
      shift;
      ARGS=$@;
      ${PATHTOMTX} -f ${PATHTODEV} ${ARGS};
    fi
  fi
fi

----

That's it.

One way of doing things.


--
---------------

Chris Hoogendyk

-
   O__  ---- Systems Administrator
  c/ /'_ --- Biology&  Geology Departments
 (*) \(*) -- 140 Morrill Science Center
~~~~~~~~~~ - University of Massachusetts, Amherst

<[email protected]>

---------------

Erdös 4




On 8/23/11 11:18 AM, McGraw, Robert P wrote:

Have you considered doing an rsync of your amanda home directory and /var/amanda directories to another disk on another machine.

You could set this up to run after you back is complete.

*From:*[email protected] [mailto:[email protected]] *On 
Behalf Of *Alden Timme
*Sent:* Monday, August 22, 2011 2:59 PM
*To:* [email protected]
*Subject:* Re: Recovering Metadata from Tape?

Great! Thanks for the responses - sorry I didn't see the archived conversations.

Alden

2011/8/22 gene heskett <[email protected] <mailto:[email protected]>>

On Monday, August 22, 2011 02:22:01 PM Alden Timme did opine:


> Hi all,
>
> I am using a tape library to do my Amanda backups, but I have run into
> one issue - restoring my Amanda system in the case that my Amanda
> server goes down.
>
> Even if I have my amanda.conf file, there is a lot of metadata I need to
> be able to run a successful amrestore or amrecover. My questions are
>
> (1) What files do I need exactly?
>
> (2) How do I retrieve/recover all of those files from the tapes
> themselves?
>
> For (1), I think I need at least
> * $CONFIGDIR/$config/amanda.conf
> * $CONFIGDIR/$config/tapelist
> * $PREFIX/var/amanda/chg-robot-dev-sg4 (file that holds my current tape
> changer's status)
> * infofile
> * indexdir
>
> but for (2) I don't know how to recover all those files.
>
> I have been able to do a little bit of the retrieval/recovery with
> amtape update, but that doesn't get me everything I need to use
> amrestore/amrecover effectively.
>
> I've looked around a lot in the forums/archives/how-tos but haven't
> found an answer for this question - which I assume is a fairly common
> issue. Apologies if I simply haven't found the documentation - in that
> case a link would be sufficient :)
>
> Thanks in advance!
> Alden

This is one of those 'bare metal' questions, and there have been 2 or 3
offerings in that regard, I rather like my own solution to that problem.
It is a wrapper script that depends on your having a tape descriptor with a
500 meg and up, cushion so that amanda will never fill the tape, but will
leave a bit of room for the wrapper scripts files.

The wrapper script adds to the end of the tape, a tarball of the current
configuration tree, and a tarball of the database tree.

It looks something like this on a vtape:
[root@coyote gene]# ls -l /amandatapes/Dailys/slot20
total 27352256
-rw------- 1 amanda amanda       32768 Aug 22 00:50 00000.Dailys-20
-rw------- 1 amanda amanda 25698360714 Aug 22 01:05 00001.coyote._home.0
[... long dle list of files]
-rw------- 1 amanda amanda   856391680 Aug 22 01:16
00040.coyote._usr_share.0
-rw-r--r-- 1 amanda amanda      102400 Aug 22 02:53 configuration.tar
-rw-r--r-- 1 amanda amanda   193904640 Aug 22 02:53 indices.tar

The version available isn't exactly the latest, but a good scripter can
adjust to suit.  Google for GenesAmandaHelper-0.6.

I probably need to repack it and put in on my web page.  I will freely
admit its a poor bash hack, but I have been using it here for several years
now.

I have assumed that disaster recovery is a new install and that you've
enough tools available in that install to recover from the tape directly,
dd, tar and gzip cover that.

Assume then that you use these tools to recover the indices.tar and place
its contents where they now reside, as step one.
Step 2 would be to recover, again using dd and tar, the configuration.tar
file and put it where it resided before the crash.
Step 3 then is to recover the user tree where amanda was built and
installed from, in my case the /home tree since I build and install amanda
as the user amanda.  You will need to adduser, and groupadd, the user who
ran amanda, unpack these files to tmp and do as root, a chown -R on those
two trees in /tmp before the wholesale copying is done.

In my case I would cd to /home/amanda/amanda-version and do a "make
install".  At that point, mkdir your holding disk area and chown it so
amanda can use it.  You should then have an amanda install that passes an
amcheck $configname, as that amanda user, or get errors telling you what is
missing yet.  Once that's done, amrecover should let you recover the rest
of your data.  I have done that several times here & there has always been
something I forget since at my years I really don't remember some of the
details.  But this really does help me...

Cheers, gene
--
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Being a BALD HERO is almost as FESTIVE as a TATTOOED KNOCKWURST.


Reply via email to