In this post we’ll see how to automate the backup of our Cisco devices. In this way, we avoid to do it manually each time we make any change.

Let’s suppose we have a router or switch configured. We also have a TFTP server available in the network.

First we test TFTP server’s reachability:

kron_1

Now we need to configure the path were the backups will be stored. To do this, specify the IP address of the TFTP server and the name of the filenames. With the path command we set the server IP address, and with the $h parameter we set the filename, that will be the same than the router hostname:

kron_2

And also we need to set up the occurrence time. With this we will tell our device at what time and with which frequency it will contact the TFTP server and upload to store its configuration:

kron_3

Last but not least, let’s check our config is working as expected. We got the following file in the root folder of our TFTP server:

Building configuration…

Current configuration : 1174 bytes
 !
 ! Last configuration change at 16:24:37 EET Tue Jul 28 2009
 !
 version 12.2
 service config
 service timestamps debug datetime msec
 service timestamps log datetime msec
 no service password-encryption
 !
 hostname R1
 !
 boot-start-marker
 boot-end-marker
 !
 !
 !
 no aaa new-model
 !
 !
 !
 !
 !
 !
 !
 !
 !
 !
 !
 !
 ip domain name cisco.lab
 ip cef
 no ipv6 cef
 !
 multilink bundle-name authenticated
 !
 !
 !
 !         
 !
 !
 !
 !
 username cisco privilege 15 secret 5 $1$cmAq$5lwBWmGQeDYQLqZrm66h5.
 !
 !
 !
 ! 
 !
 !
 !
 !
 !
 !
 !
 !
 !
 !
 !
 !
 interface Ethernet0/0
  ip address 172.17.172.120 255.255.255.224
 !
 interface Ethernet0/1
  ip address 10.210.0.1 255.255.255.0
 !
 interface Ethernet0/2
  no ip address
  shutdown
 !
 interface Ethernet0/3
  no ip address
  shutdown
 !
 ip forward-protocol nd
 !
 !
 no ip http server
 no ip http secure-server
 ip route 0.0.0.0 0.0.0.0 172.17.172.97
 ip route 10.210.0.0 255.255.0.0 10.210.0.2
 !
 kron occurrence backup at 16:25 Tue recurring
  policy-list backup
 !
 kron policy-list backup
  cli write
  cli show run | redirect tftp://172.17.172.90/$h
 !
 !
 !
 !
 control-plane
 !
 !
 !
 !
 !
 !
 !
 !
 line con 0
  logging synchronous
 line aux 0
 line vty 0 4
  login local
  length 0 
  transport input ssh
 !
 !
 end