Retrieving network elements backup from 5620 SAM

Last week I faced a routine (and quite common) task to get the latest backups of current configuration and BOF files for ~700 routers on a customers network. Sure thing sane man would use some automatization techniques, which could be:

  • 5620 SAM scripts
  • some scripting language to grab latest backups from the global NE backup location on a SAM server

I tried it both ways and invite you under the cut to read about it.

SAM’s velocity scripts

The first thing I tried was a SAM’s velocity script:

Firstly I created two directories (CFG_files and BOF_files) to store the files from the nodes. Then I used XML API calls to get info about the NE’s name (line 1) and current time (line 2). The last thing was to specify mediation IP interface to which NEs will try to connect and voila.

Last two commands effectively use the variables defined at the beginning and save current config and BOF files to directories created on the SAM server.

This method works really well, though on some nodes I got failures regarding establishing FTP session. I had no time to investigate this issue and attacked from the rear.

Get latest backup with python

Every NMS does automatic backup retrieval on a daily/weekly basis, 5620 SAM is no exception. What I did was forcing backup of all the NEs and then extract latest backups from the server hosting 5620 SAM application.

I was blessed to have all the SAMs running 12r7 since starting from 12r5 SAM application stores backups not in the database but in a directory – /opt/5620sam/nebackup.

The need to write some scripts arose because 5620 SAM stores all the backups for a particular NE under the same directory and you cant easily grab the latest manually. See this example of dirs layout for 3 NEs with two backups each:

What I needed to do is to copy just the directory linked by symlink latest to some other directory for every node present.

I wrote a tiny console python script for python2.6 (yeah, RedHat6 OS which is hosting 5620 SAM by default has this dinosaur) which you have to copy to SAM server and run as a root:

By default script uses /opt/5620sam/nebackup/SROS  directory to search for backups, but you can specify your own with the -p PATH argument if needed. Same goes for output directory, it defaults to ~/  but you can specify a custom location.

Since in most cases you’d want to transfer backups from SAM server to another host you’d love the zip option which kindly compress latest backups into the zip file.

The whole code is available in this github repo. Customize it all the way you want and do not forget to pull requests!



Roman Dodin

Network engineer at Nokia
Eagerness to learn multiplied by passion to share.
You can reach me at LinkedIn

You Might Also Like

  • Burak Şahin

    Hi Roman,

    I got here from the link you supplied in SAM interest list. This particular issue is not relevant to me at the moment (may be it will be in the future). However, I had a short tour in your site, and would like to say that you put really useful posts in a digestible way here. Please keep up the good work. I added your site into my favorites, and will keep on following.


    • Roman Dodin

      Hi Burak! Glad you liked it.
      It actually was the point of this blog – to spread/share knowledge and experience in an open way.

      Moreover, this blog is open for authors who want to share their experience.