How to backup and restore configurations on lots of Cisco routers and switches from Linux?
This is what I found was by far the easiest to manage... though it is a bit rough, especially for people who dont like the CLI.
http://sourceforge.net/projects/cosi-nms/files/ciscocmd/
This is an expect script used to send commands to lots of cisco devices.
It allows you to pass in a file with the name of all your devices and the commands you want executed on the devices.
I just have it tftp configs to our central config tftp server nightly.
copy system:running-config tftp://mytftpserver/this-router-config
To restore you could just apply:
copy tftp://mytftpserver/this-router-config system:running-config
A simple example would be to have a file called "myrouters"
--- CUT ---
#!/bin/sh
DATE=`date +%Y%m%d`
for THISHOST in `cat myrouters`
do
ciscocmd [auth params] -c "copy system:running-config tftp://mytftpserver/$THISHOST.$DATE"
done
--- CUT ---
This creates a config file called routerx.20130707
If you change
DATE=`date +%Y%m%d`
to
DATE=`date +%w`
you would just have a rolling 7 day window of configs routerx.1, routerx.2, .. routerx.7
Above is a very simplified example, but this is mostly what I do. I actually have a "config-backup.sh" and a "config-restore.sh".
Each script takes the params of a filename filled with the device names and the second parameter is the date in "YYYYMMDD". If it is a backup, it appends the date to the config filename. If it is a restore, it tells to devices to load "$HOST.$DATE".
I run the backups out of cron.
With this I can very easily restore anything just with SSH from my phone.
Related videos on Youtube
![mimipc](https://i.stack.imgur.com/vCIuT.png?s=256&g=1)
mimipc
Updated on September 18, 2022Comments
-
mimipc almost 2 years
I'm looking for a way to backup, save, version and restore configurations of Cisco network equipments.
I need to be able to automatically GET and PUSH configuration files on lots of routers and switches.
I'm looking for some kind of Linux alternative to
Orion
so I could :- Automatically get the configuration from a device when it's changed (triggered by a syslog)
- Save every version of a configuration
- Push a configuration on a single device
- Push a configuration on a bunch of devices in a scripted way
So I had a look at what could appear to be a nice solution, and I found nothing meeting those criterias. It's very strange there isn't a Linux thing built for those needs.
Here's what I found :
- Rancid is a nice script that can get configurations and save every version in a CVS or SVN repository
- Syslog-ng could help me tell Rancid to check again the config of a device when a syslog is sent
- CVS/SVN/Git/Whatever could achieve versionning and provide nice diffs
- I could push configs with clogin (Rancid) but this isn't nice at all
- I could push configs with TFTP but i'd have to script it (mostly for mass deployment).
Am I missing a tool providing functionnality I need? It's strange it doesn't exist on Linux.
Thanks for your help :)
-
Admin almost 11 yearsWanted to mention Rancid before reading the full post :) What you already mentioned already seems like the most sensible solution using tools that are already available. I have to say I'm curious too if there's some tool that can do that in a more simple way.
-
Admin almost 11 yearsPuppet supports pushing config to devices.
-
Admin almost 11 yearsThank you both for your answers. @Zoredache : I've used Puppet for servers but I didn't know it also worked on Cisco devices. I'll give it a try and see if it's a great deal ;)
-
Admin almost 11 yearsGood luck. I haven't actually tries it yet.
-
Admin almost 11 yearsCisco's LMS is a great tool...