Skip to content

Instantly share code, notes, and snippets.

@paridin
Created October 29, 2022 22:56
Show Gist options
  • Save paridin/0642b92ff1d8586ebf3e37238cb5700c to your computer and use it in GitHub Desktop.
Save paridin/0642b92ff1d8586ebf3e37238cb5700c to your computer and use it in GitHub Desktop.
A function helper to recover your postico configurations from git
function restore_postico_config() {
yn=""
origin=YOUR_GIT_PATH
recovery_path=$HOME/Library/Containers/at.eggerapps.Postico/Data/Library/Application\ Support/Postico
if ! git clone "${origin}" "${recovery_path}" 2>/dev/null && [ -d "${recovery_path}" ]; then
echo "Clone failed because the folder ${recovery_path} exists"
while true; do
echo -en "Do you want to remove to it, to restore your backup?: "
read -r yn
case $yn in
[yY]*)
"removing $recovery_path"
rm -rf $recovery_path
if [ $? -eq 0 ]; then
git clone $origin $recovery_path
return 0
else
echo "Trying again"
fi
;;
[Nn]*)
echo "We can't recovery your backup"
return 1
;;
*)
echo " "
echo "Answer $yn is not valid. Please answer yes or no. (y/n [yes/NO])"
;;
esac
yn=
done
echo " "
else
git clone $origin $recovery_path
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment