Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

automatic backup of catalyst 6500

Hey!

i have a EEM script that backups the running conf when entering command "write memory" to ftp server.

How can i modify it, that it would'nt copy the file over and over. Instead it would make the conf file with diffrent name or date.

Any ideas?

4 REPLIES
Silver

Re: automatic backup of catalyst 6500

You can have the EEM script append the current data and time to file name whenever a "write memory" is given so that every time a file with a different name will be created. Another workaround would be to manually rename or move the file after entering command "write memory".

New Member

Re: automatic backup of catalyst 6500

Yep, at the moment cron changes the filename after it has been copied to backup server

Re: automatic backup of catalyst 6500

HI karblane1,

This is Interesting.

Can you Please Provide me the Complete EEM Script you are Using.

Thanks in Advance for Help

Best Regards,

Guru Prasad R

Re: automatic backup of catalyst 6500

hi,

we use a simple shel script, like this :

#!/bin/bash

umask 022

export DIR=/netmgmt

export ID=$$

export ROUTER=${1}

export DATEDIR=`/bin/date -I`

export COMMUNITY=${2}

export SNMPSET="/usr/bin/snmpset -m CISCO-CONFIG-COPY-MIB -v 2c -t 500"

export SNMPGET="/usr/bin/snmpget -m CISCO-CONFIG-COPY-MIB -v 2c -Ovque"

export SNMPWALK="/usr/bin/snmpwalk -m CISCO-CONFIG-COPY-MIB -v 2c"

export TFTPDIR=/tftpboot

#Write memory

echo "`date` $ROUTER:write memory" >> $DIR/log_backup/log-${DATEDIR}

${SNMPSET} -c ${COMMUNITY} ${ROUTER} .1.3.6.1.4.1.9.9.96.1.1.1.1.2.${ID} i 1 >> $DIR/log_backup/log-${DATEDIR}

${SNMPSET} -c ${COMMUNITY} ${ROUTER} .1.3.6.1.4.1.9.9.96.1.1.1.1.3.${ID} i 4 >> $DIR/log_backup/log-${DATEDIR}

${SNMPSET} -c ${COMMUNITY} ${ROUTER} .1.3.6.1.4.1.9.9.96.1.1.1.1.4.${ID} i 3 >> $DIR/log_backup/log-${DATEDIR}

#Start writitng

${SNMPSET} -c ${COMMUNITY} ${ROUTER} .1.3.6.1.4.1.9.9.96.1.1.1.1.14.${ID} i 1 >> $DIR/log_backup/log-${DATEDIR}

#Destroy MIB

OUT=`${SNMPGET} -c ${COMMUNITY} ${ROUTER} ccCopyState.${ID}`

while [ $OUT == 2 ]

do

OUT=`${SNMPGET} -c ${COMMUNITY} ${ROUTER} ccCopyState.${ID}`

done

${SNMPWALK} -c ${COMMUNITY} ${ROUTER} ccCopyState >> $DIR/log_backup/log-${DATEDIR}

if [ $OUT != 3 ]

then

echo -n "`date` ERROR: " >> $DIR/log_backup/log-${DATEDIR}

${SNMPWALK} -c ${COMMUNITY} ${ROUTER} ccCopyFailCause.${ID} >> $DIR/log_backup/log-${DATEDIR}

fi

${SNMPSET} -c ${COMMUNITY} ${ROUTER} .1.3.6.1.4.1.9.9.96.1.1.1.1.14.${ID} i 6 >> $DIR/log_backup/log-${DATEDIR}

#copyto TFTP

/usr/bin/touch ${TFTPDIR}/${ROUTER}

/bin/chmod 777 ${TFTPDIR}/${ROUTER}

#Prepare MIB

echo "`date` $ROUTER:copy startup tftp" >> $DIR/log_backup/log-${DATEDIR}

${SNMPSET} -c ${COMMUNITY} ${ROUTER} .1.3.6.1.4.1.9.9.96.1.1.1.1.2.${ID} i 1 >> $DIR/log_backup/log-${DATEDIR}

${SNMPSET} -c ${COMMUNITY} ${ROUTER} .1.3.6.1.4.1.9.9.96.1.1.1.1.3.${ID} i 4 >> $DIR/log_backup/log-${DATEDIR}

${SNMPSET} -c ${COMMUNITY} ${ROUTER} .1.3.6.1.4.1.9.9.96.1.1.1.1.4.${ID} i 1 >> $DIR/log_backup/log-${DATEDIR}

${SNMPSET} -c ${COMMUNITY} ${ROUTER} .1.3.6.1.4.1.9.9.96.1.1.1.1.5.${ID} a "172.18.253.47" >> $DIR/log_backup/log-${DATEDIR}

${SNMPSET} -c ${COMMUNITY} ${ROUTER} .1.3.6.1.4.1.9.9.96.1.1.1.1.6.${ID} s "${TFTPDIR}/${ROUTER}" >> $DIR/log_backup/log-${DATEDIR}

#Start writitng

${SNMPSET} -c ${COMMUNITY} ${ROUTER} .1.3.6.1.4.1.9.9.96.1.1.1.1.14.${ID} i 1 >> $DIR/log_backup/log-${DATEDIR}

#Destroy MIB

OUT=`${SNMPGET} -c ${COMMUNITY} ${ROUTER} ccCopyState.${ID}`

while [ $OUT == 2 ]

do

sleep 1

OUT=`${SNMPGET} -c ${COMMUNITY} ${ROUTER} ccCopyState.${ID}`

done

${SNMPWALK} -c ${COMMUNITY} ${ROUTER} ccCopyState >> $DIR/log_backup/log-${DATEDIR}

if [ $OUT != 3 ]

then

echo -n "`date` ERROR: " >> $DIR/log_backup/log-${DATEDIR}

${SNMPWALK} -c ${COMMUNITY} ${ROUTER} ccCopyFailCause.${ID} >> $DIR/log_backup/log-${DATEDIR}

fi

${SNMPSET} -c ${COMMUNITY} ${ROUTER} .1.3.6.1.4.1.9.9.96.1.1.1.1.14.${ID} i 6 >> $DIR/log_backup/log-${DATEDIR}

/bin/chmod 640 ${TFTPDIR}/${ROUTER}

/bin/cp -p ${TFTPDIR}/${ROUTER} $DIR/conf_backup/${DATEDIR}/${ROUTER}

/bin/rm ${TFTPDIR}/${ROUTER}

and every night at 00:01 we run these 2 scripts:

#!/bin/bash

DIR=/netmgmt

umask 022

export DATEDIR=`date -I`

mkdir $DIR/conf_backup/${DATEDIR}

#!/bin/sh

#

# Only keep config 120 days back

#

DIR=/netmgmt

find $DIR/conf_backup -ctime +120 -exec rm -rf {} \;

404
Views
0
Helpful
4
Replies