Alan McGinlay
2014-Mar-28 13:45 UTC
[Dovecot] basic dsync wrapper for migration from another server
Hi, I cobbled together this somewhat shoddy Bash script to migrate email accounts from our Cyrus server to a new dovecot system. Feel free to use, or laugh at it as you wish :) #!/bin/bash ## # Migrate email accounts via IMAP from one server to another ## trap "kill 0" SIGINT workdir=/root/migrate # Load list of users into array. The file "migration_map" should contain one user at domain.tld per line. mapfile userList < $workdir/migration_map # Number of symultanious migrations num=10 index=0 # Loop over the array of user accounts function process_userlist { procs=$(ps aux | grep "dsync" | grep -v "grep" | wc -l) # Perform $num operations at a time for the length of the userList while [[ $procs -lt $num ]] && [[ ${#userList[@]} -gt $index ]]; do procs=$(ps aux | grep "dsync" | grep -v "grep" | wc -l) dsync -o mail_fsync=never mirror -f -R -u ${userList[$index]} imapc:& echo "procs: $procs user: ${userList[$index]} index: $index" let index++ done } # Until the userList is empty, keep going until [ ${#userList[@]} -eq $index ]; do process_userlist done exit 0
Frank Elsner
2014-Mar-28 16:41 UTC
[Dovecot] basic dsync wrapper for migration from another server
On Fri, 28 Mar 2014 14:45:05 +0100 Alan McGinlay wrote:> Hi, > > I cobbled together this somewhat shoddy Bash script to migrate email > accounts from our Cyrus server to a new dovecot system. Feel free to > use, or laugh at it as you wish :)I do want to rate your script but do you know http://www.cyrus2dovecot.sw.fu-berlin.de Kind regards, Frank -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: not available URL: <http://dovecot.org/pipermail/dovecot/attachments/20140328/4aa21241/attachment.sig>