Skip to content

Commit

Permalink
[MOSIP-30398] updated minio-client util docker file (#29)
Browse files Browse the repository at this point in the history
* To remove multiple objects from multiple buckets
* If condition to check for existence of bucket

Signed-off-by: syed salman <[email protected]>
  • Loading branch information
syedsalman3753 authored Jan 2, 2024
1 parent c7d4632 commit c71320d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions minio-client-util/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ chmod +x mc && mv mc /usr/local/bin
ENV S3_ACCESS_KEY=
ENV S3_SECRET_KEY=
ENV S3_SERVER_URL=
ENV S3_BUCKET_NAME=
ENV S3_BUCKET_LIST=
ENV S3_RETENTION_DAYS=

# Delete objects older than 3 days
CMD mc alias set myminio $S3_SERVER_URL $S3_ACCESS_KEY $S3_SECRET_KEY && mc rm --recursive --force --older-than $S3_RETENTION_DAYS myminio/$S3_BUCKET_NAME && echo "Objects from $S3_BUCKET_NAME bucket older than $S3_RETENTION_DAYS days has been deleted successfully"


CMD mc alias set myminio $S3_SERVER_URL $S3_ACCESS_KEY $S3_SECRET_KEY && \
for S3_BUCKET in $( echo $S3_BUCKET_LIST | sed 's/,/ /g'); do \
if mc ls myminio/$S3_BUCKET 2>/dev/null; then \
mc rm --recursive --force --older-than $S3_RETENTION_DAYS myminio/$S3_BUCKET && \
echo "Objects from $S3_BUCKET bucket older than $S3_RETENTION_DAYS days has been deleted successfully"; \
else \
echo "Bucket $S3_BUCKET does not exist or is empty"; \
fi; \
done
4 changes: 2 additions & 2 deletions minio-client-util/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* S3_SERVER_URL
* S3_ACCESS_KEY
* S3_SECRET_KEY
* S3_BUCKET_NAME
* S3_BUCKET_LIST
* S3_RETENTION_DAYS

## Prerequisites
Expand All @@ -21,7 +21,7 @@ sudo docker run -itd \
-e S3_SERVER_URL='<Server URL>' \
-e S3_ACCESS_KEY='<Access key>' \
-e S3_SECRET_KEY='<secret key>' \
-e S3_BUCKET_NAME='<target bucket name>' \
-e S3_BUCKET_LIST='<list of bucket name seperated by comma (,)>' \
-e S3_RETENTION_DAYS='<no of retention days>' \
-p 80:80 \
-name <CONTAINER NAME> <dockerhub_id/image_name>
Expand Down

0 comments on commit c71320d

Please sign in to comment.