VyOS Configuration Backup & Restore
Backup Configuration
Method 1: Save to file on router
# Save current config to file
save /config/backup-2025-10-25.config
# Or use a dated backup automatically
save /config/backup-$(date +%Y%m%d-%H%M%S).config
Method 2: Copy to remote location via SCP
# From the router
scp /config/config.boot user@backup-server:/path/to/backups/
# Or save and copy
save /config/backup.config
scp /config/backup.config user@backup-server:/path/to/backups/
Method 3: Display and copy manually
# Show entire configuration (copy/paste to text file)
show configuration
# or
show configuration commands
# You can also save it to a file and download
save /config/backup.config
# Then use SFTP/SCP client to download from router
Method 4: Via USB (if you have USB drive mounted)
# Mount USB drive
sudo mkdir /mnt/usb
sudo mount /dev/sdb1 /mnt/usb
# Copy config
sudo cp /config/config.boot /mnt/usb/vyos-backup-$(date +%Y%m%d).config
# Unmount
sudo umount /mnt/usb
Restore Configuration
Method 1: Load from file on router
configure
load /config/backup-2025-10-25.config
commit
save
exit
Method 2: Copy from remote location first
# Copy backup to router
scp user@backup-server:/path/to/backups/backup.config vyos@router-ip:/config/restore.config
# Then load it
configure
load /config/restore.config
commit
save
exit
Method 3: During boot (rescue/recovery)
# At boot, select older config version from boot menu
# VyOS keeps several boot configs automatically
# Or copy manually
sudo cp /config/config.boot.old /config/config.boot
reboot
Method 4: Fresh install restore
# After fresh VyOS install, copy your backup
scp backup.config vyos@new-router:/config/restore.config
# Login and load
configure
load /config/restore.config
commit
save
exit
View Available Backups
# List saved configurations
ls -lh /config/*.config
# VyOS automatic boot configs
ls -lh /config/config.boot*
Compare Configurations
configure
# Compare current config with saved file
compare /config/backup.config
# Compare current with previous boot config
compare /config/config.boot.old
Automated Backup Script
Create a simple backup script:
# Create script
sudo vi /config/scripts/backup.sh
Add this content:
#!/bin/bash
BACKUP_DIR="/config/backups"
BACKUP_FILE="$BACKUP_DIR/config-$(date +%Y%m%d-%H%M%S).boot"
mkdir -p $BACKUP_DIR
cp /config/config.boot $BACKUP_FILE
# Keep only last 10 backups
ls -t $BACKUP_DIR/config-*.boot | tail -n +11 | xargs -r rm
# Optional: Send to remote server
# scp $BACKUP_FILE user@backup-server:/backups/vyos/
Make it executable:
sudo chmod +x /config/scripts/backup.sh
Schedule it with cron:
configure
set system task-scheduler task backup-config executable path /config/scripts/backup.sh
set system task-scheduler task backup-config interval 1d
commit
save
Quick Reference
# Quick backup
save /config/backup-now.config
# Quick restore
configure
load /config/backup-now.config
commit
save
# Emergency rollback (if commit broke something)
configure
rollback 1
commit
# Copy config to external
scp /config/config.boot user@server:/backups/
Best Practices
- Before major changes: Always
save /config/pre-change-backup.config - Keep multiple versions: VyOS automatically keeps boot configs
- Off-site backup: Copy to external server regularly
- Test restores: Periodically verify backups work
- Document: Keep notes about what each backup contains
The config file is human-readable text, so you can also edit it manually if needed!
Be First to Comment