You need to back up 2 TB of mostly unchanged files nightly over a limited link. A full tar each night is impossible. What do you do?
AdvancedScenarioScenarios: backups, log rotation and housekeeping
Answer
Situation read → Only changed data should travel, and each backup should still look like a full snapshot for easy restores.
What I'd do →
- To another server:
rsyncwith hard-link snapshots, so unchanged files cost no extra space:today=/backups/$(date +%F) rsync -aH --delete --numeric-ids --link-dest=/backups/latest /data/ "$today/" ln -sfn "$today" /backups/latest - To S3:
aws s3 sync /data "s3://$bucket/data/" --sse AES256uploads only changed files; enable bucket versioning for point-in-time recovery, with lifecycle rules for old versions. - Or use a deduplicating tool (restic, borg) that does content-defined chunking, encryption and retention policies.
- Limit bandwidth (
rsync --bwlimit=20M) and usenice/ionice.
Why → Incremental transfer cuts nightly volume to the daily change rate, and snapshots keep restores simple.
Interview tip → Mention that aws s3 sync compares size and modification time, not content, which matters for files rewritten with the same size.
More on Scenarios: backups, log rotation and housekeeping
Design a nightly backup of `/etc` and application data to S3 with retention.IntermediateWrite the core of a Postgres backup that streams `pg_dump` through gzip to S3 and never uploads an empty dump.IntermediateBackups have "succeeded" every night for a year, but the first real restore failed. How do you make backups trustworthy?Advanced`/var` is 100% full because an app's logs were never rotated, and the app now fails to start. What do you do now, and what do you set up after?BeginnerShould you use `copytruncate` or a `postrotate` signal for an application's logs? How do you decide?Intermediate`/srv/app/releases` has 300 old release directories. Write a cleanup that keeps the newest 5 and never deletes the current release.Beginner