Wed 30 Jul 2008
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
==========

(4 votes, average: 4.25 out of 5)







July 31st, 2008 at 9:43 am
Just used the path flash:$h$t variable on a customer’s 1811 router and worked great! no issues.
August 2nd, 2008 at 10:21 pm
James,
Thanks for sharing your experience.
I still don’t know what my problem was. It could have been that I was using GNS3 at the time or the tftp server I was using may have not worked correctly either.
Josh
September 8th, 2008 at 4:26 pm
I’m testing this at the moment. Saving to a subdirectory on flash disk. It all works fine except when I use the “$t” variable. It saves with a filename like this:
disk2:archives/Sep–8-23:21:30.588-IST-1
However the “sh archive config diff” command cannot read the file:
Error: Could not open file disk2:archives/Sep–8-23:21:30.588-IST-2 for reading
When I do not use the “$t” variable, config diff works fine. “configure replace” works fine, regardless.
September 23rd, 2008 at 7:58 pm
Hi Darren here (from Josh’s post above). Thanks for your kind words josh, keep it up and I don’t know if I’ll be able to fit my head through the door haha.
Paul:
when you say “it saves with a filename like this”, did you just obtain that from running the command “sh archive”? the reason why I bring this up is because that is how the your device will see the filename (regardless if the OS can write that filename or not).
Also what is the output after you run your write mem.
This is the output of one of my switches using automatic archive:
hostname#wr me
Building configuration…
[OK]!
notice the “!”, if you see this the auto archive has worked. if you see a number of “.” it means it has not worked for one reason or another (say network connection, incompatible filename with the OS etc).
September 23rd, 2008 at 10:09 pm
you may see more “!”, depending on how long it takes to copy across your config (size/network speed etc)
October 1st, 2008 at 1:38 pm
Hi Darren,
thanks for the response. That is the exact filename on the filesystem using “dir”. The “OS” in question is the cisco IOS itself - I am saving to a local flash disk on the router. The config archives successfully (I see the ‘!’), but whatever way the code is written, the “sh archive config diff” command doesn’t like the filename, while “configure replace” can deal with it. I suspect the colons are what’s upsetting it…
October 13th, 2008 at 12:33 pm
What if you manually gave the archive a name (something that doesn’t have special characters)? Do you get the same problem?
October 13th, 2008 at 12:39 pm
dazamaz,
I don’t have any issues if I specify a name only when I try the time variable.
Josh
October 14th, 2008 at 8:07 am
could possibly be as paul suggested, maybe it is not liking the colons…
I will do some testing as well and get back to you guys