Created
May 9, 2019 10:23
-
-
Save claui/127a35a6de3b60403c7fc36ce31bf97d to your computer and use it in GitHub Desktop.
Migrate Airmail Beta data to Airmail 3
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
#!/bin/bash | |
set -eu; | |
echo >&2 'Quitting Airmail 3' | |
osascript -e 'tell app "Airmail 3" to quit' | |
echo >&2 'Quitting Airmail Beta' | |
osascript -e 'tell app "Airmail Beta" to quit' | |
echo >&2 'Asserting that Airmail Beta data is available' | |
if [ ! -d ~/Library/'Group Containers'/2E337YPCZY.airmail ]; then | |
echo >&2 'Unable to find container directory 2E337YPCZY.airmail' | |
exit 1 | |
fi | |
cd ~/Library/'Group Containers'/2E337YPCZY.airmail | |
if [ ! -d Library/'Application Support'/it.bloop.airmail.beta11/Airmail ]; then | |
echo >&2 'Unable to find directory it.bloop.airmail.beta11/Airmail' | |
exit 1 | |
fi | |
if [ ! -d SharedDataBeta ]; then | |
echo >&2 'Unable to find directory SharedDataBeta' | |
exit 1 | |
fi | |
echo >&2 'OK' | |
echo >&2 'Searching for Airmail 3 data to back up' | |
if [ -d Library/'Application Support'/it.bloop.airmail2 ] \ | |
|| [ -d SharedData ] | |
then | |
echo >&2 'Found Airmail 3 data' | |
echo >&2 'CAUTION: Your Airmail 3 data (non-beta) will be overwritten.' | |
read -r -p 'Press Enter to continue or Ctrl+C to cancel: ' | |
BACKUP_DIR="$(mktemp -d ~/Desktop/Airmail3Backup.XXXXXX)" | |
echo >&2 "Backing up Airmail 3 data to: ${BACKUP_DIR}" | |
cd ~/Library/'Group Containers'/2E337YPCZY.airmail | |
BACKUP_CONTAINER="${BACKUP_DIR}/Library/Group Containers/2E337YPCZY.airmail" | |
mkdir -p "${BACKUP_CONTAINER}/Library/Application Support" | |
if [ -d Library/'Application Support'/it.bloop.airmail2 ]; then | |
mv -n Library/'Application Support'/it.bloop.airmail2 \ | |
"${BACKUP_CONTAINER}/Library/Application Support/" | |
fi | |
if [ -d SharedData ]; then | |
mv -n SharedData "${BACKUP_CONTAINER}/" | |
fi | |
echo >&2 'Backup completed' | |
echo >&2 "Your old Airmail 3 data has been backed up to: ${BACKUP_DIR}" | |
fi | |
echo >&2 'Asserting that Airmail 3 data has been moved out of the way' | |
if [ -d Library/'Application Support'/it.bloop.airmail2/Airmail ] \ | |
|| [ -d SharedData ] | |
then | |
echo >&2 'Cannot continue due to residual Airmail 3 data found' | |
exit 1 | |
fi | |
echo >&2 'OK' | |
echo >&2 'Copying Airmail Beta data to Airmail 3' | |
mkdir -p SharedData | |
echo >&2 '- Accounts' | |
cp -R SharedDataBeta/Accounts.plist SharedData/Accounts.plist | |
echo >&2 '- Contacts' | |
cp -R SharedDataBeta/Contacts SharedData/Contacts | |
echo >&2 '- Today view' | |
cp -R SharedDataBeta/Today SharedData/Today | |
echo >&2 '- Database (this may take a long time)' | |
cp -R Library/'Application Support'/it.bloop.airmail.beta11 \ | |
Library/'Application Support'/it.bloop.airmail2 | |
echo >&2 'Done' | |
echo >&2 'Your Airmail Beta data has been copied to Airmail 3' |
@colindean Thanks for the feedback! Glad it was useful for you.
superb! worked like a dream. many thanks!
superb! worked like a dream. many thanks!
You’re welcome @iljamm! Thanks for the feedback, glad to see it worked for you.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Worked for me!