Automated network configuration backup with Git versioning, compliance checking, and change detection
Features β’ Installation β’ Usage β’ Supported Devices
The Network Config Backup Tool provides enterprise-grade automated configuration backup for multi-vendor network environments. It combines Netmiko for device connectivity, Git for version control, and intelligent diff analysis for change detection.
| Challenge | Solution |
|---|---|
| Manual backups are inconsistent | Scheduled automated backups |
| No version history | Git-based versioning with full history |
| Change tracking is difficult | Automated diff reports and notifications |
| Multi-vendor complexity | Unified interface for Cisco, Juniper, Arista, Palo Alto |
| Compliance verification | Built-in compliance rule engine |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CORE CAPABILITIES β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π¦ BACKUP β π ANALYSIS β π ALERTS β
β βββββββββββββββββ β βββββββββββββββββ β βββββββββββββββββ β
β β’ Running Config β β’ Diff Detection β β’ Email Reports β
β β’ Startup Config β β’ Change Summary β β’ Slack Webhook β
β β’ Full State β β’ Compliance Check β β’ Teams Notify β
β β’ Custom Commands β β’ Security Audit β β’ Syslog β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π VERSION CONTROL β π
SCHEDULING β π SECURITY β
β βββββββββββββββββ β βββββββββββββββββ β βββββββββββββββββ β
β β’ Git Integration β β’ Cron Jobs β β’ Encrypted Creds β
β β’ Branch per Site β β’ Interval Based β β’ SSH Key Auth β
β β’ Commit History β β’ On-Demand β β’ Vault Support β
β β’ Tag Releases β β’ Change Triggered β β’ Audit Logging β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Vendor | Platforms | Connection |
|---|---|---|
| Cisco | IOS, IOS-XE, IOS-XR, NX-OS, ASA | SSH |
| Juniper | Junos (SRX, EX, MX, QFX) | SSH/NETCONF |
| Arista | EOS | SSH/eAPI |
| Palo Alto | PAN-OS | SSH/API |
| Fortinet | FortiOS | SSH |
| HP/Aruba | ProCurve, ArubaOS | SSH |
| Linux | Any SSH-accessible server | SSH |
# Clone repository
git clone https://github.com/tamersaid2022/network-config-backup.git
cd network-config-backup
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# Install dependencies
pip install -r requirements.txt
# Initialize Git repository for backups
cd backups && git initnetmiko>=4.2.0
paramiko>=3.3.0
pyyaml>=6.0
gitpython>=3.1.0
cryptography>=41.0.0
jinja2>=3.1.0
rich>=13.0.0
python-dotenv>=1.0.0
schedule>=1.2.0
requests>=2.31.0from network_backup import NetworkBackup
# Initialize backup manager
backup = NetworkBackup(
inventory="inventory.yaml",
backup_dir="./backups",
git_enabled=True
)
# Backup all devices
results = backup.backup_all()
# Backup specific device
backup.backup_device("core-router-01")
# Generate change report
report = backup.diff_report(days=7)# Backup all devices in inventory
python network_backup.py backup --all
# Backup specific device
python network_backup.py backup --device core-router-01
# Backup by group/tag
python network_backup.py backup --group datacenter
# Show recent changes
python network_backup.py diff --days 7
# Run compliance check
python network_backup.py compliance --rules rules/security.yaml
# Schedule backups (runs every 6 hours)
python network_backup.py schedule --interval 6h# inventory.yaml
---
defaults:
username: admin
timeout: 30
devices:
core-router-01:
host: 192.168.1.1
device_type: cisco_ios
groups: [datacenter, core]
core-router-02:
host: 192.168.1.2
device_type: cisco_ios
groups: [datacenter, core]
firewall-01:
host: 192.168.1.10
device_type: paloalto_panos
groups: [datacenter, security]
switch-access-01:
host: 192.168.2.1
device_type: cisco_ios
groups: [access, floor1]
groups:
datacenter:
backup_commands:
- show running-config
- show version
- show inventory
security:
backup_commands:
- show config running
- show system info# rules/security.yaml
---
name: "Security Baseline"
version: "1.0"
rules:
- name: "SSH Version 2 Required"
pattern: "ip ssh version 2"
required: true
severity: HIGH
remediation: "Configure 'ip ssh version 2'"
- name: "No Telnet"
pattern: "transport input telnet"
prohibited: true
severity: CRITICAL
remediation: "Remove telnet from line configurations"
- name: "Enable Secret Configured"
pattern: "enable secret"
required: true
severity: HIGH
- name: "NTP Configured"
pattern: "ntp server"
required: true
severity: MEDIUM
- name: "Logging Enabled"
pattern: "logging buffered"
required: true
severity: MEDIUMββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β NETWORK CONFIGURATION BACKUP REPORT β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£
β Timestamp: 2024-01-15 14:30:00 β
β Total Devices: 25 β
β Successful: 23 β
β Failed: 2 β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£
β BACKUP STATUS β
β ββ core-router-01 β
SUCCESS 2.3 KB Changed β
β ββ core-router-02 β
SUCCESS 2.1 KB No Change β
β ββ firewall-01 β
SUCCESS 45 KB Changed β
β ββ switch-access-01 β FAILED Timeout β
β ββ switch-access-02 β
SUCCESS 1.8 KB No Change β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£
β GIT COMMIT: a3f7c2d - "Automated backup 2024-01-15" β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CONFIGURATION CHANGE REPORT (7 Days) β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£
β Device: core-router-01 β
β Changes: 3 commits β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£
β β
β [2024-01-15 10:30] Added VLAN 100 β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β + vlan 100 β
β + name PRODUCTION β
β + interface Vlan100 β
β + ip address 10.100.0.1 255.255.255.0 β
β β
β [2024-01-14 16:45] Updated ACL β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β - access-list 101 permit ip 10.0.0.0 0.255.255.255 any β
β + access-list 101 permit ip 10.0.0.0 0.0.255.255 any β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β COMPLIANCE AUDIT REPORT β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£
β Baseline: Security Baseline v1.0 β
β Devices: 25 scanned β
β Compliant: 20 (80%) β
β Non-Compliant: 5 (20%) β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£
β FINDINGS β
β β
β π΄ CRITICAL (2) β
β ββ switch-access-05: Telnet enabled on VTY lines β
β ββ switch-access-12: Telnet enabled on VTY lines β
β β
β π HIGH (3) β
β ββ switch-access-03: SSH version 1 in use β
β ββ switch-access-07: No enable secret configured β
β ββ switch-access-09: SSH version 1 in use β
β β
β π‘ MEDIUM (5) β
β ββ 5 devices missing NTP configuration β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
network-config-backup/
βββ network_backup.py # Main backup script
βββ inventory.yaml # Device inventory
βββ config/
β βββ settings.yaml # Global settings
βββ rules/
β βββ security.yaml # Security compliance rules
β βββ best-practices.yaml # Best practice checks
β βββ pci-dss.yaml # PCI-DSS requirements
βββ backups/ # Git-versioned backups
β βββ datacenter/
β β βββ core-router-01.cfg
β β βββ core-router-02.cfg
β βββ branch/
β βββ branch-router-01.cfg
βββ reports/
β βββ compliance_YYYYMMDD.html
βββ templates/
β βββ report.html.j2 # Report template
βββ requirements.txt
| Practice | Implementation |
|---|---|
| Credential Storage | Use environment variables or HashiCorp Vault |
| SSH Keys | Prefer key-based authentication over passwords |
| Encryption | Encrypt backup files at rest |
| Access Control | Restrict backup directory permissions |
| Audit Trail | Git commit history provides full audit trail |
| Secrets in Git | Never commit credentials - use .gitignore |
# .env file (never commit this!)
NETWORK_USER=admin
NETWORK_PASSWORD=SecureP@ss123
VAULT_TOKEN=hvs.xxxxxxxxxxxxx
SLACK_WEBHOOK=https://hooks.slack.com/...# Run every 6 hours
0 */6 * * * /path/to/venv/bin/python /path/to/network_backup.py backup --all
# Daily at 2 AM
0 2 * * * /path/to/venv/bin/python /path/to/network_backup.py backup --all# Run continuously with interval
python network_backup.py schedule --interval 6h --notify slack# Create scheduled task
schtasks /create /tn "NetworkBackup" /tr "python C:\backup\network_backup.py backup --all" /sc hourly /mo 6# config/settings.yaml
notifications:
slack:
enabled: true
webhook_url: ${SLACK_WEBHOOK}
channel: "#network-alerts"
on_change: true
on_failure: truenotifications:
email:
enabled: true
smtp_server: smtp.company.com
recipients:
- netops@company.com
on_change: true
on_failure: true
daily_summary: trueContributions are welcome! Please read our Contributing Guide for details.
This project is licensed under the MIT License - see the LICENSE file for details.