Blog |Follow Nick on Twitter| About

As part of my ISE work I generally make changes to WLCs, I'm not really a Wi-Fi Guy so don't ask me about channel width but I do a lot with authentication and in ISE's case that usually includes an ACL or two on the WLC!

There are a number of options for backing up a WLC but they're all a bit clunky if you have say 10 of the blighters to backup!!

Using python (and the Netmiko module), I've written a python script to do the job. If you're a windows user, I recommend you look at MicroSoft's Subsystem for linux as setting up python & netmiko is very straight forward... i.e. the same as linux!

Here's what it looks like when you run it.

linickx:~ $ python3
Username: admin
[INFO] 2017-08-28 16:51:11,065 Connecting to
[INFO] 2017-08-28 16:51:16,502 Connected (version 2.0, client CISCO_WLC)
[INFO] 2017-08-28 16:51:17,620 Authentication (password) successful!
[INFO] 2017-08-28 16:51:24,366 Working on CHWC01
[INFO] 2017-08-28 16:51:24,367 Filename: CHWC01_170828-165124.txt
[INFO] 2017-08-28 16:51:24,367 Sending cmd: show run-config commands
[INFO] 2017-08-28 16:51:25,773 Connecting to
[INFO] 2017-08-28 16:51:31,205 Connected (version 2.0, client CISCO_WLC)
[INFO] 2017-08-28 16:51:32,322 Authentication (password) successful!
[INFO] 2017-08-28 16:51:39,124 Working on CHWC02
[INFO] 2017-08-28 16:51:39,125 Filename: CHWC02_170828-165139.txt
[INFO] 2017-08-28 16:51:39,125 Sending cmd: show run-config commands
[INFO] 2017-08-28 16:51:40,530 Connecting to
[INFO] 2017-08-28 16:51:45,647 Connected (version 2.0, client CISCO_WLC)
[INFO] 2017-08-28 16:51:45,998 Authentication (password) successful!
[INFO] 2017-08-28 16:51:51,782 Working on DEWC01
[INFO] 2017-08-28 16:51:51,783 Filename: DEWC01_170828-165151.txt
linickx:~ $ 

Each WLC gets it's own text file, time/date stamped, of "show run-config commands" which you can use to compare before and after changes... potentially useful for nightly backups if you want to use cron.

The script can be downloaded here (rename to .py), I've pasted it below for your reading pleasure ;-)

Please take note of the comments at the top, the WLC IP addresses are stored in the script, you'll need to update and change as appropriate. By default the script prompts you for credentials which works for runs manually but if used with cron you'll need insecure hardcoded variables (use and secure wisely!)

    Script to backup Cisco WLCs using netmiko

    # Version 1.0 28.Aug.2017
    # Nick Bettison -

    # External Credit...
    # Thanks to ^that^ for getting me started! :)
import logging
import getpass
import re
import datetime
import sys

    import netmiko
    print("Error Netmiko not installed -")

    This array stores a list if IPS to connect to
        one device: `ips = [""]`
        two devices: `ips = ["", ""]
ips = ["", ""]

    By default, ths scipt prompts for credentials.
    If you're feeling insecure and want to store them in the file, replace below with...
    um = "admin"
    pw = "insecure_password"
un = input('Username: ')
pw = getpass.getpass()

    No Need to change below here!
logging.basicConfig(format='[%(levelname)s] %(asctime)s %(message)s', level=logging.INFO)
logger = logging.getLogger("wlc_backup")
devices = [] # Empty array to store wlcs
files = [] # Empty array to store filenames

for ip in ips:
    # device definition
    cisco_wlc = {
        'device_type': 'cisco_wlc',
        'ip': ip,
        'username': un,
        'password': pw,

for device in devices:"Connecting to %s", device['ip'])
    # connect to the device w/ netmiko
        net_connect = netmiko.ConnectHandler(**device)
        logger.error("Failed to connect to %s", device['ip'])
        logger.debug("Exception: %s", sys.exc_info()[0])

    # get the prompt as a string
    prompt = net_connect.find_prompt()

    logger.debug("prompt: %s", prompt)

    regex = r'^\((.*)\)[\s]>'

    regmatch = re.match(regex, prompt)
    if regmatch:
        hostname ="Working on %s", hostname)
        logger.error("Hostname Not Found!")

    filetime ="%y%m%d-%H%M%S") # File timestamp
    config_filename = hostname + "_" + filetime + ".txt" # Filname with hostname
    files.append(config_filename)"Filename: %s", config_filename)

    commands = ['show run-config commands'] # commands to run

    for cmd in commands:"Sending cmd: %s", cmd)
        this_cmd = net_connect.send_command(cmd)
        config_filename_f = open(config_filename, 'a')

for fname in files:
    print(" %s " % fname)

Enjoy your backups!


Nick Bettison ©