1

Topic: Migrate mailboxes and user accounts

I am about to install the newest Iredmail package on Ubuntu 18.04 server. I have never used Iredmail. My current email server is running Mysql, Dovecot, basically all the same services that Iredmail uses. My biggest issue will be migrating over the user mailboxes and username/passwords.

Is there a script to import in emails/passwords also from a csv or sql dump file?

For the mailboxes mine are stored in /var/vmail/$domain/$username format. I have noticed that Iredmail is also in /var/vmail by default but a different directory structuring format. So a simple rsync copy would not work well.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Migrate mailboxes and user accounts

- For mailboxes, try "imapsync" command with Dovecot Master User: https://docs.iredmail.org/dovecot.master.user.html
  this way you don't need to take care of the maildir path under /var/vmail(/vmail1) at all.

- For mail accounts, you need some shell scripting or just SQL commands.

Here's a tutorial for shell scripting: https://docs.iredmail.org/sql.create.mail.user.html
With SQL commands, you can try to import old mail accounts to a temporary SQL database (e.g. "oldvmail") on iRedMail server, then use the "INSERT INTO vmail.... SELECT ... FROM oldvmail...." command to migrate mail accounts, make sure you have correct SQL columns populated.

btw, i suppose this reddit thread was posted by you?
https://www.reddit.com/r/linuxadmin/com … migration/

3

Re: Migrate mailboxes and user accounts

I'll try that SQL shell script.

I thought I saw a config change where you can set dovecot mail directories to "normal"?
/var/vmail/vmail1/domain/username. If it's like that then I can just use rsync. Which I'd prefer.

4

Re: Migrate mailboxes and user accounts

Icedutah wrote:

I thought I saw a config change where you can set dovecot mail directories to "normal"?

Here's the document for iRedAdmin and iRedAdmin-Pro:
https://docs.iredmail.org/iredadmin-pro … .path.html

For shell script, you can open it and modify the path.

5 (edited by Icedutah 2019-03-06 12:15:58)

Re: Migrate mailboxes and user accounts

For this script, create_mail_user_SQL.sh it asks to import a plain_text password. What if I only have the old server passwords in MD5 format? They are md5crypt created from Postfixadmin.

Also, can you pass a file to the script instead of each user line by line?

6

Re: Migrate mailboxes and user accounts

Icedutah wrote:

For this script, create_mail_user_SQL.sh it asks to import a plain_text password. What if I only have the old server passwords in MD5 format? They are md5crypt created from Postfixadmin.

Should be easy to modify this script to avoid encrypting password and use the value on command line directly.

Icedutah wrote:

Also, can you pass a file to the script instead of each user line by line?

You can achieve this with the "for" loop in bash shell.

Anyway, i will try to provide a script to import users from text/csv file directly.
Question: what kind of info do you want to import besides email and password?

7

Re: Migrate mailboxes and user accounts

I modified the script and it's using the md5 perfectly. Just had to add {crypt} before the hashes. Imported to mysql and it's all working.


Also decided to use the default mail paths. Now I will use imapsync instead of rsync.

Thanks! Can't wait to make this live soon.