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.
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
- Create and activate a virtual environment.
- Install dependencies:
pip install -e .[dev]
- Copy credentials template:
cp .env.example .env
- Edit
.envwith your lab credentials. - Review and update
samples/inventory.ymlfor your devices.
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- Uses mock-safe TEST-NET address ranges (
192.0.2.0/24,198.51.100.0/24). - Hostnames are generic and intended for demonstration.
backup-lab --inventory samples/inventory.yml --backup-dir backups --log-path logs/backup.logOutputs:
- Backup files like
backups/r1-lab_20260101_120101.txt - Logs in
logs/backup.log
- 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.
Run tests with:
pytestThis 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