Skip to content

danielpmadden/netmiko-config-backup-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

netmiko-config-backup-lab

netmiko-config-backup-lab is a lab automation project for students transitioning into network automation. It demonstrates a realistic backup workflow:

  • Read device inventory from YAML
  • Connect with Netmiko
  • Run show running-config (or another per-device command)
  • Save timestamped backups by hostname
  • Log connection and command errors for troubleshooting

This project is intentionally designed for lab/sandbox practice and portfolio use.

Project structure

netmiko-config-backup-lab/
├── netmiko_config_backup_lab/
│   ├── backup.py
│   ├── cli.py
│   ├── config.py
│   ├── inventory.py
│   ├── logging_utils.py
│   └── workflow.py
├── samples/
│   └── inventory.yml
├── tests/
│   ├── test_backup.py
│   └── test_inventory.py
├── .env.example
└── pyproject.toml

Quick start

  1. Create and activate a virtual environment.
  2. Install dependencies:
    pip install -e .[dev]
  3. Copy credentials template:
    cp .env.example .env
  4. Edit .env with your lab credentials.
  5. Review and update samples/inventory.yml for your devices.

Inventory format (YAML)

defaults:
  device_type: cisco_ios
  command: show running-config

devices:
  - hostname: r1-lab
    host: 192.0.2.10
  - hostname: r2-lab
    host: 192.0.2.11
    command: show startup-config

Notes about sample inventory

  • Uses mock-safe TEST-NET address ranges (192.0.2.0/24, 198.51.100.0/24).
  • Hostnames are generic and intended for demonstration.

Run backups

backup-lab --inventory samples/inventory.yml --backup-dir backups --log-path logs/backup.log

Outputs:

  • Backup files like backups/r1-lab_20260101_120101.txt
  • Logs in logs/backup.log

Error handling behavior

  • Connection failures (auth/timeout) are logged and processing continues to next device.
  • Command failures are logged and processing continues.
  • Summary line reports successful backups count.

Testing

Run tests with:

pytest

Educational goals

This repository focuses on practical fundamentals expected in junior network automation work:

  • clean modular Python layout
  • environment-based credentials handling
  • structured inventory input
  • repeatable backup output naming
  • basic unit tests with mocking

About

Python lab project for automating network configuration backups from inventory-defined devices.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages