Automatic Configuration Backup With Version Control


There are a variety of devices that have a multitude of ways to backup their configuration, although often you find yourself needing to purchase additional tools from a vendor to do so, or be forever stuck with copying that pesky switch, router, proxy or other configuration to some TFTP server on some (hopefully) regular schedule.  In 2009, I set Matt Heckman on the task to create a process to create an automatic configuration backup for a variety of our network devices and the results have served us well ever since.

The automatic configuration backup will connect to a network device, execute a series of commands

Requirements:  WinSCP (for sftp support), Windows Powershell (with appropriate script execution policies), putty suite, SVN server

 

CbAddDeviceCred.ps1

Run this script first to output securely stored credential files.  The files can only be decrypted by the user who encrypts them, so make sure you run powershell as whatever service account you intend to run this process.

CBFunctions.ps1

 

 

The meat, this file contains the necessary pieces to backup different types of devices

ConfigBackup.ps1

This file defines the jobs you wish to run.  As you see, you can backup SSH or Sftp devices fairly easily.  You must have WinScp installed to take advantage of the SFTP functionality, and you need and SVN client (in our case, this runs from the same server that runs SVN server, which has a SVN client built in)

WinSCPFunctions.ps1

The bits necessary for SFTP support.

 

/DeviceScripts/*

This directory contains example device scripts of commands to issue for each device type.  The CSV format is used to issue a command, expected response in the case of unusual console output.

Leave a Reply