#!/usr/local/bin/bash # Amflush made easier. A simple script to work with amanda. # Written from scratch by Michael Dosser ############################################################################### # Please adjust this to your needs! # ############################################################################### # Very important: We suppose that your labeling of the tapes is in this format: # configurationname-xxyyzz # where xx is the year (e.g. 01 for 2001), yy the month and zz the day. # If this is not true for you you'll have to adjust the script below the # not-change-anything line ;-) # Amanda configuration file location: location="/usr/local/etc/amanda" # Who is your amanda user? amandauser="operator" # Where is your system password file? passwdfile="/etc/passwd" # Where is your holding disk location? dumpdir="/mnt/amanda/hold" ############################################################################### # Don't change anything below here, unless you know what you do # ############################################################################### whoami=`whoami` if [ "$whoami" != "root" ] then echo "You are not root, so you cannot execute this program!" exit 1 fi echo echo "+---------------------------------------------------------------------+" echo "| This script will dump the specified host from disk to tape. |" echo "| Please answer the following questions correctly ... |" echo "+---------------------------------------------------------------------+" echo testamuser=`grep $amandauser $passwdfile 1> /dev/null 2> /dev/null; echo $?` if [ "$testamuser" = "1" ] then echo "Sorry. Your amandauser variable or your passwd file location is not set correctly." echo "Please adjust this script." echo exit 1 elif [ "$testamuser" = "0" ] then echo "We assume that $amandauser is your amandauser." fi if [ ! -d $location ] then echo "Sorry. Your amanda configuration location is not set correctly." echo "Please adjust this script!" echo exit 1 else echo "Hm. your amanda configuration location seems to be $location." fi echo "Is this true? Answer with yes or no!" echo read question echo if [ "$question" = "yes" ] then echo "Good. Let's go on ..." echo elif [ "$question" = "no" ] then echo "Well, then adjust your settings." echo exit 1 else echo "You did not answer correctly." echo exit 1 fi # ipcrm.pl 1> /dev/null 2> /dev/null echo "Which machine do you want to backup? Give the configuration name!" echo "Here are the configuration files you have created:" for i in `ls $location` do if [ -d $location/$i ] then echo $i fi done echo read confname echo for i in `ls $location` do if [ $confname = $i ] then testval=0 echo "Good. $confname matches the configuration." echo fi done if [ "$testval" != "0" ] then echo "Bad. You have set the wrong configuration name. We are exiting." echo exit 1 fi echo "What date you want to give the tape? E.g. 010303 for the 3. march 2001." echo read tapedate echo case $tapedate in [0123456789][0123456789][0123456789][0123456789][0123456789][0123456789]) echo "Good. The date matches your needs." echo echo "We are going to label the tape with $confname-$tapedate" su $amandauser -c "amlabel $confname $confname-$tapedate" echo "These are the files you could dump to your tape:" echo for i in `ls $dumpdir` do cd $dumpdir/$i echo "---" echo "In $i there are the following files:" du -sk * | grep $confname done echo echo "Do you want to procedure? Answer with yes or no" read proced echo if [ "$proced" = "yes" ] then echo "Good. Let's go on." echo elif [ "$proced" = "no" ] then echo "O.k. we stop here." echo exit 0 else echo "You gave me the wrong answer. We are exiting." echo exit 1 fi su $amandauser -c "amflush $confname" ;; *) echo "Sorry. This is not the right format. Use six digits in consequence." exit 1 ;; esac