09-06-2017 10:38 PM - edited 03-08-2019 11:56 AM
Hello Cisco Users
I have a problem with scheduling a tftp backup job with kron.
I confiured one of our C2960X with IOS 15.2(2)E3 switches like this:
kron policy-list ConfigBackup
cli copy running-config tftp://servername/switchbackup.cfg
kron occurrence ConfigBackup at 20:00 recurring
policy-list ConfigBackup
The problem is, if i set the scheduler to run the job about 5 or 10 minutes from now,
it works fine. But if i set the scheduler to run the job in about 4 hours (more then just a few minutes), it does not run the job at the scheduled time.
Does someone have the same issues?
Is there a solution for this problem?
Regards,
Daniel
Solved! Go to Solution.
09-07-2017 04:23 AM
Hello
Since i added the line "cli write" to the command, it seems to work.
kron policy-list ConfigBackup
cli write
cli copy running-config tftp://servername/switchbackup.cfg
kron occurrence ConfigBackup at 20:00 recurring
policy-list ConfigBackup
I will check tomorrow and will let you know if it works correctly now.
Thanks for your help!
Regards,
Daniel
09-06-2017 11:56 PM
Daniel,
do you have:
2960X(config-kron-policy)
configured under your policy ?
After the policy has run, is it still visible with:
show kron schedule
?
09-07-2017 12:08 AM
Hi Georg
No, i dont. You mean it should look like this?
I will try this.
kron policy-list ConfigBackup
cli write
cli copy running-config tftp://servername/switchbackup.cfg
kron occurrence ConfigBackup at 20:00 recurring
policy-list ConfigBackup
Yes, it is still visible after running:
ConfigBackup inactive, will run again in 0 days 00:23:41 at 9 :30 on
Regards,
Daniel
09-07-2017 12:22 AM
Hello,
you can also replace the cli line with a show run | redirect:
kron policy-list ConfigBackup
cli show run | redirect tftp://servername/switchbackup.cfg
kron occurrence ConfigBackup at 20:00 recurring
policy-list ConfigBackup
09-07-2017 12:56 AM
Hello Daniel,
as an alternative, you could also run a simple EEM script:
event manager applet ConfigBackup
event timer cron cron-entry "0 20 * * *" maxrun 9999999
action 1.0 cli command "enable"
action 2.0 cli command "copy running-config tftp://servername/switchbackup.cfg"
09-07-2017 12:16 AM
Hello,
sorry for the misunderstanding. The problem is that KRON does not support interactive commands that require user confirmation. Try replacing the line in bold with 'cli write' and see if that works. Also, in global config mode, configure:
2960X(config)#file prompt quiet
kron policy-list ConfigBackup
cli copy running-config tftp://servername/switchbackup.cfg
kron occurrence ConfigBackup at 20:00 recurring
policy-list ConfigBackup
09-07-2017 04:23 AM
Hello
Since i added the line "cli write" to the command, it seems to work.
kron policy-list ConfigBackup
cli write
cli copy running-config tftp://servername/switchbackup.cfg
kron occurrence ConfigBackup at 20:00 recurring
policy-list ConfigBackup
I will check tomorrow and will let you know if it works correctly now.
Thanks for your help!
Regards,
Daniel
07-06-2018 02:40 AM
Hi Daniel,
I have exactly the same problem, but only to some Switches. I configured for 40 Switches, 34 of them are working fine and 6 Switches have this problem. I also noticed that the policy-list will also remove from the Switch config and at the scheduled time and only the last two commands "kron occurrence ConfigBackup at 20:00 recurring, policy-list ConfigBackup" will remain.
How did you solve the problem?
Regards
Motiar
07-06-2018 04:09 AM - edited 07-06-2018 04:10 AM
Hi Motiar
I use the following commands:
Enable Auto Backup:
----------------------------------------------
conf t
kron policy-list ConfigBackup
cli write
cli copy running-config tftp://your_ftp_server/switch01.cfg
exit
kron occurrence ConfigBackup at 18:00 recurring
policy-list ConfigBackup
exit
exit
wr
----------------------------------------------
Remove Auto Backup:
----------------------------------------------
conf t
no kron policy-list ConfigBackup
no kron occurrence ConfigBackup at 18:00 recurring
exit
wr
----------------------------------------------
Change the Backup Time:
----------------------------------------------
conf t
kron occurrence ConfigBackup at 18:00 recurring
policy-list ConfigBackup
exit
exit
wr
----------------------------------------------
Show Backup Plan:
----------------------------------------------
sh kron schedule
----------------------------------------------
This works with all our Switches WS-C2960X-48LPD-L / WS-C4500X-16
Hope this helps.
Regards,
Daniel
07-11-2018 12:30 AM
Guten Morgen Daniel,
Thank you for your details guidelines and indeed, it does work for my rest of the switches!! Actually ca. 40 Switche work perfectly with my following redirect commands with file format. And the 6 Switche work only with your suggested config (at the bottom) with .cfg format, even without cli write command. I don't know why.
conf t
kron policy-list BackupConfig
cli show run | redirect tftp://TFTP-Server/Switch01
exit
kron occurrence BackupConfig at 22:00 recurring
policy-list BackupConfig
--
conf t
kron policy-list BackupConfig
cli copy running-config tftp://TFTP-Server/Switch10.cfg
exit
kron occurrence BackupConfig at 22:30 recurring
policy-list BackupConfig
regards
Motiar
11-01-2018 09:59 PM
Hi,
When am scheduling a kron to copy the running-config to a tftp server for every 5 min. Fort first time running config file got saved in TFTP server but on next schedule it throws an error "Not allowed to overwrite the existing file" in TFTP server. Running config files are not getting copied plz help.
Switch(config)#kron policy-list Daily-backup
Switch(config-kron)#cli show running-config | redirect tftp://10.0.0.10/configfile
Switch(config-kron)#exit
Switch(config)#kron occurrence Daily-backup in 5 recurring
Switch(config-kron)#policy-list Daily-backup
Switch(config-kron)#exit
Please suggest.
05-12-2019 05:54 PM
Have you looked at using the archive command rather than the kron?
https://www.cisco.com/c/en/us/td/docs/ios/fundamentals/command/reference/cf_book/cf_a1.html
So you would enter archive in the global config
Under that you set the path to use; in your case that is:
tftp://10.0.0.10/
I personally would use a folder setup so each switch would save their configs to a separate folder. So the command would look more like this:
tftp://10.0.0.10/switch1/configfile
You would also issue:
write memory
The last command would be time-period
So it would look something like this:
archive
path tftp://10.0.0.10/switch1/configfile
write-memory
time-period 1440
The above will save the config every 24 hours (1440 minutes). If you put the switch name in the path like switch2, switch3, etc. every switch will backup to its own folder. Also, with archive, it keeps multiple copies. You can even use the show archive command to see them. What archive cannot do is is be schedule for a specific time. If you wanted to backup every 8 hours you can do that by adjusting the time-period. When it does save the config it adds a timestamp to the name.
If you want to use kron, then your TFTP server will need to allow files to be overwritten.
06-03-2019 03:58 AM
Hi Lanbrown,
Thank you for your contribution. I have tried, it works!
best regards
Motiar
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