Skip to content

Instantly share code, notes, and snippets.

@spookyuser
Last active October 10, 2023 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spookyuser/e3e18386e33cfc16b9d02f2661676881 to your computer and use it in GitHub Desktop.
Save spookyuser/e3e18386e33cfc16b9d02f2661676881 to your computer and use it in GitHub Desktop.
Big firebase backup
#! /bin/bash
# Manual stuff
# Install gcloud sdk: https://cloud.google.com/sdk/docs/install
# Install firebase tools: https://firebase.google.com/docs/cli#install_the_firebase_cli
# Login to firebase: firebase login
# Login to gcloud: gcloud auth login
GCLOUD_PROJECT_ID=xxxx
BACKUP_BUCKET=gs://backups-$GCLOUD_PROJECT_ID-firebase
gcloud config set project $GCLOUD_PROJECT_ID
gsutil ls $BACKUP_BUCKET || gcloud storage buckets create $BACKUP_BUCKET
gcloud beta firestore export --async $BACKUP_BUCKET
firebase use $GCLOUD_PROJECT_ID
firebase auth:export users.json --format=JSON
# More manual stuff
# Wait a few min then download the bucket, it takes like 5 min to export:
# - gsutil -m cp -r gs://$BACKUP_BUCKET .
#
# - Save the Password Paramaters from the firebase authentication section https://firebase.google.com/docs/cli/auth#password_hash_parameters in your password manager probably
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment