Scheduled Firestore backups
—
Tips
I followed the official guide to create a scheduled Function on Firebase to backup Firestore on a Google Cloud bucket.
The code includes
...
const firestore = require('@google-cloud/firestore')
const client = new firestore.v1.FirestoreAdminClient()
...
but then, on pre-deploy, I got the error
Module ‘@google-cloud/firestore’ is not listed as dependency in package.json.
And adding "@google-cloud/firestore": "^0.x.y"
to package.json
did not seem to be the right thing to do, because that package is already included in the Firebase sdk.
So I adapted the code from the team at Firebase to:
import * as admin from 'firebase-admin'
const client = new admin.firestore.v1.FirestoreAdminClient({})
...
and removed"@google-cloud/firestore": "^0.x.y"
from package.json
. This worked.
Leave a comment