How to Backup the AP Controllers Nightly
This document will show you how to back up the Aruba Wireless AP Controllers nightly for both the flash and running-config
Begin by downloading the needed applications for this setup. Go to http://www.bitvise.com/download-area and download the bitvise tunnelier client software. Also, go to http://www.solarwinds.com/products/freetools/free_tftp_server.aspx and download the tftp server software.
Install both of these software applications on the server that you are going to be taking backups from. This would be the file server where the backups will be stored. You may already have a tftp client installed and running on the server. In this case, disregard the installation of the tftp server. Verify that you have a TFTP-Root folder on your C:\ drive. This is where the tftp program will tftp the files to.
If you navigate to the C:\Program Files (x86)\Bitvise SSH Client folder, you should now see a file called stermc.exe.
Go to the Start>Search programs and files box and type in “sysdm.cpl” and hit enter.
Go to the “Advanced” tab and click on the “Environment Variables” button
Click the new button under System Variables and type in “stermc” for variable name and “C:\Program Files (x86)\Bitvise SSH Client\stermc.exe” as the Variable value. Click “OK” and “OK” and “OK” to exit.
Open the BitVise client by going to Start>Programs>BitVise SSH Client>BitVise SSH Client
Set up the SSH Client to connect to your AP Controller. Click the Login button. The first time you connect, the client will pop-up a message that asks you if you want to save the 2048 bit SSH key for the controller in your connection profile. Click the button for Yes and Save.
Logout and disconnect from the client. Click the “Save profile as” button and save it to the C:\ drive of the server. You will need to reference this connection profile in you script later and you wan tto be able to find it easily.
Click the, “Exit” button on the SSH Client. (In the script, we will be calling for the terminal version of the BiVise SSH Client using the profile)
Next, go to the parent folder on the server where you will want to save the configs and flash backups. Create a Folder called BKUPAPCON. All of the configs and flash tar.gz files will go in there. In this example, the “F:\Backups” folder is my parent folder.
In the F:\Backups parent folder, I also want to create my .vbs script. Go to that folder and create a new text file and name it for the controller you are backing up. Change the file extension to .vbs. Right click on the file and click edit.
The .vbs script should contain the following:
'Written by Neal Ellis 08/28/2013
'For logging into the AP Controllers and copying out config and flash files
Dim WSHShell
Set WSHShell = Wscript.CreateObject("Wscript.Shell")
'Declare the variables for the timestamp on the config file
Dim strSafeDate
Dim strSafeTime
Dim strDateTime
'Build the format of the timestamp
strSafeDate = DatePart("yyyy",Date) & Right("0" & DatePart("m",Date), 2) & Right("0" & DatePart("d",Date), 2)
strSafeTime = Right("0" & Hour(Now), 2) & Right("0" & Minute(Now), 2) & Right("0" & Second(Now), 2)
'Set strDateTime equal to a string representation of the current date and time, for use as part of the config name
strDateTime = strSafeDate & "-" & strSafeTime
'Log Event 4 indicates an informational event
WSHShell.LogEvent 4, "Starting <Your AP Controller> Running-Config Copy"
'Make sure to declare stermc as a system variable first in your windows machine. Go to run and type sysdm.cpl then go to
'advanced tab and environment variables button. Declare stermc as a new system variable with the path to the stermc.exe
'Put your bitvise profile somewhere that is easy to get to. I put mine on C:\
iret = WSHShell.Run("stermc -profile=c:\yourbitviseprofile.bscp" )
'Wait for bitvise to log into the box. Sleep time is in milliseconds. 2000 = 2 seconds
WScript.Sleep 2000
'this will type "enable " into the first prompt of the Aruba controller
WSHShell.SendKeys "enable" & vbCr
'Send the keyboard keys to the terminal for your password in Aruba. Replace "yourapcontrollerenablepassword" with your actual password. Keep the quotes around the password.
WSHShell.SendKeys "yourapcontrollerenablepassword" & vbCr
'send the command to copy the running config to a tftp server with the date and time attached to the file. Replace “IPoftftpserver” with actual IP address. Replace “yourapcontrollername” with the name of your controller.
WSHShell.SendKeys "copy running-config tftp: IPoftftpserver yourapcontrollernamerunningconfig" & strDateTime & ".cfg" & vbCr
WScript.Sleep 1000
‘Create the backup flash file on the controller.
WSHShell.SendKeys "backup flash" & vbCr
WScript.Sleep 1000
'send the command to copy the flash backup to a tftp server with the date and time attached to the file. Replace “IPoftftpserver” with actual IP address. Replace “yourapcontrollername” with the name of your controller.
WSHShell.SendKeys "copy flash: flashbackup.tar.gz tftp: IPoftftpserver yourapcontrollernameflashbackup" & strDateTime & ".tar.gz" & vbCr
'exit the enable mode
WSHShell.SendKeys "exit" & vbCr
'exit the prompt to close the session with the controller
WSHShell.SendKeys "exit" & vbCr
'Wait 5 seconds for the closeout and for the file to be tftp to the server
WScript.Sleep 5000
On Error Resume Next
'Now we need to copy the config and flash files over to the backup folder where they will be stored and backed up.
WSHShell.LogEvent 4, "Starting APCON Copy from C:\TFTP-Root"
'Copy the files from tftp-root on the c:\ drive to the backup location. You can eliminate this is you are simply backing
'up the tftp-root or whatever folder your tftp server puts the file in
iret3 = WSHShell.Run("xcopy /E /C /Y /D C:\tftp-root\*.* F:\Backups\BKUPAPCON", 1, TRUE)
If iRet3 = 0 Then
WSHShell.LogEvent 0, "Copying APCON configs and flash backups termintated successfully"
Else
WSHShell.LogEvent 1, "Copying APCON configs and flash backups termintated failed"
End If
If iRet = 0 Then
WSHShell.LogEvent 0, "Logged into MSAPCON1 successfully!"
Else
WSHShell.LogEvent 1, "Logged into MSAPCON1 unsuccessfully!"
End If
Set WSHShell = Nothing
Wscript.Quit
Now you will need to clean up the tftp-root folder in order to keep it tidy. I suggest creating another .vbs script with the following:
Set fso=CreateObject("Scripting.FileSystemObject")
set fldr=fso.getFolder("C:\tftp-root")
set fldr2=fso.getFolder("F:\Backups\BKUPAPCON")
for each file in fldr.files
if dateDiff("d",file.dateLastModified,Now)>30 then file.delete
next
for each file in fldr2.files
if dateDiff("d",file.dateLastModified,Now)>365 then file.delete
next
You will now need to create a scheduled task to run these two scripts.
-Neal Ellis 08/29/2013