Hi mates,
a customer asked me how to automate the configuration backup for the internal switches. There are some 2950, 3750 , 3560 and so on.
Unfortunately there are a lot of non-free solutions but searching a little bit deeper I discovered that Cisco provides at least two different ways to do this.
So first of all you have to identify the server that will host the backup files.
Second identify which protocol you want to use to send, over the network, the backup to the selected server.
In my situation I've choose TFTP. There's a free TFTP server solution from Solarwind that is simple and works.
I've explained, briefly, two different solution : Kron and Archive.
With Kron you schedule an action to be done periodically. Kron does accept only EXEC CLI commands and, practically speaking, you will configure two different processes : a policy (that includes commands) and the scheduling (specifying the interval).
The most important part of the procedure will be the command to make the backup :
show running-config | redirect tftp://mypreferredserver/Chicago_Main_switch_running.conf
show startup-config | redirect tftp://mypreferredserver/Chicago_Main_switch_startup.conf
Let's go ahead with the entire procedure:
Chicago-Master-1A342>en
Password:
Chicago-Master-1A342#conf t
Enter configuration commands, one per line. End with CNTL/Z.
# in the next three lines we configure the policy : policy name (weekly-backup) and then the two command line that we want to execute
Chicago-Master-1A342(config)#kron policy-list weekly-backup
Chicago-Master-1A342(config-kron-policy)#cli show startup-config | redirect tftp://myinternalserver(IP)/chicago_master_startup.conf
Chicago-Master-1A342(config-kron-policy)#cli show running-config | redirect tftp://myinternalserver(IP)/chicago_master_running.conf
Chicago-Master-1A342(config-kron-policy)#exit
# in the next two lines we schedule the job : first of all we plan and fix the scheduling, then we tell to the switch which policy associate to the previous scheduling
Chicago-Master-1A342(config)#kron occurrence WeekBackup at 1:00 Sun recurring
Chicago-Master-1A342(config-kron-occurrence)#policy-list weekly-backup
Chicago-Master-1A342(config-kron-occurrence)#exit
Chicago-Master-1A342(config)#exit
# here we double check the scheduling
Chicago-Master-1A342#show kron schedule
Kron Occurrence Schedule
sunday inactive, will run again in 4 days 16:35:18 at 1 :00 on Sun
This was only an example. If you want you can find more than one.....for instance : I had to simulate the backup adding, at the end of the scheduling command , the magic word "oneshot".
Anyway here below one of the official article that could give you more informations :
http://www.cisco.com/c/en/us/td/docs/ios-xml/ios/cns/configuration/xe-3s/asr1000/cns-xe-3s-asr1000-book/cns-cmd-sched.html
The same goal could be achieved using a different approach : using the Archive feature (only from IOS version 12.3(4)).
In case of several devices you can choose this approach :
Chicago-Master-1A342>en
Password:
Chicago-Master-1A342#conf t
# here you define the TFTP server and the frequency of the archiving (ie 1440 minutes = 1 day)
# additionally I've added that every time that a "write-memory" event happens it saves the configuration
Chicago-Master-1A342#Archive
Chicago-Master-1A342# Path tftp://(IP)/(FileName)
Chicago-Master-1A342# Time-period (time in minutes)
Chicago-Master-1A342# Write-memory
Chicago-Master-1A342# End
Chicago-Master-1A342# Write
If you want to check the backup situation you can type in the following command :
Chicago-Master-1A342#show archive
The maximum archive configurations allowed is 14.
The next archive file will be named tftp://1.2.3.4/chicago_master_running_22-04-02-29-USA04
Archive # Name
1 tftp://1.2.3.4/chicago_master_running_22-04-02-29-USA01
2 tftp://1.2.3.4/chicago_master_running_22-04-04-29-USA02
3 tftp://1.2.3.4/chicago_master_running_22-04-07-29-USA03 <- br="">
->
As you can see the third line represents the latest backup and is highlighted with a sort or arrow (<- br="">
As a final tips you can set up some variables inside the file path that you specified before : $h and $t would do the trick.
Hope this could help you or at least could be a starting point from which to deploy and organize your backup strategy.
See you soon
Bye
->
No comments:
Post a Comment