Posts

Showing posts with the label backup

Multiple Cisco device configuration Backup using python Script

Image
 Multiple Cisco device configuration Backup using python Script Device configuration will be saved as per Hostname.    Saved files are looking as below:  ===================  Python Script: ===================  from netmiko import ConnectHandler import pandas as pd import datetime import os # Read device information from the Excel file device_file = "devices.xlsx" devices_df = pd.read_excel(device_file) # Convert the dataframe to a list of dictionaries devices = devices_df.to_dict( orient = 'records' ) # Directory to save the configuration files output_directory = "device_configs" os.makedirs(output_directory, exist_ok = True ) # Define the commands to be executed commands = [ 'show running-config' , 'show ip interface brief' , 'show version' ] # Get the current date current_date = datetime.datetime.now().strftime( "%Y-%m-%d" ) # Function to connect to a device and save the output to a file def connect_and_save (...

Multiple Cisco device Backup Python Script using Telnet with different port

Image
 Multiple device Backup Python Script using Telnet with different port File will be saved using Device IP address   Need to create a xl file the same file location as named device Create an Excel file (e.g., devices.xlsx )  from netmiko import ConnectHandler import pandas as pd import datetime import os # Read device information from the Excel file device_file = "devices.xlsx" devices_df = pd.read_excel(device_file) # Convert the dataframe to a list of dictionaries devices = devices_df.to_dict( orient = 'records' ) # Directory to save the configuration files output_directory = "device_configs" os.makedirs(output_directory, exist_ok = True ) # Define the commands to be executed commands = [ 'show running-config' , 'show version' ] # Get the current date current_date = datetime.datetime.now().strftime( "%Y-%m-%d" ) # Function to connect to a device and save the output to a file def connect_and_save ( device ): try : ...