2

I am doing a backup of the whole Cloud Firestore Database in the storage bucket on the daily basis. As our users are increasing, Firestore cost is also increasing.

Now, I want to delete the backup older than 15 days ago automatically. Is there any way by which I can write a cloud function that automatically deletes backup which is older than 15 days?

Jitendera Kumar
  • 136
  • 1
  • 12

3 Answers3

4

Besides the other solutions provided here, you could also add a lifecycle rule on the backup bucket that will delete the objects within it based on their age. You can set a condition that the object will be deleted after 15 days.

Have a look at this GCP documentation article for more information about the Object Lifecycle Management.

Deniss T.
  • 2,526
  • 9
  • 21
0

You can create a corn job and run it as per your schedule, please refer the below URL for more details, hope it will help: https://www.digitalocean.com/community/tutorials/nodejs-cron-jobs-by-examples

Schedule job in firebase can also be a help: https://firebase.google.com/docs/functions/schedule-functions

How to run cron job with Firebase?

Manoj
  • 2,059
  • 3
  • 12
  • 24
0

For this purpose, you should be having a timestamp(of its creation) on each document.

Then you can write a function to delete the documents whose timestamp is older than 15 days which you can execute every 15 days or so by a Cron Job

Hope it works out!

s_o_m_m_y_e_e
  • 406
  • 4
  • 9