I was browsing videos on brainbump.net last Friday and noticed a different take on a tutorial I did regarding automatic configuration backups with the ‘archive’ command.  While watching the video, I learned a new trick.  The file name in the ‘path’ command may contain two different variables.





One variable is available for the date & time and another for the router’s hostname. To include the router hostname in the archive file filename, enter the characters $h. To include the date and time in the archive file filename, enter the characters $t. They can be used independant of each other, together or as a prefix/suffix to another word.

Examples:

SCP: path scp://10.100.100.50//cygdrive/c/tftp/$h
TFTP: path tftp://10.100.100.50/sunny-branch-$t
Local: path flash:$h$t

Problems:

Although the date/time variable is documented to work on Cisco’s site, I have not had any luck.  In all my testing, I get error when I try to use the date/time variable.  I also get a permission denied error when I try to use the timestamp variable with my tftp server. If anyone has a solution for this, I would be interested to find a solution. Here is an example of the error I get when storing to flash.

Router(config)#archive
Router(config-archive)#path $h$t
Invalid path, please include a : character
Router(config-archive)#path flash:$h$t
Router(config-archive)#wr
Router(config-archive)#^Z
Router#wr
Building configuration…

*Mar  1 00:02:21.315: %SYS-5-CONFIG_I: Configured from console by console[OK]
%Error opening flash:Router-Mar–1-00:02:28.427-1 (Illegal file character)
Router#

Update:

Shortly after I wrote my first draft of this post, a visitor left a very interesting comment on my previous posts. He answered some of the questions I presented above and shared his own struggles. I thought about rewriting the post, but I thought it would be better to leave it.  Here is the comment. Thanks Darren!

==========

To use the timestamps you have to append “$t” to your filename. However it puts the time format in the following:

Jul-28-05:10:23.794

Thus windows will not read this, all you will get is “23.794″ followed but -1 or whatever sequence number you are upto.

When I deployed this a month ago I was having great difficulty with the “time-period” command, it never worked :(
Here is how I managed to get scheduling working:

kron occurrence backup at 2:30 1 recurring
policy-list backup
!
kron policy-list backup
cli archive config

This backs up my config on the 1st of every month at 2:30am. You can also use the EEM (embedded event manager) to do something similar.

Hope this helps

==========

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Live
  • Reddit
  • StumbleUpon
  • Technorati
  • LinkedIn
  • Twitter

Post to Twitter

Related Posts: