Managing disaster-recovery effectively is a crucial skill for any system administrator. This tutorial provides step-by-step instructions for planning configuration, along with best practices for production environments.
Prerequisites
- A remote storage destination (S3, B2, or another server)
- Root or sudo access to the server
- A registered domain name (for public-facing services)
- Basic familiarity with the Linux command line
- Sufficient storage for backups (2-3x data size)
Backup Configuration
The disaster-recovery configuration requires careful attention to resource limits and security settings. On a VPS with limited resources, it's important to tune these parameters according to your available RAM and CPU cores.
# Install and initialize backup tool
sudo apt install -y disaster-recovery
disaster-recovery init --repo /backup/repo
# Create first backup
disaster-recovery backup --repo /backup/repo /etc /home /var/www
# List backups
disaster-recovery snapshots --repo /backup/repo
The configuration above sets the recommended values for a VPS with 2-4GB of RAM. Adjust the memory-related settings proportionally if your server has different specifications.
Scheduling Automated Backups
Before making changes to the configuration, always create a backup of the existing files. This ensures you can quickly roll back if something goes wrong during the setup process.
# Automated backup script: /usr/local/bin/backup.sh
#!/bin/bash
set -euo pipefail
BACKUP_REPO="/backup/repo"
LOG_FILE="/var/log/backup.log"
DATE=$(date +%Y-%m-%d_%H-%M)
echo "[$DATE] Starting backup..." >> $LOG_FILE
# Database dump
mysqldump --all-databases | gzip > /tmp/db-$DATE.sql.gz
# Run backup
disaster-recovery backup --repo $BACKUP_REPO /etc /home /var/www /tmp/db-$DATE.sql.gz
# Cleanup old backups (keep 30 days)
disaster-recovery forget --repo $BACKUP_REPO --keep-daily 7 --keep-weekly 4 --keep-monthly 3 --prune
rm /tmp/db-$DATE.sql.gz
echo "[$DATE] Backup completed successfully" >> $LOG_FILE
The configuration above sets the recommended values for a VPS with 2-4GB of RAM. Adjust the memory-related settings proportionally if your server has different specifications.
Summary
You've successfully configured disaster-recovery on your VPS. Remember to monitor performance, keep your software updated, and maintain regular backups. If you run into issues, consult the official documentation or open a support ticket for assistance.