Universal Network Backup Tool

Managing a multi-vendor network environment can be challenging. Especially when it comes to performing configuration backup tasks. Each vendor has its own approach to accomplishing such a task. Some network equipment even doesn’t have any built-in mechanism to send running-configuration to the specified server. I want to share with you a tool, that can gather configuration from various network devices, and save it on the local machine.

Overview

Universal Network Backup Tool is a script written in Python. It uses ssh to connect to the devices specified in the inventory.csv file and executes the given command. After that, CLI output is saved to the text file on the local machine.

The script was tested and is working correctly on Python 3.10. If you have issues with running this script on other Python versions, please let me know. I’ll put an annotation in this post.

Current script version: 2.0

Last update: 05.02.2022

Requirements

In order for the script to work, you need to have the Netmiko Python library present on your workstation. You can install it using pip and the requirements.txt file present in the script repository.

$ pip install -r requirements.txt

For more information about pip, please visit this website.

If you don’t have installed pip, please visit this website.

Supported platforms

This script supports plenty of network platforms, you can find a complete list in the netmiko documentation. Supported platforms may vary on the installed library version. At the end of the article, you can find a list of supported operating systems. This list is based on a netmiko version from the requirements.txt file.

Download

You can download the latest script version from the git repository.

Usage

The script usage is pretty straightforward, it boils down to three steps.

  1. Fill the config.cfg file with credentials
  2. Fill the inventory.csv file with network devices information
  3. Run UniversalNetworkBackupTool.py

And that’s it! If you’ve filled both the configuration and inventory files correctly, the commands output will be saved in the newly-created directory. By default, a new directory is created in the scripts folder, but it can be changed in the config.csv file.

Config.cfg structure

It’s a standard text file, that has to be filled before running the script for the first time. It can be opened in any text editor.

File consists of three sections:

  1. Credentials
    • username – username used for ssh login to the device.
    • password – password for the user mentioned above.
    • secret – password for privileged mode, can be left empty if you don’t use or if your user is placed directly in the privileged mode after logging in.
  2. Connection
    • port – specifies the TCP port number for ssh connection, by default it’s port 22. Change only if you have a non-standard configuration.
  3. Path
    • path – specifies the directory path where backup files will be saved, if left empty, backups will be saved to the directory created in the script folder.
  4. Options (not visible on the screenshoot)
    • autoexit – if you want the script to exit automatically after it’s completion, set the autoexit to True, otherwise stay with the default value – False

Inventory.csv structure

List of network devices is generated based on the information in the inventory.csv file. You can work on that file with a simple text editor, but I recommend opening it in Microsoft Excel, or similar software because it’s way easier to work that way.

The inventory.csv file structure consists of the following columns:

  1. Hostname – hostname of a network device, it’s used as a filename with backed-up configuration.
  2. IP – network device management IP address.
  3. Device type – a type of network device, you can find supported types in Appendix A at the end of the article.
  4. Backup command – command used to display configuration on the network device.

Running UniversalNetworkBackupTool.py

After filling both config.cfg and inventory.csv files, you can start the script.

I don’t hold any responsibility for possible errors regarding this script. Use with caution.

In the terminal window, you will be prompted with information about the current status. In case of any encountered errors/warnings, detailed information will be also displayed. In the end, you’ll receive information about the location of a directory where you can find saved command outputs.

Each file represents a device, the filename is taken from the column hostname from the invetory.csv file.

Additional information

Even tho main purpose of this script is to backup network devices configuration, you can use it for other tasks, such as inventarisation. If you replace commands displaying the device’s configuration such as show running-config to the show inventory, you’ll have inventory output saved in the task directory.

The above example was based on Cisco. Commands to display running configuration and inventory may vary from the vendor.

Summary

I hope that this script will enhance your work, and make it a bit easier.

I’m open to discussion regarding this tool. Feel free to comment down below, or contact me directly. If you find a bug, please also let me know.

Appendix A: Supported device types

  • a10
  • accedian
  • adtran_os
  • alcatel_aos
  • alcatel_sros
  • allied_telesis_awplus
  • apresia_aeos
  • arista_eos
  • aruba_os
  • aruba_osswitch
  • aruba_procurve
  • avaya_ers
  • avaya_vsp
  • broadcom_icos
  • brocade_fos
  • brocade_fastiron
  • brocade_netiron
  • brocade_nos
  • brocade_vdx
  • brocade_vyos
  • checkpoint_gaia
  • calix_b6
  • cdot_cros
  • centec_os
  • ciena_saos
  • cisco_asa
  • cisco_ftd
  • cisco_ios
  • cisco_nxos
  • cisco_s300
  • cisco_tp
  • cisco_wlc
  • cisco_xe
  • cisco_xr
  • cloudgenix_ion
  • coriant
  • dell_dnos9
  • dell_force10
  • dell_os6
  • dell_os9
  • dell_os10
  • dell_powerconnect
  • dell_isilon
  • dlink_ds
  • endace
  • eltex
  • eltex_esr
  • enterasys
  • ericsson_ipos
  • extreme
  • extreme_ers
  • extreme_exos
  • extreme_netiron
  • extreme_nos
  • extreme_slx
  • extreme_vdx
  • extreme_vsp
  • extreme_wing
  • f5_ltm
  • f5_tmsh
  • f5_linux
  • flexvnf
  • fortinet
  • generic
  • generic_termserver
  • hp_comware
  • hp_procurve
  • huawei
  • huawei_smartax
  • huawei_olt
  • huawei_vrpv8
  • ipinfusion_ocnos
  • juniper
  • juniper_junos
  • juniper_screenos
  • keymile
  • keymile_nos
  • linux
  • mikrotik_routeros
  • mikrotik_switchos
  • mellanox
  • mellanox_mlnxos
  • mrv_lx
  • mrv_optiswitch
  • netapp_cdot
  • netgear_prosafe
  • netscaler
  • nokia_sros
  • oneaccess_oneos
  • ovs_linux
  • paloalto_panos
  • pluribus
  • quanta_mesh
  • rad_etx
  • raisecom_roap
  • ruckus_fastiron
  • ruijie_os
  • sixwind_os
  • sophos_sfos
  • supermicro_smis
  • tplink_jetstream
  • ubiquiti_edge
  • ubiquiti_edgerouter
  • ubiquiti_edgeswitch
  • ubiquiti_unifiswitch
  • vyatta_vyos
  • vyos
  • watchguard_fireware
  • zte_zxros
  • yamaha
Share

Leave a Reply

Your email address will not be published. Required fields are marked *