Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Webcast-Catalyst9k
New Member

Backup FWSM and ASASM contexts for dummies

Because Prime or LMS has no ability to backup FWSM and ASASM configurations, here I share our trick to do "backups" from a remote linux server.

FAckup.sh stands for FWSM-and-ASASM-backup :-) It uses ASDM stuffs to get configs.

Configuration file looks like this :

10.11.12.13;system

10.11.12.13;admin

10.11.12.13;myContext1

10.11.12.13;myContext2

...

 

And the script :

[root@CiscoTricks]# cat FAckup.sh
#!/bin/sh

CONFIG=FAckup.cfg
SHORTdate=`date +%F_%H-%M`
HADERROR=false
ERRLETTER=error.letter

mkdir $SHORTdate

echo -n "Please wait, FAckup in progress ."

for i in `cat $CONFIG`; do
        echo -n "."
        MODULE=`echo $i | cut -d";" -f1`
        CONTEXT=`echo $i | cut -d";" -f2`
        LONGdate=`date +%F_%H-%M-%S`
        if wget -q --no-check-certificate --user=my_user_name --password=my_password  https://$MODULE/admin/exec/changeto%20context%20$CONTEXT/show%20running-config/$MODULE.$CONTEXT.$LONGdate; then
                mv $MODULE.$CONTEXT.$LONGdate $SHORTdate/
        else
                HADERROR=true
        fi
        echo -n "."
done

if $HADERROR;then
        echo " finished, with at least one error."
        ERRMSG=`echo "FAckup is running on host : " && hostname`
        echo $ERRMSG > $ERRLETTER
        ERRMSG=`echo "FAckup is working in directory : " && pwd`
        echo $ERRMSG >> $ERRLETTER
        ERRMSG=`echo "FAckup is working for date : $SHORTdate"`
        echo $ERRMSG >> $ERRLETTER
        mail -s "FAckup ERROR !" my.email@my.domain < $ERRLETTER
else
        echo " finished, without error."
        ERRMSG=`echo "May the Force be with you ..."`
        echo $ERRMSG > $ERRLETTER
        echo "" >> $ERRLETTER
        mail -s "FAckup SUCCESS !" my.email@my.domain < $ERRLETTER
fi
rm -f $ERRLETTER

echo "FAckup is now compressing result files ..."

LONGdate=`date +%F_%H-%M-%S`
tar zcvf $LONGdate.tar.gz $SHORTdate/
rm -rf $SHORTdate

echo "FAckup housekeeping, done."

if $HADERROR;then
        exit 2
fi

If you have suggestions to enhance script, do not hesitate to post !

Fred

Everyone's tags (1)
147
Views
0
Helpful
0
Replies
CreatePlease to create content