i am looking for script through i can take weekly backup of configuration.

  • 1
  • Question
  • Updated 1 month ago
  • Answered
  • (Edited)
Hi All,
I hope that you are doing well...
i am new in Brocade ICX family switches.
i have one small query if any one can help me, it will be highly appreciated !!!!
we have Brocade ICX 7450,7250 and 6430 switches and i am looking for script through i can take weekly backup of configration.
i have spend so much time to make it possible by using their in buit option which is Batch buffer but unfortunatly it not work as i accepted.

so dear all , i am looking hopefully your response.

Thanks in Advance
Photo of Pradeep sonawne

Pradeep sonawne

  • 4 Posts
  • 0 Reply Likes
  • Hopefully

Posted 1 month ago

  • 1
Photo of chill

chill

  • 16 Posts
  • 7 Reply Likes
How is your python? You could easily write a script utilizing netmiko to accomplish this. 
Photo of Pradeep sonawne

Pradeep sonawne

  • 4 Posts
  • 0 Reply Likes
Hi, thanks for reply, i have not used python yet but i heard lots of about it and i am interested to do !!!
do one favor for me.
how to start it ? please give me some guidelines....

Photo of Pradeep sonawne

Pradeep sonawne

  • 4 Posts
  • 0 Reply Likes
Hi, as i did some googling and got info about python and script for network backup.
i have installed it on my windows system.
but when i trying to execute that script, it showing an error as below.
------------------------------------------------------------------------------------------------------
C:\Users\ibmwlengr1\AppData\Local\Programs\Python\Python37-32>python autobackup-cisco.py
Traceback (most recent call last):
  File "autobackup-cisco.py", line 1, in <module>
    from netmiko import ConnectHandler
ModuleNotFoundError: No module named 'netmiko'
------------------------------------------------------------------------------------------------------

so i have downloaded netmiko 2.2.2 but still i am getting error like above.

please help
Photo of Pradeep sonawne

Pradeep sonawne

  • 4 Posts
  • 0 Reply Likes
Hi,
as you asked to me Q,  How is my python? , honestly i tell you i heard lots of about it but never used, today i used it and frankly i tell u its amazing, i started finding more about it  and i got script for cisco switch and as tested it works !!!
do you have any scrip for brocade ICX switches ?
i really appreciate your help ....
Photo of NETWizz

NETWizz

  • 25 Posts
  • 8 Reply Likes
Solar Winds NCM does a great job of it in Orion.


Photo of Scott Farrand

Scott Farrand

  • 9 Posts
  • 3 Reply Likes
Apparently the link I shared for Rancid was deemed spam. 

Rancid is a free tool that has an ICX/Brocade module that will automatically poll the configuration of a given switch, it leverages code versioning software to maintain an archive of all switch/router configuration changes, and can be configured to automatically e-mail a network team to alert them about configuration changes made to networking environment.

If you're going to delete comments like mine as "spam" perhaps you should also delete references to other software solutions.
Photo of Fernando Flórez

Fernando Flórez

  • 22 Posts
  • 6 Reply Likes
If you need a python script I can help.

If you have python installed check that you have setup_tools installed too.

If you don't then:

1) Download: https://bootstrap.pypa.io/get-pip.py
2) python get-pip.py

Install netmiko:

# pip install netmiko

Then the script:

from netmiko import ConnectHandler

from datetime import datetime
import argparse
from getpass import getpass


def main(conf):
    conn = ConnectHandler(**conf)
    dump = conn.send_command('show run')
    filename = 'backup_%(ip)s_%(timestamp)s.conf' % {
        'ip': conf.get('ip'),
        'timestamp': datetime.now().strftime('%s')
    }
    with open(filename, 'wb+') as dump_file:
        dump_file.write(dump)


if __name__ == '__main__':
    command_line = argparse.ArgumentParser()
    command_line.add_argument('--ip', help='IP address of your ruckus ICX')
    command_line.add_argument('--username', help='SSH username')
    command_line.add_argument('--password',
                              help='SSH password (clear text btw!)')

    try:
        args = command_line.parse_args()
    except TypeError:
        print u'Unable to parse args'
    else:
        if None in (args.ip, args.username):
            print u'IP and username is required'
        else:
            _password = args.password
            if not _password:
                _password = getpass()
        conf = {
            'device_type': 'ruckus_fastiron',
            'ip': args.ip,
            'username': args.username,
            'password': _password
        }
        main(conf)


Save it as "backup_icx.py".

To execute help:

$ python backup_icx.py --help

--ip -> ip address of the icx to backup
--username -> ssh username
--password -> ssh password

To create a backup

$ python backup_icx.py --ip=<ip address> --username=<ssh username> --password=<ssh password>

Becareful that password is in clear text. If you don't specify a password arg then you will be prompted for one:

$ python backup_icx.py --ip=<ip address> --username=<ssh username>


You will need SSH enable on the hardware for this to work.

Backups will be saved on the same directory under the name "backup_<ip address>_<timestamp>.conf"

Sorry for the quickly put together script but this could guide you a little.

Cheers!
Photo of chill

chill

  • 16 Posts
  • 7 Reply Likes
This is great! But if you want to get around having your password in cleartext, import the getpass module and use that.

import getpass

password = getpass.getpass()


It will create a prompt for your password and not show it in cleartext at your console. It's perfect for this situation. 
Photo of Fernando Flórez

Fernando Flórez

  • 22 Posts
  • 6 Reply Likes
If you don't specify a --password arg the script will prompt for a password.

BTW, I would NOT recommend having this script running under windows. Paramiko will try to emulate SSH and would be slooooow. Try running it under linux and create a cron to forget about it :)
Photo of Jim Shanks

Jim Shanks

  • 1 Post
  • 0 Reply Likes
Scott
I've not heard of Rancid.  Sounds like a winner.  I've been using BNA for years and it includes backing up configs.  
Jim