Saturday, October 24, 2020

Automate your network device backup with a excel sheet and python - Part 2

Enter your full device inventory to a excel sheet and use it for backup your devices. with below python script your select/filter devices required to backed up.

Full Sheet in one shot backup see the Part 1

Example:



>py Backup_Devices.py
>python Backup_Devices.py

  • Step1 - Will prompt the excel sheet headings to select.
  • Step2 -  Once you selected the heading it will prompt all the unique values from the row you selected
  • Step3 - Selected devices will be printed on console for verification and prompt for authentication details of selected device

     

Once all set, Script will start to backup the device an stored into the folders.

File Path of backup file 

BASE DIR > Current Year > Current Month > Current Date > Device_Location

File Name

IP_address_Current-Date-&-Time.txt


Script is written using below python libraries

  1.     Netmiko - For  SSH and Telnet to the device and read the output.
  2.     Xlrd - For reading data and formatting information from Excel (xls or .xlsx files)
  3.     prettytable - To print tables in an attractive ASCII form


Download a copy from: 
https://github.com/arazzan/network_backup_with_python.git

Excel Sheet Sample
    A1. Device_Location    *required
    B1. Serial_Number
    C1. Device_Name_or_Hostname    *required
    D1. Device_type - Platform Support and more details in below link    *required
                                     https://pynet.twb-tech.com/blog/automation/netmiko.html
    E1. IP_address (hostname also supported, if DNS can resolve to IP)    *required
    F1. Software_Version
    G1. Model Number
    H1. Access_Method




No comments:

Post a Comment