How to Save, backup or upload Configuration Script on WLC

Document

Dec 29, 2011 6:43 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?

1. 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.

2. 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

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?

2. 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

Related Links

This document was generated from the following discussion: WLC configuration script or backup?

This document was generated from the following discussion: Automatic configuration upload on WLC?

Average Rating: 5 (1 ratings)

Comments

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 6:43 AM
Stats:
Comments:1 Avg. Rating:5
Views:9851 Contributors:1
Shares:0

Related Content

Documents Leaderboard