Skip to content

Instantly share code, notes, and snippets.

@changeme
Created February 2, 2016 01:19
Show Gist options
  • Save changeme/a45ba2b7c22fdafbea61 to your computer and use it in GitHub Desktop.
Save changeme/a45ba2b7c22fdafbea61 to your computer and use it in GitHub Desktop.
/bin/bash
#Configure servers
#SERVER1=190.228.29.39
SERVER2=newhostname-or-ip
#Uncomment to hide folder sizes
#FAST="--nofoldersizes"
#Uncomment to do a dry run (no actual changes)
#DRY="--dry"
#Uncomment to just sync folders (no messages)
#JUSTFOLDERS="--justfolders"
#Uncomment to just connect (no syncs at all)
#JUSTCONNECT="--justconnect"
#Set the path to your imapsync binary
imapsync=/usr/bin/imapsync
#Users file
if [ -z "$1" ]
then
echo "No users text file given."
echo "users file sintax: "
echo "hostname-or-ip-old-server;user@domain.com;old-P4ssW0rd;user@domain.com;new-P4ssW0rd"
exit
fi
if [ ! -f "$1" ]
then
echo "Given users text file \"$1\" does not exist"
exit
fi
{ while IFS=';' read s1 u1 p1 u2 p2; do
$imapsync --usecache --tmpdir /var/tmp \
--host1 $s1 --user1 "$u1" \
--password1 "$p1" --ssl1 \
--host2 ${SERVER2} \
--port2 993 --user2 "$u2" \
--password2 "$p2" --ssl2 \
--no-modules_version \
${FAST} ${DRY} ${JUSTFOLDERS} ${JUSTCONNECT}
#--regextrans2 's{Sent$}{[Gmail]/Sent Mail}' \
#--regextrans2 's{Sent Items$}{[Gmail]/Sent Mail}' \
#--regextrans2 's{Sent Messages$}{[Gmail]/Sent Mail}' \
#--regextrans2 's{Drafts$}{[Gmail]/Drafts}' \
#--exclude 'INBOX.Trash|INBOX.spam|INBOX.Apple Mail To Do'
done ; } < $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment