Skip to content

Instantly share code, notes, and snippets.

@MorenoMdz
Created May 21, 2021 18:24
Show Gist options
  • Save MorenoMdz/70e8be191796fdb713b1e238f53a5c94 to your computer and use it in GitHub Desktop.
Save MorenoMdz/70e8be191796fdb713b1e238f53a5c94 to your computer and use it in GitHub Desktop.
Bash script that will export your local firestore data and rename the previous data.
#!/bin/bash
# yea yea windows will require WSL
red=$(tput setaf 1)
green=$(tput setaf 2)
bg_blue=$(tput setab 4)
bg_cyan=$(tput setab 6)
reset=$(tput sgr0)
nl=$(tput il 1)
echo "${red}red text ${green}green text${reset}"
function run_export() {
read -p "Enter the new backup ${bg_blue}name${reset}, defaults to ${green}seed${reset}: " folder_name
echo "backing up $folder_name..."
if [ -z "$folder_name" ]; then
echo "No folder name provided, exporting to ${green}'seed'${reset}"
folder_name=seed
else
echo "Exporting to ${green}$folder_name${reset}"
fi
path=$(pwd)
echo "Trying to rename old export to ${green}seed_prev${reset}"
mv $path/functions/seed $path/functions/seed_prev
firebase emulators:export functions/$folder_name --force
}
read -r -p "Are You Sure? [Y/n] " input
case $input in
[yY][eE][sS] | [yY])
echo "${green}Continuing...${reset}"
run_export
;;
[nN][oO] | [nN])
echo "${red}Canceled"
;;
*)
echo "Invalid input..."
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment