Fifty servers back up to one S3 bucket. How do you structure keys and permissions?
IntermediateScenarioScenarios: backups, log rotation and housekeeping
Answer
Situation read → You need clear ownership, isolation between servers, and protection against a compromised server deleting all backups.
What I'd do →
- Key layout:
servers/<hostname>/<hostname>-<UTC timestamp>.tar.gz, so listing and lifecycle rules work per host. - Instance role permissions:
s3:PutObject(ands3:GetObjectfor verification if needed) onarn:aws:s3:::bucket/servers/${aws:PrincipalTag/Name}/*or a per-host prefix; nos3:DeleteObject. - Bucket: versioning, default encryption, Block Public Access, lifecycle expiration, and Object Lock in governance or compliance mode for ransomware resistance.
- Monitoring: a scheduled check that every host has an object newer than 26 hours.
Why → Put-only permissions plus versioning means a compromised host can add objects but cannot destroy history.
Interview tip → Mention "freshness monitoring per host"; a host that silently stopped backing up is the common failure.
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