Script for removing old backups from s3 (old in this case means > 1 month old). Keeps first backup for each day.
I deployed it using Serverless framework to AWS Lambda where it's running once a day (see serverless.example.yml file) - but you can do it whatever way you'd like.
Following env vars need to be specified:
- S3_BUCKET_NAME (e.g. some-bucket)
- FILE_PATH_PREFIX: prefix for which the files are listed (e.g. backups/db_ if files are in backups dir and named db_<date>)
Also, the function must have access to the bucket setup along with proper permissions.
- Clone this repo.
- Run
npm install - Configure AWS credentials.
- Set env vars.
- Run the script using
node run.js.