How to Save, backup or upload Configuration Script on WLC

Document

Apr 26, 2015 6:44 AM
Dec 29th, 2011


Introduction

How to Automatically Save, backup or upload Configuration Script on WLC.

Scenario

Is there a way to save the WLC configuration as a .txt file or a copy start to tftp command like in a switch or router in order to later paste or load it to another or the same WLC?

Condition

Add a new backup WLC in network (only the name and IP address will be different) in order to avoid going step by step through it's configuration.

Or

In order to restore default settings in current WLC and then loading a config file.

Solution

Starting from 5.2 or later, when loading the config file via FTP or TFTP, you can actually open it with a text editor and it should show as a list of commands:

Saving Configurations

Controllers contain two kinds of memory: volatile RAM and NVRAM. At any time, you can save the configuration changes from active volatile RAM to non-volatile RAM (NVRAM) using one of these commands:

•save config—Saves the configuration from volatile RAM to NVRAM without resetting the controller.

•reset system—Prompts you to confirm that you want to save configuration changes before the controller reboots.

•logout—Prompts you to confirm that you want to save configuration changes before you log out.

Saving Configurations

In this way you can make changes with the text editor and load it back to the WLC. Alternatively, you could also copy the whole config as a text,

go in the WLC's config mode (with the "config" command) and at the prompt "config>" simply copy the whole config text file.

Scenario

Is there a method to save configs automatically and periodically to TFTP/FTP server or anywhere WITHOUT using WCS?

Solution

There is a way to do this using expect scripts. You can use cron to call the shell script that calls the commands expect file.

commands expect script for backing up configs. Change the script upload variables for your environment

#!/usr/bin/expect

set router [ lindex $argv 0]
set username [ lindex $argv 1]
set password [ lindex $argv 2]

spawn ssh $router

#log_user 0
set timeout 10
expect "(yes/no)?" {
send "yes\r"; exp_continue }
expect "User:"
send -- "$username\r"
expect "assword:"
send -- "$password\r"
expect "Controller"
send -- "transfer upload datatype config\r"
expect "Controller"
send -- "transfer upload mode tftp\r"
expect "Controller"
send -- "transfer upload serverip <your tftp or ftp server ip>\r"
expect "Controller"
send -- "transfer upload start\r"
# some wlc config commands require yes/no verification
expect "(y/N)"
send -- "y\r"
expect "Controller"
send "logout\r"
expect "(y/N)"
send -- "n\r"
expect eof
Overall Rating: 5 (1 ratings)
tcartledge Mon, 05/28/2012 - 05:22

You could also use a PHP script as per below (You will have to fill in the username/password from the WLC web admin if your using FTP first).

<?php
$TargetIP='IP Address of WLC';
$TargetUser='Username';
$TargetPass='Password';

$MySSH=ssh2_connect($TargetIP);
ssh2_auth_none($MySSH,$TargetUser);
$MyShell=ssh2_shell($MySSH);
sleep(1);
fwrite($MyShell,$TargetUser."\r");
sleep(1);
fwrite($MyShell,$TargetPass."\r");
sleep(1);
while($buffer=fgets($MyShell,4096))
{
  print($buffer);              
  };
fwrite($MyShell,'transfer upload datatype config'."\r");
sleep(1);
fwrite($MyShell,'transfer upload mode ftp'."\r");
sleep(1);
fwrite($MyShell,'transfer upload serverip IP_of_ftp_server'."\r");
sleep(1);
while($buffer=fgets($MyShell,4096))
{
  print($buffer);              
  };
fwrite($MyShell,'transfer upload start'."\r");
sleep(1);
fwrite($MyShell,'y'."\r");
sleep(1);

$WaitFlag=True;
while($WaitFlag)
{
  sleep(1);
  $buffer=fgets($MyShell,4096);
  flush();
  if (!is_null($buffer))
   {
    if(strpos($buffer,'file transfer failed')!== False) $WaitFlag=False;
    if(strpos($buffer,'operation completed successfully')!== False) $WaitFlag=False;
    print($buffer.PHP_EOL);              
    };
  };
fclose($MyShell);

?>

Then setup a MS automatic task from a Windows server and run php + script argument.

Actions

Login or Register to take actions

This Document

Posted December 29, 2011 at 8:13 PM
Updated December 29, 2011 at 8:42 PM
Stats:
Comments:1 Overall Rating:5
Views:13472 Contributors:1
Shares:0

Related Content