<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic UPM script to backup switch configuration and policies etc in Scripting</title>
    <link>https://community.extremenetworks.com/t5/scripting/upm-script-to-backup-switch-configuration-and-policies-etc/m-p/19317#M57</link>
    <description>Create Date: Jan  4 2012  4:15AM&lt;BR /&gt;
&lt;BR /&gt;
Hi!&lt;BR /&gt;
&lt;BR /&gt;
 Enclosed is a UPM script we've been using for a while to backup XOS switches. We've used it on 450/460/BD10K etc. I think I'll require XOS 12.4.&lt;BR /&gt;
&lt;BR /&gt;
 It backs up the current config both as text and xml. It also backs up other files like .pol or .xsf. The files are stored on a tftp server, in a separate directory for each day (you have to create the directory structure with a script on the tftp server - included below). In our setup the the tftp root for the backups is /data/tftpboot/switchbackup/&lt;BR /&gt;
&lt;BR /&gt;
 Date and switch name are prepended to each file name (eg a123a-2012-01-03.cfg and a123a-2012-01-03.txt for XML and text versions).&lt;BR /&gt;
&lt;BR /&gt;
 We use the script to backup files to two different tftp servers - you'll have to enter your own ip address(es).&lt;BR /&gt;
&lt;BR /&gt;
 The script tries to intelligently decide to use the correct VR for the tftp command (vr-default or vr-management).&lt;BR /&gt;
&lt;BR /&gt;
 The script is first run 12 hours after reboot and then every 24 hours.&lt;BR /&gt;
&lt;BR /&gt;
  &lt;BR /&gt;
&lt;BR /&gt;
  &lt;BR /&gt;
&lt;BR /&gt;
 UPM SCRIPT:&lt;BR /&gt;
&lt;BR /&gt;
 create upm profile backup-config&lt;BR /&gt;
&lt;BR /&gt;
 configure cli mode scripting abort-on-error&lt;BR /&gt;
&lt;BR /&gt;
 set var CLI.OUT 0&lt;BR /&gt;
&lt;BR /&gt;
 set var tftproot switchbackup&lt;BR /&gt;
&lt;BR /&gt;
 show iproute vr vr-mgmt&lt;BR /&gt;
&lt;BR /&gt;
 set var input $TCL(split ${CLI.OUT} " ")&lt;BR /&gt;
&lt;BR /&gt;
 set var x $TCL(lsearch -glob $input "*Total number of routes = 0*")&lt;BR /&gt;
&lt;BR /&gt;
 if ($x == -1) then&lt;BR /&gt;
&lt;BR /&gt;
 set var vr "vr-mgmt"&lt;BR /&gt;
&lt;BR /&gt;
 else&lt;BR /&gt;
&lt;BR /&gt;
 set var vr "vr-default"&lt;BR /&gt;
&lt;BR /&gt;
 endif&lt;BR /&gt;
&lt;BR /&gt;
 set var seconds $TCL(clock seconds)&lt;BR /&gt;
&lt;BR /&gt;
 set var date $TCL(clock format $seconds -format {%Y-%m-%d})&lt;BR /&gt;
&lt;BR /&gt;
 show switch&lt;BR /&gt;
&lt;BR /&gt;
 set var input $TCL(split ${CLI.OUT} " ")&lt;BR /&gt;
&lt;BR /&gt;
 set var x $TCL(lsearch -glob $input "*SysName*")&lt;BR /&gt;
&lt;BR /&gt;
 set var x $TCL(lindex $input $x)&lt;BR /&gt;
&lt;BR /&gt;
 set var x $TCL(split $x " ")&lt;BR /&gt;
&lt;BR /&gt;
 set var switchname $TCL(lindex ${x} 10)&lt;BR /&gt;
&lt;BR /&gt;
 set var x $TCL(lsearch -glob $input "*Config Selected*")&lt;BR /&gt;
&lt;BR /&gt;
 set var x $TCL(lindex $input $x)&lt;BR /&gt;
&lt;BR /&gt;
 set var x $TCL(split $x " ")&lt;BR /&gt;
&lt;BR /&gt;
 set var y $TCL(lsearch -glob $x "*.cfg*")&lt;BR /&gt;
