We need to enable below Object Lifecycle rules
in GCP Cloud Storage bucket
If a non current object version is not accessed for 100 days and its current storage class is either of STORAGE, MULTI_REGIONAL and DURABLE_REDUCED_AVAILABILITY
, move that object to Nearline
Storage
If a object version is not accessed for 100 days and its current storage class is Nearline
, move it to Coldline
storage Class
Delete from Coldline
storage if objects are not accessed for 100 days from Coldline
Storage.
Keep 2 non current version of file
To implement the above rules , the following rules were applied to bucket
{
"lifecycle": {
"rule": [
{
"action": {
"type": "SetStorageClass",
"storageClass": "NEARLINE"
},
"condition": {
"age": 100,
"isLive": false,
"matchesStorageClass": ["REGIONAL", "STANDARD", "DURABLE_REDUCED_AVAILABILITY"]
}
},
{
"action": {
"type": "SetStorageClass",
"storageClass": "COLDLINE"
},
"condition": {
"age": 100,
"matchesStorageClass": ["NEARLINE"]
}
},
{
"action": { "type": "Delete"},
"condition": {
"age": 100,
"matchesStorageClass": ["COLDLINE"]
}
},
{
"action": { "type": "Delete"},
"condition": {
"numNewerVersions": 2
}
}
]
}
}
Need clarification on below
It is showing the rules are applied successfully but will it work practically. Since we are moving non current versions from NEARLINE to COLDLINE which are not accessed for 100 days do I need to add "isLive": false in Rule 2 . Also does we need it for rule 3 too .
{
"action": {
"type": "SetStorageClass",
"storageClass": "COLDLINE"
},
"condition": {
"age": 100,
"isLive": false
"matchesStorageClass": ["NEARLINE"]
}
},
{
"action": { "type": "Delete"},
"condition": {
"age": 100,
"isLive": false
"matchesStorageClass": ["COLDLINE"]
}
},
Also does it makes sense to move directly to COLDLINE from STANDARD storage class as we are considering access above 100 days
Any suggestions ?
Your rules aren't correct.
Firstly, the age
is the number of days after the creation
Age is measured from the object's creation time
So, your condition "if it has not been accessed the last 100 days" is not possible. The correct expression is "100 days after its creation, do..."
From there, your archiving policies aren't correct. You use the same age (100 days after the object creation) to
On the same AGE condition!!
To answer to your questions
isLive: false
if you consider (and you are sure) that only non-current version are in nearline
class