CCNA Lab 13: Configuration Management and Automated Backups
Configuration management is the most overlooked discipline in network engineering. Every engineer knows how to do a one-off copy running-config tftp:, but very few have automated, versioned, and tested restoration procedures.
The simplest method. No authentication, runs over UDP port 69.
! Save running-config to TFTP server
copy running-config tftp://192.168.1.100/ACCESS-SW-1-running-config.txt
! Save startup-config
copy startup-config tftp://192.168.1.100/ACCESS-SW-1-startup-config.txt
! Save both in one command
copy running-config tftp://192.168.1.100/ACCESS-SW-1-config-$(date +%Y%m%d).txtRestore from TFTP:
copy tftp://192.168.1.100/ACCESS-SW-1-config-20250621.txt running-configNot recommended โ passwords are sent in plaintext.
SCP runs over SSH and encrypts everything.
! Enable SCP server on the switch
ip scp server enableFrom the management host:
scp admin@ACCESS-SW-1:running-config backup/ACCESS-SW-1-$(date +%Y%m%d).txt
scp admin@ACCESS-SW-1:startup-config backup/ACCESS-SW-1-startup-$(date +%Y%m%d).txtPush config to switch via SCP:
scp backup/ACCESS-SW-1-new-config.txt admin@ACCESS-SW-1:running-configcopy running-config http://backup-server/configs/ACCESS-SW-1.cfg
copy running-config https://backup-server/configs/ACCESS-SW-1.cfgRequires an HTTP server listening on the backup host.
The archive feature provides automatic versioned backups integrated with the CLI.
archive
path tftp://192.168.1.100/$h-config
maximum 10
time-period 1440
write-memory$h expands to the hostnamemaximum 10 keeps 10 backup revisionstime-period 1440 takes a snapshot every 24 hourswrite-memory triggers a backup on every write memory (copy run start)archive configThis immediately copies the running config to the archive path with an incremental version number.
show archive
show archive log config allconfigure replace tftp://192.168.1.100/ACCESS-SW-1-config-3This replaces the running config with the archived version without reloading the switch. It is the fastest way to revert a bad change.
Cisco IOS supports atomic config replacement and rollback without a reload.
! Preview changes without applying them
configure replace tftp://192.168.1.100/ACCESS-SW-1-config-base.txt list
! Apply the replacement
configure replace tftp://192.168.1.100/ACCESS-SW-1-config-base.txt forceThe force option suppresses prompts. The list option shows what will change.
configure replace tftp://192.168.1.100/ACCESS-SW-1-previous-good-config.txtIf the rollback introduces more problems:
configure revert nowOr if within the idle timeout:
configure revert timer 5This gives you a 5-minute window to confirm the replacement.
Run this from a Linux management host:
#!/bin/bash
# backup-switches.sh โ Backup all switch configs via SCP
BACKUP_DIR="/backup/switches/$(date +%Y-%m-%d)"
mkdir -p "$BACKUP_DIR"
SWITCHES="CORE-SW DIST-SW-1 DIST-SW-2 ACCESS-SW-1 ACCESS-SW-2 ACCESS-SW-3"
USER="admin"
PASS="YourPasswordHere"
for switch in $SWITCHES; do
echo "Backing up $switch..."
sshpass -p "$PASS" ssh -o StrictHostKeyChecking=no "$USER@$switch" \
"show running-config" > "$BACKUP_DIR/$switch-running.cfg"
sshpass -p "$PASS" ssh -o StrictHostKeyChecking=no "$USER@$switch" \
"show startup-config" > "$BACKUP_DIR/$switch-startup.cfg"
sshpass -p "$PASS" ssh -o StrictHostKeyChecking=no "$USER@$switch" \
"show vlan brief" > "$BACKUP_DIR/$switch-vlans.txt"
echo "$switch done"
done
# Generate checksums
cd "$BACKUP_DIR"
sha256sum *.cfg > checksums.txtFor larger networks, use automated config collectors:
# RANCID โ runs via crontab, diffs configs
# Config location: /usr/local/rancid/var/router.db
# Oxidation โ web interface for RANCID
# View config diffs in browserFor each switch model, keep a base config file:
BACKUP_DIR/
โโโ 2025-06-01/
โ โโโ CORE-SW-running.cfg
โ โโโ DIST-SW-1-running.cfg
โ โโโ ACCESS-SW-1-running.cfg
โโโ templates/
โ โโโ base-2960.cfg
โ โโโ base-3850.cfg
โ โโโ base-9300.cfg
โโโ recovery-drill.sh
When a switch dies and a new one arrives:
# 1. Copy base config for the model
cp templates/base-2960.cfg /tftp/ACCESS-SW-1-recovery.cfg
# 2. Modify hostname, IP, and VLANs specific to ACCESS-SW-1
vim /tftp/ACCESS-SW-1-recovery.cfg
# 3. On the new switch, set initial IP on VLAN 99
# Connect console, configure management IP
interface vlan 99
ip address 192.168.1.10 255.255.255.0
no shutdown
ip default-gateway 192.168.1.1
# 4. Copy the full config
copy tftp://192.168.1.100/ACCESS-SW-1-recovery.cfg running-config
# 5. Verify and save
show running-config | section hostname|vlan
copy running-config startup-config# Check checksums
cd /backup/switches/2025-06-21
sha256sum -c checksums.txt
# Compare with last known good config
diff /backup/switches/2025-06-20/ACCESS-SW-1-running.cfg ACCESS-SW-1-running.cfgTrack configs in Git for full audit trail:
cd /backup/switches
git init
git add .
git commit -m "Initial backup of all switch configs"#!/bin/bash
# backup-to-git.sh
cd /backup/switches
./backup-switches.sh # Run the backup script above
git add -A
git commit -m "Auto-backup $(date +%Y-%m-%d %H:%M)"
git push origin mainNow every config change is tracked, diffable, and revertible.
Test restoration quarterly:
configure replace command apply cleanly?| Command | Purpose |
|---|---|
copy running-config tftp://host/file | TFTP backup |
copy tftp://host/file running-config | TFTP restore |
ip scp server enable | Enable SCP on switch |
archive path tftp://host/\$h-config | Enable archive with auto-backup |
archive config | Manual archive snapshot |
show archive | List archived versions |
configure replace tftp://host/file | Atomic config replacement |
configure replace tftp://host/file list | Preview replacement changes |
configure revert now | Cancel pending replacement |
show archive log config all | View config change history |
write memory | Save running to startup (triggers archive) |
for sw in CORE DIST ACCESS; do ssh admin@$sw "show run" > backup/$sw-$(date +%Y%m%d).cfg; doneRelated Articles
CCNA Lab 13: Configuration Management and Automated Backups
Automate configuration backups, implement version control for switch configs, and build a disaster recovery workflow using TFTP, SCP, and archive.
CCNA Lab 4: Switch Configuration Backup to TFTP Server
Automate Cisco switch configuration backups to a remote TFTP server. Includes scripts, scheduled backups, and disaster recovery procedures.
CCNA Lab 14: Network Health Checks, BKMs, and Command Reference
Daily, weekly, and monthly health checks for your switches. Best known methods, maintenance procedures, and a comprehensive command reference for L2 engineers.