&lt;BR /&gt;
 set var config $TCL(lindex ${x} $y)&lt;BR /&gt;
&lt;BR /&gt;
 save configuration&lt;BR /&gt;
&lt;BR /&gt;
 configure cli mode scripting ignore-error&lt;BR /&gt;
&lt;BR /&gt;
 tftp put 10.1.1.120 vr $vr $(config) $(tftproot)/$(date)/$(switchname)-$(date).cfg&lt;BR /&gt;
&lt;BR /&gt;
 tftp put 10.1.1.130 vr $vr $(config) $(tftproot)/$(date)/$(switchname)-$(date).cfg&lt;BR /&gt;
&lt;BR /&gt;
 upload configuration 10.1.1.120 $(tftproot)/$(date)/$(switchname)-$(date).txt vr $vr&lt;BR /&gt;
&lt;BR /&gt;
 upload configuration 10.1.1.130 $(tftproot)/$(date)/$(switchname)-$(date).txt vr $vr&lt;BR /&gt;
&lt;BR /&gt;
 configure cli mode scripting abort-on-error&lt;BR /&gt;
&lt;BR /&gt;
 ls&lt;BR /&gt;
&lt;BR /&gt;
 set var files $TCL(split ${CLI.OUT} " ")&lt;BR /&gt;
&lt;BR /&gt;
 set var n $TCL(llength $files)&lt;BR /&gt;
&lt;BR /&gt;
 set var n $TCL(expr {$n-5})&lt;BR /&gt;
&lt;BR /&gt;
 set var files $TCL(lrange $files 0 $n)&lt;BR /&gt;
&lt;BR /&gt;
 while ($n != -1) do&lt;BR /&gt;
&lt;BR /&gt;
 set var line $TCL(lindex $files $n)&lt;BR /&gt;
&lt;BR /&gt;
 set var filename $TCL(lindex $line end)&lt;BR /&gt;
&lt;BR /&gt;
 set var exempt $TCL(list license.xlic vmt)&lt;BR /&gt;
&lt;BR /&gt;
 set var suffix $TCL(string match "*cfg" $line)&lt;BR /&gt;
&lt;BR /&gt;
 if ($suffix == 0) then&lt;BR /&gt;
&lt;BR /&gt;
 set var dobackup $TCL(lsearch $exempt $filename)&lt;BR /&gt;
&lt;BR /&gt;
 if ($dobackup == -1) then&lt;BR /&gt;
&lt;BR /&gt;
 configure cli mode scripting ignore-error&lt;BR /&gt;
&lt;BR /&gt;
 tftp put 10.1.1.120 vr $vr $(filename) $(tftproot)/$(date)/$(switchname)-$(date)_$(filename)&lt;BR /&gt;
&lt;BR /&gt;
 tftp put 10.1.1.130 vr $vr $(filename) $(tftproot)/$(date)/$(switchname)-$(date)_$(filename)&lt;BR /&gt;
&lt;BR /&gt;
 configure cli mode scripting abort-on-error&lt;BR /&gt;
&lt;BR /&gt;
 endif&lt;BR /&gt;
&lt;BR /&gt;
 endif&lt;BR /&gt;
&lt;BR /&gt;
 set var n ($n-1)&lt;BR /&gt;
&lt;BR /&gt;
 endwhile&lt;BR /&gt;
&lt;BR /&gt;
 .&lt;BR /&gt;
&lt;BR /&gt;
  &lt;BR /&gt;
&lt;BR /&gt;
 UPM CONFIG:&lt;BR /&gt;
&lt;BR /&gt;
 configure upm profile backup-config maximum execution-time 240&lt;BR /&gt;
&lt;BR /&gt;
 create upm timer backup-config-timer&lt;BR /&gt;
&lt;BR /&gt;
 configure upm timer backup-config-timer profile backup-config&lt;BR /&gt;
&lt;BR /&gt;
 configure upm timer backup-config-timer after 43200 every 86400&lt;BR /&gt;
&lt;BR /&gt;
 enable upm profile backup-config&lt;BR /&gt;
&lt;BR /&gt;
    &lt;BR /&gt;
&lt;BR /&gt;
 UNIX SCRIPT TO CREATE DIRECTORIES&lt;BR /&gt;
&lt;BR /&gt;
  &lt;BR /&gt;
&lt;BR /&gt;
 #!/bin/sh&lt;BR /&gt;
&lt;BR /&gt;
 #&lt;BR /&gt;
&lt;BR /&gt;
 # Create empyt directories for next 5 days&lt;BR /&gt;
&lt;BR /&gt;
 # used to store backup of switch configuration&lt;BR /&gt;
&lt;BR /&gt;
 #&lt;BR /&gt;
&lt;BR /&gt;
 basedir='/data/tftpboot/switchbackup'&lt;BR /&gt;
&lt;BR /&gt;
 today='date +'%s''&lt;BR /&gt;
&lt;BR /&gt;
 for i in 0 1 2 3 4 5; do&lt;BR /&gt;
&lt;BR /&gt;
   nextday='expr $i \* 86400 + $today'&lt;BR /&gt;
&lt;BR /&gt;
   mkdir -m 777 $basedir/'date +'%F' --date "1970-01-01 $nextday sec"'&lt;BR /&gt;
&lt;BR /&gt;
 done&lt;BR /&gt;
&lt;BR /&gt;
    &lt;BR /&gt;
&lt;BR /&gt;
  (from Roland_Mansson)</description>
    <pubDate>Wed, 08 Jan 2014 05:49:00 GMT</pubDate>
    <dc:creator>EtherNation_Use</dc:creator>
    <dc:date>2014-01-08T05:49:00Z</dc:date>
    <item>
      <title>UPM script to backup switch configuration and policies etc</title>
      <link>https://community.extremenetworks.com/t5/scripting/upm-script-to-backup-switch-configuration-and-policies-etc/m-p/19317#M57</link>
      <description>Create Date: Jan  4 2012  4:15AM&lt;BR /&gt;
&lt;BR /&gt;
Hi!&lt;BR /&gt;
&lt;BR /&gt;
 Enclosed is a UPM script we've been using for a while to backup XOS switches. We've used it on 450/460/BD10K etc. I think I'll require XOS 12.4.&lt;BR /&gt;
&lt;BR /&gt;
 It backs up the current config both as text and xml. It also backs up other files like .pol or .xsf. The files are stored on a tftp server, in a separate directory for each day (you have to create the directory structure with a script on the tftp server - included below). In our setup the the tftp root for the backups is /data/tftpboot/switchbackup/&lt;BR /&gt;
&lt;BR /&gt;
 Date and switch name are prepended to each file name (eg a123a-2012-01-03.cfg and a123a-2012-01-03.txt for XML and text versions).&lt;BR /&gt;
&lt;BR /&gt;
 We use the script to backup files to two different tftp servers - you'll have to enter your own ip address(es).&lt;BR /&gt;
&lt;BR /&gt;
 The script tries to intelligently decide to use the correct VR for the tftp command (vr-default or vr-management).&lt;BR /&gt;
&lt;BR /&gt;
 The script is first run 12 hours after reboot and then every 24 hours.&lt;BR /&gt;
&lt;BR /&gt;
  &lt;BR /&gt;
&lt;BR /&gt;
  &lt;BR /&gt;
&lt;BR /&gt;
 UPM SCRIPT:&lt;BR /&gt;
&lt;BR /&gt;
 create upm profile backup-config&lt;BR /&gt;
&lt;BR /&gt;
 configure cli mode scripting abort-on-error&lt;BR /&gt;
&lt;BR /&gt;
 set var CLI.OUT 0&lt;BR /&gt;
&lt;BR /&gt;
 set var tftproot switchbackup&lt;BR /&gt;
&lt;BR /&gt;
 show iproute vr vr-mgmt&lt;BR /&gt;
&lt;BR /&gt;
 set var input $TCL(split ${CLI.OUT} " ")&lt;BR /&gt;
&lt;BR /&gt;
 set var x $TCL(lsearch -glob $input "*Total number of routes = 0*")&lt;BR /&gt;
&lt;BR /&gt;
 if ($x == -1) then&lt;BR /&gt;
&lt;BR /&gt;
 set var vr "vr-mgmt"&lt;BR /&gt;
&lt;BR /&gt;
 else&lt;BR /&gt;
&lt;BR /&gt;
 set var vr "vr-default"&lt;BR /&gt;
&lt;BR /&gt;
 endif&lt;BR /&gt;
&lt;BR /&gt;
 set var seconds $TCL(clock seconds)&lt;BR /&gt;
&lt;BR /&gt;
 set var date $TCL(clock format $seconds -format {%Y-%m-%d})&lt;BR /&gt;
&lt;BR /&gt;
 show switch&lt;BR /&gt;
&lt;BR /&gt;
 set var input $TCL(split ${CLI.OUT} " ")&lt;BR /&gt;
&lt;BR /&gt;
 set var x $TCL(lsearch -glob $input "*SysName*")&lt;BR /&gt;
&lt;BR /&gt;
 set var x $TCL(lindex $input $x)&lt;BR /&gt;
&lt;BR /&gt;
 set var x $TCL(split $x " ")&lt;BR /&gt;
&lt;BR /&gt;
 set var switchname $TCL(lindex ${x} 10)&lt;BR /&gt;
&lt;BR /&gt;
 set var x $TCL(lsearch -glob $input "*Config Selected*")&lt;BR /&gt;
&lt;BR /&gt;
 set var x $TCL(lindex $input $x)&lt;BR /&gt;
&lt;BR /&gt;
 set var x $TCL(split $x " ")&lt;BR /&gt;
&lt;BR /&gt;
 set var y $TCL(lsearch -glob $x "*.cfg*")&lt;BR /&gt;
&lt;BR /&gt;
 set var config $TCL(lindex ${x} $y)&lt;BR /&gt;
&lt;BR /&gt;
 save configuration&lt;BR /&gt;
&lt;BR /&gt;
 configure cli mode scripting ignore-error&lt;BR /&gt;
&lt;BR /&gt;
 tftp put 10.1.1.120 vr $vr $(config) $(tftproot)/$(date)/$(switchname)-$(date).cfg&lt;BR /&gt;
&lt;BR /&gt;
 tftp put 10.1.1.130 vr $vr $(config) $(tftproot)/$(date)/$(switchname)-$(date).cfg&lt;BR /&gt;
&lt;BR /&gt;
 upload configuration 10.1.1.120 $(tftproot)/$(date)/$(switchname)-$(date).txt vr $vr&lt;BR /&gt;
&lt;BR /&gt;
 upload configuration 10.1.1.130 $(tftproot)/$(date)/$(switchname)-$(date).txt vr $vr&lt;BR /&gt;
&lt;BR /&gt;
 configure cli mode scripting abort-on-error&lt;BR /&gt;
&lt;BR /&gt;
 ls&lt;BR /&gt;
&lt;BR /&gt;
 set var files $TCL(split ${CLI.OUT} " ")&lt;BR /&gt;
&lt;BR /&gt;
 set var n $TCL(llength $files)&lt;BR /&gt;
&lt;BR /&gt;
 set var n $TCL(expr {$n-5})&lt;BR /&gt;
&lt;BR /&gt;
 set var files $TCL(lrange $files 0 $n)&lt;BR /&gt;
&lt;BR /&gt;
 while ($n != -1) do&lt;BR /&gt;
&lt;BR /&gt;
 set var line $TCL(lindex $files $n)&lt;BR /&gt;
&lt;BR /&gt;
 set var filename $TCL(lindex $line end)&lt;BR /&gt;
&lt;BR /&gt;
 set var exempt $TCL(list license.xlic vmt)&lt;BR /&gt;
&lt;BR /&gt;
 set var suffix $TCL(string match "*cfg" $line)&lt;BR /&gt;
&lt;BR /&gt;
 if ($suffix == 0) then&lt;BR /&gt;
&lt;BR /&gt;
 set var dobackup $TCL(lsearch $exempt $filename)&lt;BR /&gt;
&lt;BR /&gt;
 if ($dobackup == -1) then&lt;BR /&gt;
&lt;BR /&gt;
 configure cli mode scripting ignore-error&lt;BR /&gt;
&lt;BR /&gt;
 tftp put 10.1.1.120 vr $vr $(filename) $(tftproot)/$(date)/$(switchname)-$(date)_$(filename)&lt;BR /&gt;
&lt;BR /&gt;
 tftp put 10.1.1.130 vr $vr $(filename) $(tftproot)/$(date)/$(switchname)-$(date)_$(filename)&lt;BR /&gt;
&lt;BR /&gt;
 configure cli mode scripting abort-on-error&lt;BR /&gt;
&lt;BR /&gt;
 endif&lt;BR /&gt;
&lt;BR /&gt;
 endif&lt;BR /&gt;
&lt;BR /&gt;
 set var n ($n-1)&lt;BR /&gt;
&lt;BR /&gt;
 endwhile&lt;BR /&gt;
&lt;BR /&gt;
 .&lt;BR /&gt;
&lt;BR /&gt;
  &lt;BR /&gt;
&lt;BR /&gt;
 UPM CONFIG:&lt;BR /&gt;
&lt;BR /&gt;
 configure upm profile backup-config maximum execution-time 240&lt;BR /&gt;
&lt;BR /&gt;
 create upm timer backup-config-timer&lt;BR /&gt;
&lt;BR /&gt;
 configure upm timer backup-config-timer profile backup-config&lt;BR /&gt;
&lt;BR /&gt;
 configure upm timer backup-config-timer after 43200 every 86400&lt;BR /&gt;
&lt;BR /&gt;
 enable upm profile backup-config&lt;BR /&gt;
&lt;BR /&gt;
    &lt;BR /&gt;
&lt;BR /&gt;
 UNIX SCRIPT TO CREATE DIRECTORIES&lt;BR /&gt;
&lt;BR /&gt;
  &lt;BR /&gt;
&lt;BR /&gt;
 #!/bin/sh&lt;BR /&gt;
&lt;BR /&gt;
 #&lt;BR /&gt;
&lt;BR /&gt;
 # Create empyt directories for next 5 days&lt;BR /&gt;
&lt;BR /&gt;
 # used to store backup of switch configuration&lt;BR /&gt;
&lt;BR /&gt;
 #&lt;BR /&gt;
&lt;BR /&gt;
 basedir='/data/tftpboot/switchbackup'&lt;BR /&gt;
&lt;BR /&gt;
 today='date +'%s''&lt;BR /&gt;
&lt;BR /&gt;
 for i in 0 1 2 3 4 5; do&lt;BR /&gt;
&lt;BR /&gt;
   nextday='expr $i \* 86400 + $today'&lt;BR /&gt;
&lt;BR /&gt;
   mkdir -m 777 $basedir/'date +'%F' --date "1970-01-01 $nextday sec"'&lt;BR /&gt;
&lt;BR /&gt;
 done&lt;BR /&gt;
&lt;BR /&gt;
    &lt;BR /&gt;
&lt;BR /&gt;
  (from Roland_Mansson)</description>
      <pubDate>Wed, 08 Jan 2014 05:49:00 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/upm-script-to-backup-switch-configuration-and-policies-etc/m-p/19317#M57</guid>
      <dc:creator>EtherNation_Use</dc:creator>
      <dc:date>2014-01-08T05:49:00Z</dc:date>
    </item>
    <item>
      <title>RE: UPM script to backup switch configuration and policies etc</title>
      <link>https://community.extremenetworks.com/t5/scripting/upm-script-to-backup-switch-configuration-and-policies-etc/m-p/19318#M58</link>
      <description>Create Date: Jan  4 2012  8:37AM&lt;BR /&gt;
&lt;BR /&gt;
 Macrm,&lt;BR /&gt;
&lt;BR /&gt;
 Great contribution! This can benefit anyone who has not commited to Ridgeline or Epicenter yet. &lt;BR /&gt;
&lt;BR /&gt;
  (from john_padilla)</description>
      <pubDate>Wed, 08 Jan 2014 05:49:00 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/upm-script-to-backup-switch-configuration-and-policies-etc/m-p/19318#M58</guid>
      <dc:creator>EtherNation_Use</dc:creator>
      <dc:date>2014-01-08T05:49:00Z</dc:date>
    </item>
  </channel>
</rss>

