Skip to content

Instantly share code, notes, and snippets.

@ts-ign0re
Last active November 26, 2020 14:23
Show Gist options
  • Save ts-ign0re/770ef70a697cdee65b5f78b4b3fab440 to your computer and use it in GitHub Desktop.
Save ts-ign0re/770ef70a697cdee65b5f78b4b3fab440 to your computer and use it in GitHub Desktop.
Firebase: export from firestore A to firestore B
#!/bin/sh
FOLDER_NAME=`date +\%y\%m\%d\%s`
echo "Enter bucket identifier (you can find it in project Settings)"
read BUCKET_NAME
echo "Enter target bucket"
read TARGET_BUCKET
gcloud config set project BUCKET_NAME &&
gcloud firestore export gs://$BUCKET_NAME.appspot.com/backups/$FOLDER_NAME &&
gsutil -m cp -R gs://$BUCKET_NAME.appspot.com/backups/$FOLDER_NAME . &&
gcloud config set project $TARGET_BUCKET &&
cd backups && gsutil cp -r $FOLDER_NAME gs://$TARGET_BUCKET.appspot.com/backups &&
gcloud firestore import gs://$TARGET_BUCKET.appspot.com/backups/$FOLDER_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment