Skip to main content

Backup & Restore

Configuration backup and recovery procedures.

Configuration Backup

Manual Backup

# Backup running config
sudo cp /opt/athena-bng/etc/running-config.yaml \
/opt/athena-bng/etc/backups/running-config.$(date +%Y%m%d-%H%M%S).yaml

# Backup candidate config
sudo cp /opt/athena-bng/etc/candidate-config.yaml \
/opt/athena-bng/etc/backups/candidate-config.$(date +%Y%m%d-%H%M%S).yaml

Automated Backup (Cron)

# Add to crontab
0 2 * * * /opt/athena-bng/scripts/backup-config.sh

Backup script:

#!/bin/bash
BACKUP_DIR="/opt/athena-bng/etc/backups"
TIMESTAMP=$(date +%Y%m%d-%H%M%S)

mkdir -p "$BACKUP_DIR"
cp /opt/athena-bng/etc/running-config.yaml \
"$BACKUP_DIR/running-config.$TIMESTAMP.yaml"

# Keep only last 30 days
find "$BACKUP_DIR" -name "running-config.*.yaml" -mtime +30 -delete

Configuration Restore

Restore from Backup

# View available backups
ls -la /opt/athena-bng/etc/backups/

# Restore to candidate config
sudo cp /opt/athena-bng/etc/backups/running-config.20260314-120000.yaml \
/opt/athena-bng/etc/candidate-config.yaml

# Commit to running config
abng> configure
abng# commit

Rollback to Previous Config

# View config history
abng> show configuration | compare

# Rollback to previous version
abng# rollback 1

Archive Management

View Config Archive

ls -la /opt/athena-bng/etc/config-archive/

Archive Structure

config-archive/
├── running-config.yaml.0 (current)
├── running-config.yaml.1 (previous)
├── running-config.yaml.2 (2 commits ago)
└── ...

Restore from Archive

# Copy archive to candidate
sudo cp /opt/athena-bng/etc/config-archive/running-config.yaml.2 \
/opt/athena-bng/etc/candidate-config.yaml

# Commit
abng> configure
abng# commit

Database Backup

Backup RADIUS Database (if using SQL)

# PostgreSQL backup
sudo -u postgres pg_dump athenabng > /backups/athenabng-$(date +%Y%m%d).sql

# Compress backup
gzip /backups/athenabng-$(date +%Y%m%d).sql

Restore RADIUS Database

# Decompress backup
gunzip /backups/athenabng-20260314.sql.gz

# Restore to database
sudo -u postgres psql athenabng < /backups/athenabng-20260314.sql

System Backup

Backup Entire System

# Backup /opt/athena-bng
sudo tar -czf /backups/athenabng-$(date +%Y%m%d).tar.gz \
/opt/athena-bng

# Backup /etc/AthenaBNG
sudo tar -czf /backups/athenabng-etc-$(date +%Y%m%d).tar.gz \
/etc/AthenaBNG

Restore System

# Restore /opt/athena-bng
sudo tar -xzf /backups/athenabng-20260314.tar.gz -C /

# Restore /etc/AthenaBNG
sudo tar -xzf /backups/athenabng-etc-20260314.tar.gz -C /

# Restart services
sudo systemctl restart AthenaBNG.target

Disaster Recovery

Complete System Recovery

  1. Install Debian 13
  2. Install AthenaBNG package
  3. Restore configuration
    sudo cp /backups/running-config.yaml /opt/athena-bng/etc/
  4. Restore RADIUS database (if applicable)
  5. Start services
    sudo systemctl start AthenaBNG.target
  6. Verify operation
    abng -c "show subscribers"

Backup Verification

Verify Backup Integrity

# Check backup file size
ls -lh /opt/athena-bng/etc/backups/

# Validate YAML syntax
python3 -c "import yaml; yaml.safe_load(open('/backups/running-config.yaml'))"

Test Restore Procedure

# Restore to test system
# Verify configuration loads
# Verify services start
# Verify sessions can be created

Best Practices

  1. Backup Frequency — Daily automated backups
  2. Retention — Keep 30 days of backups
  3. Offsite Storage — Store backups on separate system
  4. Encryption — Encrypt backups containing secrets
  5. Testing — Test restore procedure monthly
  6. Documentation — Document recovery procedures
  7. Monitoring — Alert on backup failures

Next Steps