Skip to content

Instantly share code, notes, and snippets.

@dhyegocalota
Created September 16, 2016 13:09
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 dhyegocalota/672677b0c75565573b389b8f47348cea to your computer and use it in GitHub Desktop.
Save dhyegocalota/672677b0c75565573b389b8f47348cea to your computer and use it in GitHub Desktop.
imapsync
#!/bin/sh
error() { echo "$@" 1>&2; }
file=$1
if [ -z $file ]; then
error "Usage \`./migrate credentials.txt\`"
exit 1
fi
echo Looping on account credentials found in $file
echo
while IFS=';' read h1 u1 p1 h2 u2 p2; do
# Skip commented lines in $file
{ echo "$h1" | egrep "^#" ; } > /dev/null && continue
echo "==== Starting imapsync from host1 $h1 user1 $u1 to host2 $h2 user2 $u2 ===="
imapsync \
--host1 "$h1" --user1 "$u1" --password1 "$p1" --ssl1 \
--host2 "$h2" --user2 "$u2" --password2 "$p2" --ssl2 \
"$@" > /dev/null 2>&1
echo "==== Ended imapsync from host1 $h1 user1 $u1 to host2 $h2 user2 $u2 ===="
echo
done < $file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment