Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generate shell commands for migrating mail boxes from IMAP provider to Zimbra
import os
import sys
host1 = 'source.example.com'
host2 = 'destination.example.com'
cos = 'cos-of-group-for-the-account'
data = """test@example.com password
test3@example.com password3
test2@example.com password2"""
accounts = []
for a in data.split('\n'):
u,p = a.split(' ')
accounts.append({
"user": u,
"password": p
})
print "#!/bin/bash"
print "set -e"
for acc in accounts:
print "# account %s" % (acc['user'])
print "zmprov ca %s %s zimbraCOSid %s" % (acc['user'], acc['password'], cos)
print "imapsync --buffersize 8192000 --nosyncacls --subscribe --syncinternaldates --host1 %s --user1 %s --password1 %s --ssl1 --port1 993 --host2 %s --user2 %s --password2 %s -ssl2 --port2 993 --noauthmd5" % (host1, acc['user'], acc['password'], host2, acc['user'], acc['password'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment