Auto Backup Cisco Router & Switch with Kron and FTP Server
Briefing: In Cisco routers or switches, Kron lets you schedule an automatic backup task to save your running-configs or startup-configs. Also useful to backup IOS images, boot from FTP, copy SDM/ASDM files, and more. In the first example ill configure kron to copy the running-config to startup-config, every Automatically. The second example ill configure kron to send backups of the running-config to vsftpd FTP server.
Issues: In order to copy the running-config to startup-config we need to use write(wr) not “copy running-config startup-config”, this is because kron does not support interactive prompts and the “copy running-config startup-config” command requires interaction. It is important to remember this. Also, kron does not support configuration commands. As for sending files to vsftpd server, it needs to use redirect output.
Manual Backup & Restore
Configure your Cisco Router or Switch FTP settings
Iv previously configured a username: ftp1 with a password: cisco on my vsftp server. That will be used for this purpose.
Configure the clock with the current time.
CR1# clock set 11:41:00 4 April 2012
CR1#
*Apr 4 11:41:00.000: %SYS-6-CLOCKUPDATE: System clock has been updated from 00:09:40 UTC Fri Mar 1 2002 to 11:41:00 UTC Wed Apr 4 2012, configured from console by console.
CR1# show clock
11:41:09.783 UTC Wed Apr 4 2012
CR1#
Configure FTP login parameters
CR1# conf t
CR1(config)# ip ftp username ftp1
CR1(config)# ip ftp password cisco
CR1(config)# end
CR1#
Backup running-config to ftp server (192.168.1.131)
CR1# copy running-config ftp:
Address or name of remote host []? 192.168.1.131
Destination filename [cr1-confg]? backup-config01
Writing backup-config01 !
833 bytes copied in 2.800 secs (298 bytes/sec)
Here is the tail output from the vsftpd server log:
Wed Apr 4 23:42:29 2012 1 192.168.1.14 833 /backup-config01 b _ i r ftp1 ftp 0 * c
Note: to restore the config file into nvram just issue: copy tftp: running-config
Automatic Local Backup using Kron
This task is configured in three steps.
Step 1. Create a kron policy-list.
This will tell what commands the router should run at the scheduled time.
CR1(config)# kron policy-list AutoSaveConfig
CR1(config-kron-policy)# cli write
CR1(config-kron-policy)# exit
Step 2. Create the kron occurrence.
This tells the router when and how often the policy should run.
CR1(config)# kron occurrence AutoSaveConfigSchedule at 00:40 Thu recurring
CR1(config-kron-occurrence)# policy-list AutoSaveConfig
Verify the kron configuration.
CR1# sh kron schedule
Kron Occurrence Schedule
AutoSaveConfigSchedule inactive, will run again in 0 days 00:05:36 at 00:35 on Thu
You can view the kron configuration in the running-config:
CR1# show run | s kron
kron occurrence AutoSaveConfigSchedule at 00:35 Thu recurring
policy-list AutoSaveConfig
kron policy-list AutoSaveConfig
cli write
Automatic Backup to vsftpd FTP Server using Kron
Ill send the router’s running-config to my svftpd FTP server 192.168.1.131, every Thursday at 01:30:00.
CR1(config)# kron policy-list Backup_FTP
CR1(config-kron-policy)# cli show run | redirect ftp://192.168.1.131/ciscoback1.cfg
CR1(config-kron-policy)# exit
CR1(config)# kron occurrence Backup at 01:30 Thu recurring
CR1(config-kron-occurrence)# policy-list Backup_FTP
CR1(config-kron-occurrence)# end
CR1# show kron schedule
Kron Occurrence Schedule
AutoSaveConfigSchedule inactive, will run again in 0 days 00:02:00 at 1 :30 on Thu
Backup inactive, will run again in 0 days 00:01:22 at 1 :30 on Thu
Here is tail output from the vsftpd log:
Thu Apr 5 01:29:48 2012 1 192.168.1.14 1044 /ciscoback1.cfg b _ i r ftp1 ftp 0 * c
And here is the confirmation in the running-config that the backup was successful.
CR1# show run
Building configuration...
!
Current configuration : 1042 bytes
!
! Last configuration change at 01:25:17 UTC Thu Apr 5 2012
! NVRAM config last updated at 01:30:39 UTC Thu Apr 5 2012
!
...
Hope you found it useful.copyrigth:
https://ethernuno.wordpress.com/2012/04/05/auto-backup-cisco-routerswitch-using-kron-and-vsftpd-ftp/