10-08-2024 02:30 AM
Hello,
Can we make schedule to backup cisco WLC to the SCP server?
10-08-2024 02:31 AM
Depends if the WLC is AireOS or IOS-XE.
10-08-2024 02:35 AM
I use WLC 2504 with OS version 8.5.182 (i believe this is AireOS), right?
10-08-2024 02:51 AM
Yes, that's AireOS.
You will need to script it.
10-08-2024 03:03 AM
are you know the script?
10-08-2024 02:18 PM
Script logic would be
SSH to WLC
Issue backup commands
WLC1) >transfer upload mode tftp
(WLC1) >transfer upload datatype config
(WLC1) >transfer upload filename 10_xx_yy_1_160802_2200.cfg
(WLC1) >transfer upload path /
(WLC1) >transfer upload serverip 192.168.10.1
(WLC1) >transfer upload start
Using ChatGPT asking to create a python script to backup an AireOS WLC to a SCP server returns this (please validate before runing against a prod WLC
import paramiko
from scp import SCPClient
# WLC and SCP server details
wlc_ip = 'WLC_IP_ADDRESS' # Replace with your WLC IP
wlc_username = 'WLC_USERNAME' # Replace with WLC username
wlc_password = 'WLC_PASSWORD' # Replace with WLC password
scp_server_ip = '192.1.1.1'
scp_username = 'SCP_USERNAME' # Replace with SCP server username
scp_password = 'SCP_PASSWORD' # Replace with SCP server password
remote_backup_dir = '/backup_directory/' # SCP server path where file will be stored
# WLC config file path
wlc_config_file = '/path/to/wlc/config/file'
# SSH and SCP functions
def create_ssh_client(host, username, password):
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(host, username=username, password=password)
return client
def backup_wlc_config_to_scp():
try:
# Connect to WLC via SSH
ssh_client = create_ssh_client(wlc_ip, wlc_username, wlc_password)
print("Connected to WLC")
# Command to generate backup or get WLC configuration if needed
# stdin, stdout, stderr = ssh_client.exec_command('show running-config')
# output = stdout.read().decode()
# Connect to SCP server
with SCPClient(ssh_client.get_transport()) as scp:
print("Connected to SCP server")
# Transfer WLC config file to SCP server
scp.put(wlc_config_file, remote_backup_dir)
print(f"Backup transferred to {scp_server_ip}:{remote_backup_dir}")
except Exception as e:
print(f"Error: {str(e)}")
finally:
ssh_client.close()
if __name__ == "__main__":
backup_wlc_config_to_scp()
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide