Saturday, October 24, 2020

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

Every run of the script create a log file in base directory with all possible details, in case script fail to backup the running config of the device.

Example:
sample log file screenshot.


log file will be stored in base directory as below, name of the file will be Logging_Current_Data_&_Time.txt


For More Details: Read Part1 & 2





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




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

Script is written using below python libraries

  1.     Netmiko - For  SSH and Telnet to the device and read the output.
  1.     Xlrd - For reading data and formatting information from Excel (xls or .xlsx files)
  1.     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





Example: Backup all the devices listed in the excel sheet.

>py Backup_Devices.py
>python Backup_Devices.py
Please enter authentication details for template book "MyDevicesUploadTemplate"
"MyDevicesUploadTemplate" need to placed with this app folder
Enter User Name : admin
Enter Password :

* Authentication details of devices need to be type in. User account should have privileges to read the running config.


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