Skip to content

Instantly share code, notes, and snippets.

@vadmeste
Last active October 14, 2019 15:34
Show Gist options
  • Save vadmeste/2871f5e53996cc67576b62193e8dc9c8 to your computer and use it in GitHub Desktop.
Save vadmeste/2871f5e53996cc67576b62193e8dc9c8 to your computer and use it in GitHub Desktop.
ILM mc command line

Draft for ILM command in MC

Showing expiry rules

$ mc ilm expiry show myminio/bucket
Expiry rules:
   ID       Prefixes               Enabled    Days/Date
   fgh      ""                        ✓       10 May 2019
   gop      "temporary_uploads/"      ✓       7 days
   vez      "2019-uploads/"           ✓       2021-01-01

ID is a GUID in fact, but mc shows only the shortest possible length, mc will automatically understand it from full GUID really stored in bucket lifecycle configuration.

Notice: show command will also set random GUID for rules which have empty IDs (when lifecycle configuration is stored using other means other than mc, such as aws cli, etc..

Deleting/enabling/disabling a policy rule

$ mc ilm expiry enable myminio/bucket --id fgh
$ mc ilm expiry disable myminio/bucket --id gop
$ mc ilm expiry remove myminio/bucket --id vez

Set an expiry duration in days

$ mc ilm expiry set --days 7 --prefix "" myminio/bucket
Objects uploaded under `myminio/bucket/` will be automatically deleted after 7 days!

Set an expiry on specific date

$ mc ilm expiry set --date "oct 7, 2020" --prefix "uploads/" myminio/bucket
All objects under `myminio/bucket/uploads/` will be automatically deleted on 2020-10-07 00:00:00 +0000 MST

Used libraries

Parsing a date, very generic https://github.com/araddon/dateparse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment