storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/docs/bucket/lifecycle/README.md (about) 1 # Bucket Lifecycle Configuration Quickstart Guide [](https://slack.min.io) [](https://hub.docker.com/r/minio/minio/) 2 3 Enable object lifecycle configuration on buckets to setup automatic deletion of objects after a specified number of days or a specified date. 4 5 ## 1. Prerequisites 6 - Install MinIO - [MinIO Quickstart Guide](https://docs.min.io/docs/minio-quickstart-guide). 7 - Install `mc` - [mc Quickstart Guide](https://docs.minio.io/docs/minio-client-quickstart-guide.html) 8 9 ## 2. Enable bucket lifecycle configuration 10 11 - Create a bucket lifecycle configuration which expires the objects under the prefix `old/` on `2020-01-01T00:00:00.000Z` date and the objects under `temp/` after 7 days. 12 - Enable bucket lifecycle configuration using `mc`: 13 14 ```sh 15 $ mc ilm import play/testbucket <<EOF 16 { 17 "Rules": [ 18 { 19 "Expiration": { 20 "Date": "2020-01-01T00:00:00.000Z" 21 }, 22 "ID": "OldPictures", 23 "Filter": { 24 "Prefix": "old/" 25 }, 26 "Status": "Enabled" 27 }, 28 { 29 "Expiration": { 30 "Days": 7 31 }, 32 "ID": "TempUploads", 33 "Filter": { 34 "Prefix": "temp/" 35 }, 36 "Status": "Enabled" 37 } 38 ] 39 } 40 EOF 41 ``` 42 43 ``` 44 Lifecycle configuration imported successfully to `play/testbucket`. 45 ``` 46 47 - List the current settings 48 ``` 49 $ mc ilm ls play/testbucket 50 ID | Prefix | Enabled | Expiry | Date/Days | Transition | Date/Days | Storage-Class | Tags 51 ------------|----------|------------|--------|--------------|--------------|------------------|------------------|------------------ 52 OldPictures | old/ | ✓ | ✓ | 1 Jan 2020 | ✗ | | | 53 ------------|----------|------------|--------|--------------|--------------|------------------|------------------|------------------ 54 TempUploads | temp/ | ✓ | ✓ | 7 day(s) | ✗ | | | 55 ------------|----------|------------|--------|--------------|--------------|------------------|------------------|------------------ 56 ``` 57 58 ## 3. Activate ILM versioning features 59 60 This will only work with a versioned bucket, take a look at [Bucket Versioning Guide](https://docs.min.io/docs/minio-bucket-versioning-guide.html) for more understanding. 61 62 ### 3.1 Automatic removal of non current objects versions 63 64 A non-current object version is a version which is not the latest for a given object. It is possible to set up an automatic removal of non-current versions when a version becomes older than a given number of days. 65 66 e.g., To scan objects stored under `user-uploads/` prefix and remove versions older than one year. 67 ``` 68 { 69 "Rules": [ 70 { 71 "ID": "Removing all old versions", 72 "Filter": { 73 "Prefix": "users-uploads/" 74 }, 75 "NoncurrentVersionExpiration": { 76 "NoncurrentDays": 365 77 }, 78 "Status": "Enabled" 79 } 80 ] 81 } 82 ``` 83 84 ### 3.2 Automatic removal of delete markers with no other versions 85 86 When an object has only one version as a delete marker, the latter can be automatically removed after a certain number of days using the following configuration: 87 88 ``` 89 { 90 "Rules": [ 91 { 92 "ID": "Removing all delete markers", 93 "Expiration": { 94 "DeleteMarker": true 95 }, 96 "Status": "Enabled" 97 } 98 ] 99 } 100 ``` 101 102 ## Explore Further 103 - [MinIO | Golang Client API Reference](https://docs.min.io/docs/golang-client-api-reference.html#SetBucketLifecycle) 104 - [Object Lifecycle Management](https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html)