-
-
Save kylebradshaw/c897f4b28c2baa2a57625f3210dd976d to your computer and use it in GitHub Desktop.
Revisions
-
Bernardo Kuri revised this gist
Jun 8, 2020 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,12 +2,12 @@ # seed-storage # ============ # Seed an existing firebase cloud storage emulator instance. Run it inside your # project's firebase folder, ie: ./seed-storage.sh <project-name> <dest-folder> name=firebase_export # firebase export dir name project=$1 # project name root=$2 # export root path uri=gs://$project.appspot.com/$name # cloud storage URI trap "kill 0" EXIT -
Bernardo Kuri revised this gist
Jun 8, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -45,5 +45,5 @@ gsutil -q cp -r $uri $root echo '[5/5] Cleaning up…' screen -S $name -X quit echo '\nDone! Use the following command to run the emulator:' echo "firebase emulators:start --import=$root" -
Bernardo Kuri revised this gist
Jun 8, 2020 . 1 changed file with 1 addition and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,6 @@ # Seed an existing firebase cloud storage emulator instance. Run inside your project's firebase folder. # syntax: ./seed-storage.sh <project-name> <dest-folder> name=firebase_export # firebase export dir name project=$1 # project name root=$2 # export root path for both firestore & cloud storage @@ -41,12 +40,10 @@ echo "[3/5] Exporting firestore snapshot to $uri" gcloud --verbosity=none firestore export $uri &> /dev/null echo "[4/5] Downloading exported data to $root" gsutil -q cp -r $uri $root echo '[5/5] Cleaning up…' screen -S $name -X quit echo 'Done! Use the following command to run the emulator:' echo "firebase emulators:start --import=$root" -
Bernardo Kuri revised this gist
Jun 7, 2020 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,4 +46,7 @@ gsutil -q -m cp -r $uri $root echo '[5/5] Cleaning up…' screen -S $name -X quit echo 'Done! Use the following command to run the emulator:' echo "firebase emulators:start --import=$root" exit 0 -
Bernardo Kuri created this gist
Jun 7, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ #!/bin/bash # seed-storage # ============ # Seed an existing firebase cloud storage emulator instance. Run inside your project's firebase folder. # syntax: ./seed-storage.sh <project-name> <dest-folder> # variables name=firebase_export # firebase export dir name project=$1 # project name root=$2 # export root path for both firestore & cloud storage uri=gs://$project.appspot.com/$name # cloud storage URI trap "kill 0" EXIT echo '[1/5] Preparing local/remote filesystems for seeding…' # check if a remote file exists and wipe parent dir if needed gsutil -q stat $uri/$name.overall_export_metadata [ $? -eq 0 ] && gsutil -q rm -f ${uri}** # create root path if needed mkdir -p $root echo '[2/5] Starting emulators in the background…' # start emulator if port isn't open lsof -i TCP:4000 &> /dev/null [ $? -eq 0 ] || screen -S $name -d -m firebase emulators:start & # wait until server is detected lsof -i TCP:4000 &> /dev/null while [ $? -ne 0 ]; do sleep 5; done # exit on any error from now on trap "exit" INT ERR # create importable file/dir structure firebase --non-interactive --project $project emulators:export --force $root &> /dev/null echo "[3/5] Exporting firestore snapshot to $uri" gcloud --verbosity=none firestore export $uri &> /dev/null echo "[4/5] Downloading exported data to $root" gsutil -q -m cp -r $uri $root echo '[5/5] Cleaning up…' screen -S $name -X quit exit 0