2

I want to apply some more advanced lifecycle policies on my GCP Storage Bucket to meet some imposed requirements.

An application performs hourly backups which are stored in a GCP Storage Bucket as "app_name_timestamp". I want to optimize the number of backup files stored in the bucket, by applying policies in accordance with the following requirements:

  • keep the Hourly backup files for 7 Days,

  • keep the Daily backup files for 3 weeks,

  • keep the Weekly backup files for 2 months,

  • keep the Monthly backup files for 1 year.

Too meet the first requirement, I can use the lifecycle rule to move the backup files to a different storage class based on the "Age" condition. But, is there an option to incorporate the remaining rules, having in mind the possibility to move them between different storage classes? My main problem is to figure out how to leave one copy from the Hourly backup as the Daily one.

If someone would throw me a bone here, I would really appreciate it.

Thanks in advance!

notadevv
  • 31
  • 5

1 Answers1

0

Actually you should use the "Age" condition for all your requirements. For example, in order to keep the daily backup files for 3 weeks you should use 21 days, and 60 for keeping the weekly backup files for 2 months.

Nevertheless, something to keep in mind is that rules apply to a bucket, not an object. I mean, if you set a rule to delete objects after 7 days, all objects in that bucket will be deleted in 7 days. You can set many rules in the bucket but as you can see here "If you specify multiple rules that contain the same action, the action is taken when an object matches the condition(s) in any of the rules".

Having said that, for your business case, I would recommend you to have 1 bucket for each of your requirements in order to keep your objects the desired period.

Samuel Romero
  • 1,233
  • 7
  • 12
  • Thanks for your answer Samuel. Indeed, that was my earliest idea to implement the mentioned requirements, because any other application backup would use the same logic - I would use a bucket per retention requirement (so total number of 4), not per application (total number of x). Easier to maintain in my opinion - just wanted to know if someone would suggest a different, maybe more "fancy" solution. Thanks! – notadevv Sep 15 '20 at 20:06