crysxd / simple-firestore-backup

A simple npm package designed to run inside Google/Firebase Cloud Functions allowing a simple scheduled backup of a Firestore Database
MIT License
7 stars 1 forks source link

process.env.GCLOUD_PROJECT is not set. #1

Open davej opened 5 years ago

davej commented 5 years ago

Thanks for this, I followed the instructions and tried running it but got this error:

Error: process.env.GCLOUD_PROJECT is not set.
    at triggerResource (/srv/functions/node_modules/firebase-functions/lib/providers/pubsub.js:71:23)
    at cloudFunctionNewSignature (/srv/functions/node_modules/firebase-functions/lib/cloud-functions.js:102:13)
    at cloudFunction (/srv/functions/node_modules/firebase-functions/lib/cloud-functions.js:151:20)
    at Promise.resolve.then (/srv/node_modules/@google-cloud/functions-framework/build/src/invoker.js:330:28)
    at process._tickCallback (internal/process/next_tick.js:68:7)

image

import * as admin from 'firebase-admin';
import * as functions from 'firebase-functions';

admin.initializeApp({
  credential: admin.credential.applicationDefault()
});

const func = functions.region('europe-west1');

// Some other unrelated firebase functions here

export const firestore_backup = func
  .runWith({
    timeoutSeconds: 540, // Increase timeout to maximum. You can remove this line if your database is not terribly large.
    memory: '128MB' // We only do one HTTP request, so we don't need many resources. Let's save money!
  })
  .pubsub.schedule('every 24 hours')
  .onRun(
    firestoreBackup
      .createBackupHandler
      // 'your-project-backups', // Optionally: The Google Cloud Storage Bucket to use (without gs://). Use the name you gave your bucket in step 1 or remove this line if you skipped step 1. Defaults to the default bucket ('your-project-id.appspot.com')
      // 'path/to/backups', // Optionally: the path inside the bucket. Defaults to 'firestore'
      // 'firestore-instance-id' // Optionally: the Firestore instance id to backup. If you did not create a second Firestore instance, you can leave this out. Defaults to '(default)'
      ()
  );
chris7818kbbf4 commented 4 years ago

rip