Scheduled Firestore backups
1 min read

Scheduled Firestore backups

Deploying scheduled Firestore backups in a project that already uses Functions.

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.

Wanna stay up-to-date with Flutter and Dart?

Subscribe to get a weekly email with the best articles about Flutter and Dart.

    We won't send you spam. Unsubscribe at any time.