Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Migrate Airmail Beta data to Airmail 3
#!/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

This comment has been minimized.

Copy link

@colindean colindean commented May 11, 2019

Worked for me!

@claui

This comment has been minimized.

Copy link
Owner Author

@claui claui commented May 11, 2019

@colindean Thanks for the feedback! Glad it was useful for you.

@iljamm

This comment has been minimized.

Copy link

@iljamm iljamm commented Jan 8, 2020

superb! worked like a dream. many thanks!

@claui

This comment has been minimized.

Copy link
Owner Author

@claui claui commented Jan 8, 2020

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