Table of Contents
The 3-2-1 Backup Rule
The gold standard for backup strategy: maintain at least 3 copies of your data, on 2 different storage types, with 1 copy offsite. For a VPS, this might mean: production server, daily snapshot, weekly backup to Backblaze B2 or Wasabi.
Simple Daily Backup with Rsync
#!/bin/bash
# backup.sh — run as cron daily
DATE=$(date +%Y-%m-%d)
BACKUP_DIR="/backups/$DATE"
mkdir -p $BACKUP_DIR
# Backup web files
rsync -az /var/www/ $BACKUP_DIR/www/
# Backup MySQL databases
mysqldump --all-databases | gzip > $BACKUP_DIR/mysql.sql.gz
# Compress and remove backups older than 30 days
find /backups -type d -mtime +30 -exec rm -rf {} +Restic for Incremental Encrypted Backups
Restic is a modern backup tool that deduplicates, compresses, and encrypts backup data. It supports multiple backends including S3-compatible storage:
apt install restic -y
# Initialize repository
restic -r s3:s3.amazonaws.com/mybucket init
# Create backup
restic -r s3:s3.amazonaws.com/mybucket backup /var/www /etc /home
# Schedule with cron: daily at 2 AM
0 2 * * * restic -r s3:... backup /var/www /etcTesting Your Backups (This Step is Critical)
Unverified backups are not backups — they are hopes. Schedule a monthly restore test: spin up a new VPS, restore your backup, and verify your application works correctly. Many businesses discover their backups were corrupted only when they need to use them.
Database-Specific Backup Strategies
For PostgreSQL, use pg_dump for logical backups or pg_basebackup for full cluster backups. For MySQL, mysqldump for small databases or Percona XtraBackup for large databases that cannot afford downtime during backup.
FAQ
How often should I backup my VPS?
Database and application data: daily minimum, hourly for critical data. Configuration files: after every change. Full system: weekly. Static files: less frequently if source control exists.
Ready to deploy?
Reliable VPS Hosting with Built-in Backup Options
Power Down VPS plans include snapshot capabilities. Add automated backups from your admin panel.
