Jitendera Kumar
Jitendera Kumar

Reputation: 149

How to delete Cloud Firestore backup older than 15 days?

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?

Upvotes: 2

Views: 1047

Answers (3)

Deniss T.
Deniss T.

Reputation: 2652

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.

Upvotes: 4

Manoj
Manoj

Reputation: 2085

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?

Upvotes: 0

s_o_m_m_y_e_e
s_o_m_m_y_e_e

Reputation: 406

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!

Upvotes: 0

Related Questions