Interview Prep/Shell Scripting/Scenarios: backups, log rotation and housekeeping

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 →

  1. Key layout: servers/<hostname>/<hostname>-<UTC timestamp>.tar.gz, so listing and lifecycle rules work per host.
  2. Instance role permissions: s3:PutObject (and s3:GetObject for verification if needed) on arn:aws:s3:::bucket/servers/${aws:PrincipalTag/Name}/* or a per-host prefix; no s3:DeleteObject.
  3. Bucket: versioning, default encryption, Block Public Access, lifecycle expiration, and Object Lock in governance or compliance mode for ransomware resistance.
  4. 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.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Scenarios: backups, log rotation and housekeeping