A complete AI agency at your fingertips - From frontend wizards to Reddit community ninjas, from whimsy injectors to reality checkers. Each agent is a specialized expert with personality, processes, and proven deliverables.
Shell
Delete expired backups using complete unsplit S3 object keys
Rudy Celekli7957e781ec7b
diff --git a/support/support-infrastructure-maintainer.md b/support/support-infrastructure-maintainer.mdindex 5e38a198..77508dc9 100644--- a/support/support-infrastructure-maintainer.md+++ b/support/support-infrastructure-maintainer.md@@ -390,9 +390,17 @@ cleanup_old_backups() {find "$BACKUP_ROOT" -name "*.gpg" -mtime +$RETENTION_DAYS -delete# S3 cleanup (lifecycle policy should handle this, but double-check)+ # JSON preserves spaces, quotes and newlines in object keys. The AWS CLI+ # paginates list-objects-v2; pass each full URI as one argv item to rm.+ local cutoff+ cutoff=$(python3 -c 'from datetime import datetime, timedelta, timezone; import sys; print((datetime.now(timezone.utc) - timedelta(days=int(sys.argv[1]))).strftime("%Y-%m-%dT%H:%M:%SZ"))' "$RETENTION_DAYS")aws s3api list-objects-v2 --bucket "$S3_BUCKET" \- --query "Contents[?LastModified<='$(date -d "$RETENTION_DAYS days ago" -u +%Y-%m-%dT%H:%M:%SZ)'].Key" \- --output text | xargs -r -n1 aws s3 rm "s3://$S3_BUCKET/"+ --query "Contents[?LastModified<='$cutoff'].Key" \+ --output json | python3 -c '+import json, subprocess, sys+for key in json.load(sys.stdin) or []:+ subprocess.run(["aws", "s3", "rm", "s3://" + sys.argv[1] + "/" + key], check=True)+' "$S3_BUCKET"log "Cleanup completed"}