Backup your saved Cisco configuration from your device to a folder with the hostname, date, and time. You have the option of having it all imported from a CSV file, or manually giving it the IP, Username, Password, and Enable Secret of each host.
This is running on Python3 with Netmiko, and ping3. Version 2.0
Manual Option:
CSV Option:
The use case is that you are needing a backup of the saved configuration on your routers or switches.
- You must have Python3 and PIP installed on the device you are running the program on.
- You need to run
pip3 install netmiko
orpip install netmiko
in a command prompt / terminal on your computer. - You need to run
pip3 install ping3
orpip install ping3
in a command prompt / terminal on your computer. - You need to download this repository or copy all of the contents of the run.py file into a python file.
To run this, you need to run python3 ni_run_cisco.py
or python3 ni_run_huawei.py
in your terminal or command prompt. Host list will be taken from files cisco_backup_hosts.csv
or huawei_backup_hosts.csv
. So, please populate the right file depending on the vendor you are using.
It will copy the saved configuration into a folder named backup-config
in the same directory of the python file. The configuration file name will be the Cisco device hostname, date, and time. Unreachable hosts will be listed in a separated file named downDevices_
+ date and time.
To run this, you need to run python3 i_run.py
in your terminal or command prompt. You'll get a prompt asking if you want to load the login information from a CSV file
or manually fill it in. If you choose the CSV option, you will need said CSV file in the same directory as the Python script.
It will copy the saved configuration into a folder named backup-config
in the same directory of the python file. The configuration file name will be the Cisco device hostname, date, and time.
If you are on Linux or MacOS, you need to use sudo python3 i_run.py
to run this due to the ping requiring permissions.
Work in progress...
This code was last tested March 9th, 2021. The dependencies you need to run it are Python3, PIP, Netmiko, and Ping3.
If you are having trouble or need help, create an issue here
ste-giraldo for adding a memory and cpu saving feature to grabbing the hostname, and suggesting the ping feature.
I'd like to credit Kirk Byers for making Netmiko, and Kyan for making Ping3
This code is with the MIT license.