Migrate old iRedMail server to the latest stable release

WARNING: Please try it on a test server first. if it works well, then try it on product server.

Since new iRedMail server will install same components as old server, you can choose what data you want to migrate. Most important data are:

WARNING: Do not restore database mysql exported from old server, it contains SQL usernames/passwords for Roundcube/Amavisd/Policyd/Cluebringer used on old server. New iRedMail server has the same SQL usernames, but different passwords. So please do not restore it.

Client settings (Outlook, Thunderbird)

Since iRedMail-0.8.7, iRedMail enforces secure POP3/IMAP/SMTP connections. Mail client programs must issue 'STARTTLS' command before authentication, so please update your mail client programs you must change your mail client programs (e.g. Outlook, Thunderbird) to use TLS connection.

Additional notes:

LDAP: migrate mail accounts

Steps to migrate LDAP mail accounts:

Normally, LDAP data can be exported into LDIF format. Here's backup/export script: http://www.iredmail.org/wiki/index.php?title=IRedMail/FAQ/Backup

Notes:

MySQL/PostgreSQL: Migrate mail accounts

All mail accounts are stored in database vmail by default, to migrate mail accounts, you can simply export this database on old server, then import it on new server.

IMPORTANT NOTE: iRedMail-0.8.7 drops several SQL columns, so before you import backup SQL database, please add them first. It's safe to drop them after you imported old database on new server.

mysql> USE vmail;

mysql> ALTER TABLE mailbox ADD COLUMN bytes BIGINT(20) NOT NULL DEFAULT 0;
mysql> ALTER TABLE mailbox ADD COLUMN messages BIGINT(20) NOT NULL DEFAULT 0;

mysql> ALTER TABLE domain ADD COLUMN defaultlanguage VARCHAR(5) NOT NULL DEFAULT 'en_US';
mysql> ALTER TABLE domain ADD COLUMN defaultuserquota BIGINT(20) NOT NULL DEFAULT '1024';
mysql> ALTER TABLE domain ADD COLUMN defaultuseraliases TEXT;
mysql> ALTER TABLE domain ADD COLUMN disableddomainprofiles VARCHAR(255) NOT NULL DEFAULT '';
mysql> ALTER TABLE domain ADD COLUMN disableduserprofiles VARCHAR(255) NOT NULL DEFAULT '';
mysql> ALTER TABLE domain ADD COLUMN defaultpasswordscheme VARCHAR(10) NOT NULL DEFAULT '';
mysql> ALTER TABLE domain ADD COLUMN minpasswordlength INT(10) NOT NULL DEFAULT 0;
mysql> ALTER TABLE domain ADD COLUMN maxpasswordlength INT(10) NOT NULL DEFAULT 0;

mysql> ALTER TABLE alias ADD COLUMN islist TINYINT(1) NOT NULL DEFAULT 0;

After imported backup SQL databases, please execute below commands to mark mail alias accounts and drop above newly created columns:

mysql> USE vmail;
mysql> UPDATE alias SET islist=1 WHERE address NOT IN (SELECT username FROM mailbox);
mysql> UPDATE alias SET islist=0 WHERE address=domain;    -- domain catch-all account

-- Store values into new column: domain.settings and drop them
mysql> UPDATE domain SET settings='';
mysql> UPDATE domain SET settings=CONCAT(settings, IF(defaultlanguage IS NULL OR defaultlanguage='', '', CONCAT('default_language:', defaultlanguage, ';')));
mysql> UPDATE domain SET settings=CONCAT(settings, IF(defaultuserquota IS NULL OR defaultuserquota=0, '', CONCAT('default_user_quota:', defaultuserquota, ';')));
mysql> UPDATE domain SET settings=CONCAT(settings, IF(defaultuseraliases IS NULL OR defaultuseraliases='', '', CONCAT('default_groups:', defaultuseraliases, ';')));
mysql> UPDATE domain SET settings=CONCAT(settings, IF(minpasswordlength IS NULL OR minpasswordlength=0, '', CONCAT('min_passwd_length:', minpasswordlength, ';')));
mysql> UPDATE domain SET settings=CONCAT(settings, IF(maxpasswordlength IS NULL OR maxpasswordlength=0, '', CONCAT('max_passwd_length:', maxpasswordlength, ';')));
mysql> UPDATE domain SET settings=CONCAT(settings, IF(disableddomainprofiles IS NULL OR disableddomainprofiles='', '', CONCAT('disabled_domain_profiles:', disableddomainprofiles, ';')));
mysql> UPDATE domain SET settings=CONCAT(settings, IF(disableduserprofiles IS NULL OR disableduserprofiles='', '', CONCAT('disabled_user_profiles:', disableduserprofiles, ';')));

mysql> ALTER TABLE domain DROP defaultlanguage;
mysql> ALTER TABLE domain DROP defaultuserquota;
mysql> ALTER TABLE domain DROP defaultuseraliases;
mysql> ALTER TABLE domain DROP minpasswordlength;
mysql> ALTER TABLE domain DROP maxpasswordlength;
mysql> ALTER TABLE domain DROP disableddomainprofiles;
mysql> ALTER TABLE domain DROP disableduserprofiles;

IMPORTANT NOTE: There might be some changes in SQL structure, please read all upgrade tutorials for your current iRedMail release, then apply SQL structure related changes. Check upgrade tutorials for iRedMail.

Migrate mailboxes (Maildir format)

WARNING: please make sure maildir path stored in SQL/LDAP matches the mailbox path on file system, so that mail clients can find imported emails.

mysql> USE vmail;
mysql> SELECT CONCAT(storagebasedirectory, '/', storagenode, '/', maildir) FROM mailbox WHERE username='user@domain.com';
$ ldapsearch -x -D 'cn=Manager,dc=xx,dc=xx' -b 'o=domains,dc=xx,dc=xx' -W "(mail=user@domain.com)" homeDirectory

Migrate Roundcube webmail data

Document published under a CC BY-ND 3.0 license. If you found something wrong, please do contact us to fix it.