0 Replies Latest reply: Feb 25, 2010 6:37 AM by thiyagarajankalaiselvan RSS

    Script to automate router and switch config back-up

    thiyagarajankalaiselvan

      Dear All,

       

      I have attached a script to automate router and switch config back-up.

       

      I have downloaded this from a portal. I could not understant the logic of the script.

       

      If anybody knows about shell script, please help me know about this script.

       

      where to give the device name?

      where to give the path to save the file ?

      how to schedule it ?

       

      hoping for a help.

       

       

      #! /bin/sh

      DIR=/home/X/router

           if [ ! -e $DIR ]
           then
             mkdir $DIR
           fi

      # Tag specification: mmddhhmm
      DATE=`date +'%m%d'`
      TIME=`date +'%H%M'`
      TAG=$DATE$TIME

      > $DIR/info.$TAG.report

      echo "*******************************************************************************" >> $DIR/info.$TAG.report
      echo "*******************************************************************************" >> $DIR/info.$TAG.report
      echo "********************************Network Backup Report**************************" >> $DIR/info.$TAG.report
      echo "*******************************************************************************" >> $DIR/info.$TAG.report
      echo "*******************************************************************************" >> $DIR/info.$TAG.report

      for IP_ADDRESS in `cat /home/xxx/router/ipeu`

      do

      # Collect data from the router
      (echo "xx";\
      echo "xxx "copy running-config ftp:";\
      echo "172.16.2.253";\
      echo "\r";\
      echo "            exit";\
      sleep 10)|telnet $IP_ADDRESS > $DIR/info.$TAG 2>$DIR/info.$TAG.msg

      rm $DIR/info.$TAG
      rm $DIR/info.$TAG.msg

      cat $DIR/info.$TAG.final >> $DIR/info.$TAG.report

      echo "*******************************************************************************" >> $DIR/info.$TAG.report
      echo "*******************************************************************************" >> $DIR/info.$TAG.report

      rm $DIR/info.$TAG.final

      done
      cat $DIR/info.$TAG.report | mailx -s "Network Backup Report"