Remove all but a fixed amount of files from all buckets for a S3 endpoint.
Go to file
Liam Pietralla 1a0e854c75
All checks were successful
Publish / Publish Docker Container (push) Successful in 29s
Merge pull request 'setup ci' (#1) from feat/setup-ci into main
Reviewed-on: #1
2024-12-28 21:09:36 +11:00
.github/workflows setup ci 2024-12-28 21:09:18 +11:00
.dockerignore setup ci 2024-12-28 21:09:18 +11:00
.gitignore initial commit 2024-12-28 21:03:41 +11:00
Dockerfile initial commit 2024-12-28 21:03:41 +11:00
main.py initial commit 2024-12-28 21:03:41 +11:00
README.md setup ci 2024-12-28 21:09:18 +11:00
requirements.txt initial commit 2024-12-28 21:03:41 +11:00

S3 Recent File Cleaner

Simple python script to loop through all files in an S3 Endpoint and delete excess files based on a retention amount.

Retention ammount: 5

Development

Python 3.12 should be used for development and ideally a virtual environment should be used. With the source checked out run the following command to create a virtual environment.

python3 -m venv ./

The required packages can be installed by running the following command after activating the virtual environment.

pip install -r requirements.txt

If new packages are installed, the requirements file can be updated by running the following command.

pip freeze > requirements.txt

Usage

The S3 Recent File Cleaner is best run as a once off docker image. The image is already built so can be run with the following command.

docker run --rm -e S3_ACCESS_KEY=your_access_key -e S3_SECRET_KEY=your_secret_key -e S3_ENDPOINT=your_endpoint liamsgit.dev/liampietralla/s3-recent-file-cleaner:latest