Skip to content

Instantly share code, notes, and snippets.

@phenobarbital
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phenobarbital/2380a0e9e1f1d07e1c42 to your computer and use it in GitHub Desktop.
Save phenobarbital/2380a0e9e1f1d07e1c42 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Simple sync mails using Imapsync
# Authors:
# Jesus Lara <jesuslara@phenobarbital.info>
# version: 2.0
# Copyright (C) 2010 Jesus Lara
oldserver=10.0.0.10
newserver=10.0.0.11
while read p; do
user=( $p )
uid=${p%@*}
pass=${user[1]}
echo "Migrating mail from user ${uid}"
/usr/bin/imapsync --authmech1 LOGIN --host1 $oldserver --authmech2 LOGIN --host2 $newserver --user1 $uid --password1 $pass --user2 $uid --password2 $pass --
syncinternaldates --allowsizemismatch --subscribe_all
if [ $? -eq 0 ]; then
echo "migration sucessful: ${uid}"
else
echo "ERROR in ${uid}"
echo "${uid} >>error_mbox.log"
fi
done<migrate_mail.txt
echo "Migration Complete."
exit 0
@phenobarbital
Copy link
Author

"migrate_mail.txt" is a list of users, in a "user pass" format, one line per user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment