This document provides instructions for automating Cisco switch configuration backups using the Cisco KRON scheduler utility. It describes how to configure KRON on supported Cisco switch models to back up the startup and running configurations to an FTP server on a daily basis. The configuration backups are scheduled to run every day at 6:00pm and are named to indicate the weekday, overwriting the previous day's files. Steps provided include checking the switch time/NTP settings, creating FTP credentials, defining the scheduled CLI commands in KRON policy lists, setting the scheduled occurrences, testing with a one-time backup, and verifying the KRON schedules.
Accelerate your Kubernetes clusters with Varnish Caching
Automate Cisco Switch Configuration Backups with KRON
1. Page 1 of 5
Automate Cisco Switch Configuration Backups with KRON
Created by. Travis Kench - travis@tkcomputersolutions.com - 1/29/2014
Project: Find a free solution to automate Cisco switch configuration backups.
Solution: Cisco KRON via CLI
The Cisco KRON is a command scheduler utility. It allows you to schedule commands to run
once, at system startup, or at specified dates and times.
I have tested and verified that this works on the following switch models:
2901 (VOIP Phone Gateway)
2911 (VOIP Phone Gateway)
2921 (VOIP Phone Gateway)
2951 (VOIP Phone Gateway)
2960s
3560s
3750s
I have verified that the KRON utility isn’t available on the following switch models:
2950s
3500s
Step 1: Check to see if your switch’s clock is set to the correct time.
Switch> en
Switch# sh clock
Step 2: If the switch’s clock is not set to the correct date and time I highly recommend syncing
with an internal NTP server or your primary domain controller that is syncing to an external NTP
server. I recommend this because of time changes during the year which will make this process
automated as long as your domain controller is functioning correctly and receiving the correct
date and time.
Check to see if your switch is syncing with an NTP server.
o Switch# sh ntp status
If your switch is not syncing you will need to configure an NTP server lookup to
obtain the correct date and time. Please note: I am configuring the below time
2. Page 2 of 5
zone settings because I am in New York so please pay attention if you are located
in another state/country and visit the Standard Time Zone List.
o Switch# conf t
o Switch (config)# clock timezone EST -05
o Switch (config)# ntp server x.x.x.x (IP ADDRESS)
o Switch (config)# end
Step 3: Configuring the KRON command scheduler.
Below is a prepared script that I have implemented within my network infrastructure to
automatically backup my switches startup and running configurations daily at 6:00pm. Please
note that the KRON scheduler can make use of either FTP or TFTP transfer protocols. I am
backing up both the startup and the running configs just in case someone forgets to save the
configuration on a switch after they have made changes. By default once a file is backed up to
your FTP server it will overwrite an older one with the same name so I have given the files
names that include the name of each weekday. I figured this would be a safe plan due to the fact
that the FTP server is backed up nightly at midnight so if needed I can obtain older
configurations.
There are a few items to change in the below script to personalize it for your use:
FTPIP
SWITCHNAME
FTPUSERNAME
FTPUSERPASSWORD
Step 3.1: Create an FTP user account.
Switch# conf t
Switch (config)# ip ftp username FTPUSERNAME
Switch (config)# ip ftp password FTPUSERPASSWORD
Switch (config)# end
Step 3.2: Create a kron policy-list.
conf t
kron policy-list Mon-Backup-Configs
cli show running-config | redirect ftp://FTPIP/SWITCHNAME-Running-Config-Monday.txt
cli show startup-config | redirect ftp://FTPIP/SWITCHNAME-Startup-Config-Monday.txt
end
conf t
kron policy-list Tues-Backup-Configs
3. Page 3 of 5
cli show running-config | redirect ftp://FTPIP/SWITCHNAME-Running-Config-Tuesday.txt
cli show startup-config | redirect ftp://FTPIP/SWITCHNAME-Startup-Config-Tuesday.txt
end
conf t
kron policy-list Wed-Backup-Configs
cli show running-config | redirect ftp://FTPIP/SWITCHNAME-Running-Config-Wednesday.txt
cli show startup-config | redirect ftp://FTPIP/SWITCHNAME-Startup-Config-Wednesday.txt
end
conf t
kron policy-list Thurs-Backup-Configs
cli show running-config | redirect ftp://FTPIP/SWITCHNAME-Running-Config-Thursday.txt
cli show startup-config | redirect ftp://FTPIP/SWITCHNAME-Startup-Config-Thursday.txt
end
conf t
kron policy-list Fri-Backup-Configs
cli show running-config | redirect ftp://FTPIP/SWITCHNAME-Running-Config-Friday.txt
cli show startup-config | redirect ftp://FTPIP/SWITCHNAME-Startup-Config-Friday.txt
end
conf t
kron policy-list Sat-Backup-Configs
cli show running-config | redirect ftp://FTPIP/SWITCHNAME-Running-Config-Saturday.txt
cli show startup-config | redirect ftp://FTPIP/SWITCHNAME-Startup-Config-Saturday.txt
end
conf t
kron policy-list Sun-Backup-Configs
cli show running-config | redirect ftp://FTPIP/SWITCHNAME-Running-Config-Sunday.txt
cli show startup-config | redirect ftp://FTPIP/SWITCHNAME-Startup-Config-Sunday.txt
end
Step 3.3: Create a kron occurrence schedule.
conf t
kron occurrence Mon-Backups at 18:00 Mon recurring
policy-list Mon-Backup-Configs
end
conf t
kron occurrence Tues-Backups at 18:00 Tues recurring
policy-list Tues-Backup-Configs
4. Page 4 of 5
end
conf t
kron occurrence Wed-Backups at 18:00 Wed recurring
policy-list Wed-Backup-Configs
end
conf t
kron occurrence Thurs-Backups at 18:00 Thurs recurring
policy-list Thurs-Backup-Configs
end
conf t
kron occurrence Fri-Backups at 18:00 Fri recurring
policy-list Fri-Backup-Configs
end
conf t
kron occurrence Sat-Backups at 18:00 Sat recurring
policy-list Sat-Backup-Configs
end
conf t
kron occurrence Sun-Backups at 18:00 Sun recurring
policy-list Sun-Backup-Configs
end
Step 3.4: Save your configuration.
Switch# copy run start
Step 4: Verify your KRON schedules.
Switch# show kron schedule
Output should appear similar to:
Kron Occurrence Schedule
Mon-Backups inactive, will run again in 4 days 05:06:29 at 18:00 on Mon
Tues-Backups inactive, will run again in 5 days 05:06:29 at 18:00 on Tue
Wed-Backups inactive, will run again in 6 days 05:06:29 at 18:00 on Wed
Thurs-Backups inactive, will run again in 0 days 05:06:29 at 18:00 on Thu
Fri-Backups inactive, will run again in 1 days 05:06:29 at 18:00 on Fri
Sat-Backups inactive, will run again in 2 days 05:06:29 at 18:00 on Sat
Sun-Backups inactive, will run again in 3 days 05:06:29 at 18:00 on Sun
5. Page 5 of 5
If your KRON schedules look complete then you should be all set and now you can just keep tabs on
your FTP server to make sure everything is backing up as planned.
Step 5: Testing the KRON scheduler with the oneshot command. Verify switch clock time by using
the “sh clock” command and give yourself enough time to implement the following commands.
Switch# conf t
Switch (config)# kron occurrence One-Time-Backup at 11:22 Mon oneshot
Switch (config-kron-occurence)# policy-list Mon-Backup-Configs
Switch (config-kron-occurence)# end
Switch# sh clock
If your script ran successfully you will now have a copy of that switch’s startup and running
configurations on your FTP server.