Created
October 29, 2022 22:56
-
-
Save paridin/0642b92ff1d8586ebf3e37238cb5700c to your computer and use it in GitHub Desktop.
A function helper to recover your postico configurations from git
This file contains 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 characters
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