11

I am looking for a way to backup the controller configuration file via an automatic process. I've seen links to the web interface which appears to do a one-time tftp copy of the config to a remote host, however I'm looking for a way to schedule the copy.

Does anyone know of a way to automate configuration backups for Cisco WLCs?

4
  • Have you see this question? Not directly appicable, but possibly helpful... Commented Sep 16, 2013 at 20:21
  • 1
    Thanks @CraigConstantine, however the WLCs run a custom software that doesn't follow some of the common IOS-isms like "term len 0" -- there's probably an obscure command somewhere to allow a pure config dump, but I have yet to find it. Commented Sep 16, 2013 at 20:32
  • 1
    ...how about this Cisco support thread? Commented Sep 16, 2013 at 21:12
  • 2
    Ideally Cisco Prime Infrastructure would be used, but I suspect the OP is looking for zero-cost options. Commented Sep 17, 2013 at 8:00

4 Answers 4

8

Use a script to login to the WLC and run the transfer command: http://www.cisco.com/en/US/docs/wireless/controller/6.0/command/reference/cli60.html#wp1327209

You can use this to upload the config from the WLC to another server via TFTP/SFTP/FTP.

(Cisco Controller) >transfer upload mode sftp 

(Cisco Controller) >transfer upload username my-osx-user

(Cisco Controller) >transfer upload password my-os-password

(Cisco Controller) >transfer upload serverip 192.168.1.10

(Cisco Controller) >transfer upload path /Users/my-osx-user/

(Cisco Controller) >transfer upload filename wlc.config

(Cisco Controller) >transfer upload datatype config

(Cisco Controller) >transfer upload start

Mode............................................. SFTP
SFTP Server IP................................... 192.168.1.10
SFTP Server Port................................. 22
SFTP Path........................................ /Users/my-osx-user/
SFTP Filename.................................... wlc.config
SFTP Username.................................... my-osx-user
SFTP Password.................................... *********
Data Type........................................ Config File 
Encryption....................................... Disabled

                                                          **************************************************
                            ***  WARNING: Config File Encryption Disabled  ***
                                                                              **************************************************


Are you sure you want to start? (y/N) y

SFTP Config transfer starting.

File transfer operation completed successfully.

(Cisco Controller) >

While the link points to WLC 6.0, the example was run on 7.4.

3
  • Is the sftp only valid for certain controllers/revs? I'm only able to select tftp or ftp. Commented Sep 18, 2013 at 17:10
  • This method works for tftp, and can be automated via something like expect. This solves my problem! Commented Sep 18, 2013 at 17:23
  • SFTP is introduced in 7.4: Release Notes Commented Sep 18, 2013 at 18:45
5

Expect may be a good candidate to consider for the job.

Below is an example template I've put together that is commented out for you to play with. It will log into a WLC, grab the running configuration and append it to a file of your choice.

The example file name and location is /var/log/script-log/config-log.txt

You'll need to modify the file name and location to a file of your choice (with adequate permissions) as well as the username, password and IP address of your WLC.

Finally you can edit your crontab to execute the backup script using a desired interval.

Crontab example:

# Run configuration backup every night at midnight
0 0 * * * /path/to/script/script-name

Configuration backup script example:

#!/usr/bin/expect

set timeout 15

set user "username-here"
set password "password-here"
set ipaddress1 "ip-address-here"


# Store the current date in 'date' and add header to log for appending separation

catch { exec sh -c { date } } date
set env(date) "$date"
exec sh -c {
             {
               echo -e "\n\n==================================================="
               echo -e "= WLC Configuration - $date"
               echo -e "===================================================\n\n"
             } >>/var/log/script-log/config-log.txt
}

# Log to the log.txt file and append to the log on subsequent runs (a)

set log [open "/var/log/script-log/config-log.txt" a]
set accum {}

# Expect diagnostic information with 1 | off = 0

exp_internal 0

# View stdout with 1 | off = 0

log_user 0

# Connect to physical WLC (ipaddr) with ssh

spawn ssh $ipaddress1
match_max 100000
sleep 1

match_max [expr 32 * 1024]
while 1  {
      expect {
        "no)?" {send "yes\r"}
        "n as:*" {send "$user\r"}
        "ser:*" {send "$user\r"}
        "assword:*" {send "$password\r"}
        "r) >"             {break}
        "denied"        {send_user "Can't login\r"; exit 1}
        "refused"       {send_user "Connection refused\r"; exit 2}
        "failed"        {send_user "Host exists. Check ssh_hosts file\r"; exit 3}
         timeout         {send_user "Timeout problem\r"; exit 4}
      }
    }

# send carriage return (\r) to make sure we get back to CLI prompt

send "\r"
sleep 1

# Remove scroll limit and show running configuration

send "config paging disable\r"
sleep 1
send "show run-config\r"
sleep 1
expect {
         "nue..." {send "\r"}
}
sleep 1
send "logout\r"
sleep 1
# Upon logging out you can either save any pending changes with y or simply use n to ignore them
send "y\r"
sleep 4

# Grab string that matched the greedy regexp

expect {
        -regexp {..*} {
            set accum "${accum}$expect_out(0,string)"
            exp_continue
        }
    }

puts $log $accum
1
  • I was hoping to use expect but the output from run-config can't top the raw config of "transfer upload" as mentioned in legioxi's answer. What I wound up doing was use an expect script to trigger the transfer upload start command on a regular interval. Commented Sep 18, 2013 at 17:23
4

I know this is an old post, but the best way I could find to automate the backing up from my controllers was to use SNMP in a script run from cron.

snmpset -v2c -c <snmp_RW> <WLC_IP> .1.3.6.1.4.1.14179.1.2.9.1.1.0 i 1
snmpset -v2c -c <snmp_RW> <WLC_IP> .1.3.6.1.4.1.14179.1.2.9.1.2.0 a TFTP_Server_IP
snmpset -v2c -c <snmp_RW> <WLC_IP> .1.3.6.1.4.1.14179.1.2.9.1.3.0 s /<TFTP_Path>
snmpset -v2c -c <snmp_RW> <WLC_IP> .1.3.6.1.4.1.14179.1.2.9.1.4.0 s <File_name>
snmpset -v2c -c <snmp_RW> <WLC_IP> .1.3.6.1.4.1.14179.1.2.9.1.5.0 i 2
snmpset -v2c -c <snmp_RW> <WLC_IP> .1.3.6.1.4.1.14179.1.2.9.1.6.0 i 1

Obviously replace the items within <> to fit your setup. Hopefully someone somewhere may find this helpful.

1
  • Nice find. SNMP write capability is always underestimated!
    – RedShift
    Commented Aug 16, 2014 at 10:17
4

Depending on how many devices you have, you could hack Rancid to get it to work with them. Then you can set it up with a version control system and have a nice web gui with diffs over time.

If you don't have many devices, the [clogin part of Rancid] should be sufficient in a script called from crontab daily, á la

for device in wlc1 wlc2 wlc3 (..) wlcN; do
    clogin -c "show run; show clock" $device > ~/WLC-config-backups/$(date +%Y-%m-%d)-$device-backup.txt
done

It's a basic bash for loop that can be extended almost infinitely.

4
  • 2
    "show run" is not a valid command on the WLC, it's show running-config and even then it stops and prompts you page-by-page. It wont accept "term len 0" -- if this was a regular IOS, I would just use the same script I use to back up all my other cisco devices.. :( Commented Sep 16, 2013 at 19:59
  • 3
    config paging disabled is equivalent to IOS "term len 0". Good luck trying to abort show run-config once it gets rolling though. There's still an initial "Press enter to continue." Commented Sep 17, 2013 at 8:05
  • @generalnetworkerror, FYI config paging disabled locks up telnet and ssh sessions to the WLC4404s that we have Commented Sep 17, 2013 at 20:36
  • 1
    @MikePennington: Paging disabled tested without lock-up on WLC 5508 v7.5.102.0 in SSH session. Commented Sep 18, 2013 at 7:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.