Amanda-Users

Draft of a shell-script for backing up AMANDA-metadata

2005-09-12 15:10:21
Subject: Draft of a shell-script for backing up AMANDA-metadata
From: "Stefan G. Weichinger" <sgw AT amanda DOT org>
To: amanda-users <amanda-users AT amanda DOT org>
Date: Mon, 12 Sep 2005 20:57:57 +0200

I once wrote about a small shellscript that I use to back up AMANDA-metadata and have received some requests to provide it here.

At last I have found some time to translate it to english and add some small notes. I use this script regularly in some client-setups by wrapping it into rundump.sh (which is triggered by cron).

The idea is to run amdump first, after that generate tarballs of the current configs, indexes etc. These tarballs can then be synced somewhere else, sent by mail or simply kept for reference (although it is recommended to get them off your AMANDA-server ...)

The script am_meta_bkp.sh is far from being perfect, but it is a draft that works pretty well for me. The scripts were written on a Suse-Linux-system and uses linux-specific paths etc.

Feel free to add comments and patches.

I will also add this script and its mutations to the AMANDA-patches page, if noone flames me for bad scripting ;-)

Greets, Stefan.


-------------------------------------------------------------------------
rundump.sh
-------------------------------------------------------------------------
/usr/local/sbin/amdump daily && /usr/bin/mt -f /dev/st0 offl && sleep 5 && /opt/oops/bin/am_meta_bkp.sh


-------------------------------------------------------------------------
am_meta_bkp.sh
-------------------------------------------------------------------------

#!/bin/bash
#
# am_meta_bkp.sh
#
# v0.2 September, 12th, 2005:   translation
#
# v0.1 April, 22nd, 2005:       first draft
#
# Stefan G. Weichinger, sgw AT amanda DOT org
#
# This script backs up AMANDA-metadata like indexes and config-files.
# It creates files in the directory TARGETPATH, the filenames start with
# the string HEADER_STRING, this string contains the timestamp TIMESTAMP.
# The files backed up belong to the AMANDA-configuration CONFIG, for
# proper reading of the relevant parameters it is necessary to provide
# the correct username AMUSER of the AMANDA-user.
# Backup-files older than 7 days are removed.
#
# Backed up files:
# - curinfo-DB
# - index-DB
# - config-dir (eg. /usr/local/etc/amanda/daily)
# - logfiles
#

PATH=/bin:/opt/oops/bin:/usr/local/sbin:/usr/bin
TARGETPATH=/backup/AMANDA-Meta

# adjust this string as necessary.
TIMESTAMP=`date +%Y-%m-%d--%Hh%M`

# AMANDA-config to back up. Could also be $1 ...
CONFIG=daily
AMUSER=amanda

# headerstring
# ATTENTION: If you edit this, you also have to edit the match in the
# find-command below!

HEADER_STRING=$TIMESTAMP-AM-$CONFIG

# reads parameters from amanda.conf
LOGDIR=`/usr/local/sbin/amgetconf $CONFIG logdir`
INDEXDIR=`/usr/local/sbin/amgetconf $CONFIG indexdir`

if [[ -d $TARGETPATH ]] ; then

# exports the curinfo-DB

/usr/local/sbin/amadmin $CONFIG export > $TARGETPATH/$HEADER_STRING.curinfo

# packs indices, logs and configs into TARGETPATH, with timestamp TIMESTAMP
# Decide yourself if you want the logs also.

 tar -cpzsf $TARGETPATH/$HEADER_STRING.indices.tar.gz $INDEXDIR
 tar -cpzsf $TARGETPATH/$HEADER_STRING.logs.tar.gz $LOGDIR

# packs the config
tar -cpzsf $TARGETPATH/$HEADER_STRING.config.tar.gz /usr/local/etc/amanda/$CONFIG

# delete archives after 7 days.
# ATTENTION: Make sure that this find fits $HEADER_STRING up there ...

find $TARGETPATH -type f -name "*AM-$CONFIG*" -mtime +7 -print0 | xargs --null --no-run-if-empty rm -f

else
 echo "ERROR: target-path $TARGETPATH does not exist!"
 exit 1
fi

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

--
Stefan G. Weichinger
AMANDA core team member
mailto://sgw AT amanda DOT org
--
oops! linux consulting & implementation
http://www.oops.co.at
--

<Prev in Thread] Current Thread [Next in Thread>
  • Draft of a shell-script for backing up AMANDA-metadata, Stefan G. Weichinger <=