Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
My beginning attempt at networking device backups

This is my beginning attempt at making a networking device backup script. This script uses netmiko for communicating with the devices. I would love feed back.

Edit: Here is a link to the code in better formatting https://pastebin.com/V1tG8hCM

from netmiko import ConnectHandler
from datetime import datetime
from secrects import switchuser, switchpassword
import os
import json


devicelist = '/home/vetadmin/scripts/switch.json'
#skippagedisplay = "skip-page-display"
#pagedisplay = "page-display"
showrun = "show run"
#showhostname = "show run | inc hostname"
date = datetime.now().strftime("%Y%m%d")
s = 0
d = 0

#Creating the log file
logpath = ("/home/vetadmin/scripts/logging/")
if not os.path.exists(logpath):
os.makedirs(logpath)
l= open ("/home/vetadmin/scripts/logging/switchbackup.log", "a")
l.write("\n" + date + "\n")

#Opening the switch.json file that has all the switch ip information
with open(device
list)

/r/Python
https://redd.it/q3xbsn