Comware

 View Only
last person joined: 2 days ago 

Expand all | Collapse all

Need to automate switch config backup

This thread has been viewed 24 times
  • 1.  Need to automate switch config backup

    Posted Jun 08, 2015 01:52 AM

    Hello Guys,

     

    Planning to automate switch configuration backup system. We are having different model of HP switche's including 1900, 1800, 5900, 2600 & 3Com Series.

     

    I would prefer to do that from a Linux machine. Please do suggest some documents for that.

     
     

    #backup


  • 2.  RE: Need to automate switch config backup

    Posted Jun 08, 2015 08:27 AM

    Hello, we are using Rancid for this.

     

    The documentation and software is found here:

    http://www.shrubbery.net/rancid/

     


    #backup


  • 3.  RE: Need to automate switch config backup

    Posted Jun 08, 2015 08:33 AM

    Hello Fredrik,

    Thanks for the info!

     

    Actually i have tried rancid already. I installed 2.3.x version & they have bug on it.

    Later on they suggest to install 3.x.x version. On top of that, i have different version of HP switches like 1900,1800,5400, 3Com switches & I guess rancid have dependencies on certain version of HP switches.

     

    I would request others to suggest some more procedures!

     

    #backup


  • 4.  RE: Need to automate switch config backup

    Posted Jun 08, 2015 09:58 PM

    Hello ,

     

    Use the below VB Script it will help you .You can edit this script as per your requirement .This is an example it  will open a command prompt, telnet into an HP Procurve switch and copy its runnung config to a TFTP server.

     

    --------Start Of Script--------
    Option Explicit
    On Error Resume Next
    Dim WshShell, strIP, strTFTP, strFile, strPassHP
    Dim filesys, filetxt

    strFile = "File Name"
    strTFTP = "Your TFTP Server Address"
    strPassHP = "Your HP Procurve Password"

    'Opens IP address file for reading
    Const ForReading = 1, ForWriting = 2, ForAppending = 8
    Set filesys = CreateObject("Scripting.FileSystemObject")
    Set filetxt = filesys.OpenTextFile(strFile, ForReading, True)

    'Opens the command prompt
    set WshShell = CreateObject("WScript.Shell")
    WshShell.run "cmd.exe"
    WScript.Sleep 1000

    Do While Not filetxt.AtEndOfStream


    strIP = filetxt.ReadLine
    Copy(strIP)Loop

    filetxt.Close
    set WshShell = Nothing
    set filesys = Nothing
    WScript.Quit

    Function Copy(strIP)


    WshShell.SendKeys "telnet "& strIP
    WshShell.SendKeys ("{Enter}")
    WScript.Sleep 1000 
    WshShell.SendKeys "p"
    WshShell.SendKeys strPassHP
    WshShell.SendKeys ("{Enter}") 
    WshShell.SendKeys "copy running-config tftp " & strTFTP & " " & strIP & ".txt" 
    WshShell.SendKeys ("{Enter}")
    WshShell.SendKeys "^z"
    WshShell.SendKeys "^z"
    WshShell.SendKeys "y"
    WScript.Sleep 2000
    WshShell.SendKeys ("{Enter}")

    End Function

     

    Note :In order for this script to work, you will need a text file will the IP addresses of your switches on a seperate line. You will also need to edit the lines that I have maked in Bold

     

    Thanks and regards

    Anurag Thottathil



  • 5.  RE: Need to automate switch config backup

    Posted Sep 30, 2019 03:08 PM

    Great script!  This worked for me after changing the below line -

     

    strIP = filetxt.ReadLine
    Copy(strIP)Loop

    to

    strIP = filetxt.ReadLine
    Copy(strIP)
    Loop

    I also added a WScript.Sleep 1000 after each line in the function to help with timing.  Thanks for making this.  I've been looking for something like this for years.

    FYI for others, to run this script, just make the script into a .vbs file and then use cscript yourfile.vbs from an admin command prompt.



  • 6.  RE: Need to automate switch config backup

    Posted Oct 20, 2019 03:49 PM

    I wil try this script, it is very useful, thanks.


    #t


  • 7.  RE: Need to automate switch config backup

    Posted Oct 27, 2022 03:19 AM
    hello can i use this scrip with imc server to backup i think this not work for comware switch.


  • 8.  RE: Need to automate switch config backup

    Posted Oct 31, 2022 08:43 AM
    Comware is fully supported in IMC (no idea from what version onwards, but running here iMC PLAT 7.3 (E0706P11)
    Original message was from 2015 (same as the script) - that is 7 years old!

    Seb


  • 9.  RE: Need to automate switch config backup

    Posted Nov 01, 2022 06:16 AM
    Hello when i want to backup comware switch like HP 5900  HPE 1950 in IMC it show error (failed to excute script) and cant backup it, can  you please  Share ur Knowledge  have you ever faced
    like this problem we use this version of 
    iMC PLAT 7.3 (E0705P12)