33 lines
997 B
Markdown
33 lines
997 B
Markdown
|
# 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.
|
||
|
|
||
|
```bash
|
||
|
python3 -m venv ./
|
||
|
```
|
||
|
|
||
|
The required packages can be installed by running the following command after activating the virtual environment.
|
||
|
|
||
|
```bash
|
||
|
pip install -r requirements.txt
|
||
|
```
|
||
|
|
||
|
If new packages are installed, the requirements file can be updated by running the following command.
|
||
|
|
||
|
```bash
|
||
|
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.
|
||
|
|
||
|
```bash
|
||
|
docker run --rm -e S3_ACCESS_KEY=your_access_key -e S3_SECRET_KEY=your_secret_key -e S3_ENDPOINT=your_endpoint s3-recent-file-cleaner
|
||
|
```
|