Backup rotation logic decides how backups are created, named, stored, retained, verified, and deleted over time. It is one of the most important sysadmin algorithms because backups are only useful if they can be restored.
Simple explanation
A backup system needs rules: how often to backup, how many copies to keep, where to store them, how to verify them, and when to delete old copies safely.
Why it matters
Without rotation, backups either disappear, fail silently, or fill the disk. A real backup plan balances recovery, storage, and risk.
Real VPS example
A WordPress VPS may need daily database backups, weekly full file backups, offsite copies, checksums, and restore tests.
System Administrator Operating Notes
Core principle, commands, verification, troubleshooting, rollback, and cloud/security connection.
Foundation
Skill Level
admin
System Layer
storage
Core Principle
Backup rotation protects recovery options while controlling storage growth. A backup is not valid until it is verified and restorable.
Mental Model
Think of backups as time machines with limited parking space. Rotation decides which time machines to keep and which to safely remove.
When To Use
Use this when designing database backups, WordPress backups, config backups, server snapshots, offsite copies, or retention policies.
Wrong Assumption
Beginners often create backups but never verify restore. They also store backups on the same disk until the server becomes full.
Commands
Command Goal
Create timestamped backups, verify them, retain enough history, remove old copies safely, and test restore.
Primary Command
mkdir -p /backup; tar -czf site-$(date +%F).tar.gz /var/www/site; mysqldump DB > db-$(date +%F).sql; sha256sum file > file.sha256; find /backup -type f -mtime +14 -deleteCommand Breakdown
tar archives files. mysqldump exports database. date creates timestamp names. sha256sum verifies integrity. find deletes old backups by age.
Safe Check Command
df -h; ls -lah /backup; test -d /backup; mysqladmin pingExpected Output
Backup directory should exist, disk should have enough free space, database should be reachable, and filenames should be timestamped.
Verify Command
ls -lah /backup; sha256sum -c file.sha256; tar -tzf backup.tar.gz | head; mysql < test_restore.sql if using test environmentTroubleshooting
Common Failures
Backup not created, corrupt archive, no database dump, disk full, old backups not deleted, deleted too much, same-server-only backup, or restore untested.
Log Files
/var/log/syslog; custom backup logs; MySQL error log; cron logsDebug Commands
tar -tzf; sha256sum -c; find /backup; df -h; du -sh /backup; grep backup /var/log/syslogRoot Cause Map
Define recovery goal, choose backup scope, create backup, verify integrity, copy offsite, rotate old versions, and test restore.
Fix Pattern
Design restore first. If you cannot explain how to restore it, the backup logic is incomplete.
Risk & Recovery
Risk Level
high
Backup Before Change
Before changing backup scripts or retention rules, copy the old script, list existing backups, and record disk usage.
Rollback Plan
Restore previous backup script, stop deletion job, recover from offsite backup if needed, and run a manual backup verification.
Blast Radius
Critical. Bad backup rotation can delete the only recovery copy or fill disk until services fail.
Security Note
Backups may contain secrets, user data, database credentials, and private files. Store them with restricted permissions and encryption when possible.
Strategic Value
Cloud Connection
Cloud backup logic maps to snapshots, object storage lifecycle policies, cross-region copies, and restore testing.
Automation Opportunity
Automate backup creation, checksum verification, offsite upload, retention deletion, and alerting on failure.
Interview Value
Backup design is a senior sysadmin topic because it combines reliability, risk, storage, and recovery thinking.
Related Concepts
backup, retention, restore, tar, mysqldump, checksum, offsite storage, cron, disaster recovery