Anleitungen und Tutorials

Backups automatisieren: die 3-2-1-Regel

Veröffentlicht am 9. Juli 2024 · 10 Min. Lesezeit

Dieser Artikel ist auf Französisch und Englisch verfügbar.

The 3-2-1 rule

Three copies of your data, on two different media, one of them off-site. A VPS without a backup strategy is a matter of "when", not "if".

Level 1 — hypervisor snapshots

Included in our plans: an automatic daily snapshot of your entire disk. One-click restore from the panel. It's your ultimate safety net, but not enough alone: snapshots live on the same infrastructure as the VPS.

Level 2 — incremental rsync to a second VPS

A small Apex in another datacenter (Paris ↔ Frankfurt) makes an excellent backup server:

rsync -avz --delete --link-dest=/backups/current \
  -e "ssh -p 2222" /var/www/ backup@backup-server:/backups/daily-$(date +%F)
ln -sfn daily-$(date +%F) /backups/current

The --link-dest option creates incremental backups via hard links: each day looks complete, but only differences consume space.

Level 3 — external object storage

rclone to a compatible S3 (encrypted with rclone crypt) for the off-site copy:

rclone sync /backups encrypted-s3:my-backups --transfers 8

Databases: always a logical dump

Running rsync on MySQL files being written to gives you a corrupted database. Dump before copying:

mysqldump --single-transaction --quick prod | gzip > /backups/db-$(date +%F).sql.gz

PostgreSQL: pg_dump -Fc. SQLite: sqlite3 db .backup.

Cron and alerts

Put everything in a script, scheduled at 3 a.m., and send the result to a webhook (Discord, n8n): a backup that fails silently is worse than no backup. Test a full restore once a month — an untested backup doesn't exist.

Schritt-für-Schritt-Tutorials von unseren Ingenieuren, getestet auf unserer Infrastruktur.

GLOBALCLOUDHOSTING →