Addition/Migrate.to.New.iRedMail.Server

From iRedMail

(Difference between revisions)
Jump to: navigation, search
(Migrate mailboxes)
(Migrate mailboxes (in maildir format))
 
(9 intermediate revisions not shown)
Line 6: Line 6:
Since new iRedMail server will install same components as old server, you
Since new iRedMail server will install same components as old server, you
-
can choose what data you want to migrate. The major data are mail accounts,
+
can choose what data you want to migrate. The major data are mail accounts, user mailboxes, roundcube webmail database, Policyd database, Amavisd database.
-
roundcube webmail database, mailboxes.
+
Line 16: Line 15:
* Export mail accounts from LDAP on OLD mail server.
* Export mail accounts from LDAP on OLD mail server.
-
Normally, LDAP data can be exported into LDIF format. Here's backup/export script:
+
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
-
http://www.iredmail.org/wiki/index.php?title=IRedMail/FAQ/Backup
+
-
After exported from old server, you will get a plain text file which has
+
'''Note''':
-
LDIF data. You should remove top some items, includes:
+
* There might be some changes in LDAP schema, please read all upgrade tutorials for your running iRedMail version, then apply LDAP data related upgradings. For example:
-
* dc=xxx,dc=xxx
+
** http://iredmail.org/wiki/index.php?title=Upgrade/iRedMail/0.5.1-0.6.0#Add_missing_values
-
* cn=vmail,dc=xxx,dc=xxx
+
** http://iredmail.org/wiki/index.php?title=Upgrade/iRedMail/0.6.1-0.7.0#Add_missing_value_for_mail_users
-
* cn=vmailadmin,dc=xxx,dc=xxx
+
* You can find all upgrade tutorials of iRedMail here: http://www.iredmail.org/doc.html#upgrade_tutorial
-
* o=domains,dc=xxx,dc=xxx
+
-
Because we will use these ldap objects on new server, so remove them from
+
== MySQL: Migrate mail accounts ==
-
exported data.
+
-
Assume the exported backup data is saved in file /root/old.ldif
+
All mail accounts are stored in database '''vmail''' by default, to migrate mail accounts, just simply export this database on old server, then import it on new server.
-
* Now, log into phpLDAPadmin with cn=Manager,dc=xxx,dc=xxx on NEW server, remove object of your mail domain. it should be:
+
'''Note''': There might be some changes in SQL structure, please read all upgrade tutorials for your running iRedMail version, then apply SQL structure related upgradings. For example:
-
** domainName=your_domain.com,o=domains,dc=xxx,dc=xxx
+
* http://www.iredmail.org/wiki/index.php?title=Upgrade/iRedMail/0.7.4-0.8.0#Add_internal_service_required_by_Doveadm_2
-
 
+
-
* Remove all sub-objects under this object.
+
-
* Import /root/old.ldif with phpLDAPadmin.
+
-
You can find a button named "Import" in phpLDAPadmin left panel.
+
-
 
+
-
* There might be some changes to LDAP schema, please read all upgrade tutorials for your running iRedMail version, then apply LDAP data related upgradings. For example:
+
-
** http://iredmail.org/wiki/index.php?title=Upgrade/iRedMail/0.5.1-0.6.0#Add_missing_values
+
-
** http://iredmail.org/wiki/index.php?title=Upgrade/iRedMail/0.6.1-0.7.0#Add_missing_value_for_mail_users
+
-
 
+
-
Note: You can find all upgrade tutorials here: http://www.iredmail.org/doc.html#upgrade_tutorial
+
== Migrate mailboxes (in maildir format) ==
== Migrate mailboxes (in maildir format) ==
* Simply copy all mailboxes (in maildir format) to new iRedMail server.
* Simply copy all mailboxes (in maildir format) to new iRedMail server.
 +
* Set correct file owner of mailboxes. Default is owned by user '''vmail''', group '''vmail'''.
 +
* Set correct file permission of mailboxes. Default is 0700.
WARNING: please make sure maildir path which stored/configured in LDAP
WARNING: please make sure maildir path which stored/configured in LDAP
Line 51: Line 39:
them.
them.
 +
=== Important Notes for MySQL backend ===
 +
'''This section is applicable to iRedMail-0.7.3 and earlier versions, with MySQL backend. Not required in iRedMail-0.7.4 and later versions.'''
-
* '''IMPORTANT NOTE FOR MYSQL BACKEND''': Please force Dovecot to recalculate migrated users' mailbox quota after you copied/migrated mailboxes. Here's tutorial: [[IRedMail/FAQ/Recalculate.Mailbox.Quota |How to force Dovecot to re-calculate mailbox quota]]
+
Please refer to this section for more details: [http://iredmail.org/wiki/index.php?title=Upgrade/iRedMail/0.7.3-0.7.4#Store_realtime_mailbox_quota_usage_in_seperate_SQL_table Store realtime mailbox quota usage in seperate SQL table]
-
 
+
-
This step is REQUIRED if you migrated mailboxes with iRedMail '''MySQL backend'''. Otherwise Dovecot will delete records in table '''vmail.mailbox''' to re-calculate mailbox quota.
+
-
 
+
-
 
+
-
Here's simple tutorial for your reference:
+
-
 
+
-
1) List all migrated users' email address in a plain text file, one address per line. Assume this file is /root/all_migrated_users.list.
+
-
 
+
-
2) Create shell script '''/root/get_sql_commands.sh''' with below content.
+
-
{{cmd|<pre>
+
-
while read email; do
+
-
    cat >> /root/result.sql <<EOF
+
-
UPDATE mailbox SET bytes=-1,messages=-1 WHERE username="${email}";
+
-
EOF
+
-
done < /root/all_migrated_users.list
+
-
</pre>}}
+
-
 
+
-
3) Execute this shell script. As shown in shell code, it will create a file named "result.sql" under directory /root.
+
-
{{cmd|<pre>
+
-
# bash /root/get_sql_commands.sh
+
-
</pre>}}
+
-
 
+
-
4) Import this SQL file to update SQL table, it will force Dovecot to re-calculate migrated users' mailbox quota when user first login to Roundcube webmail (or access mailbox via other IMAP clients).
+
-
{{cmd|<pre>
+
-
# mysql -uroot -p
+
-
mysql> USE vmail;
+
-
mysql> SOURCE /root/result.sql;
+
-
</pre>}}
+
== Migrate Roundcube webmail data ==
== Migrate Roundcube webmail data ==
Line 86: Line 48:
* Export/import roundcube webmail database, and upgrade database to work with new version of Roundcube.
* Export/import roundcube webmail database, and upgrade database to work with new version of Roundcube.
http://trac.roundcube.net/wiki/Howto_Upgrade
http://trac.roundcube.net/wiki/Howto_Upgrade
 +
 +
== Migrate Policyd database ==
 +
 +
Policyd database stores blacklist/whitelist, throttling, etc. To migrate its data, simply export this database on old server, then import it on new server.

Current revision as of 00:07, 20 June 2012

Contents


TO BE CONTINUED.

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. The major data are mail accounts, user mailboxes, roundcube webmail database, Policyd database, Amavisd database.


LDAP: migrate mail accounts

Steps to migrate LDAP mail accounts:

  • Setup a new server with the latest iRedMail, and make iRedAdmin-Pro-LDAP work as expected.
  • Export mail accounts from LDAP on OLD mail server.

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

Note:

MySQL: Migrate mail accounts

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

Note: There might be some changes in SQL structure, please read all upgrade tutorials for your running iRedMail version, then apply SQL structure related upgradings. For example:

Migrate mailboxes (in maildir format)

  • Simply copy all mailboxes (in maildir format) to new iRedMail server.
  • Set correct file owner of mailboxes. Default is owned by user vmail, group vmail.
  • Set correct file permission of mailboxes. Default is 0700.

WARNING: please make sure maildir path which stored/configured in LDAP will match the real path on file system, so that mail clients can find them.

Important Notes for MySQL backend

This section is applicable to iRedMail-0.7.3 and earlier versions, with MySQL backend. Not required in iRedMail-0.7.4 and later versions.

Please refer to this section for more details: Store realtime mailbox quota usage in seperate SQL table

Migrate Roundcube webmail data

  • Export/import roundcube webmail database, and upgrade database to work with new version of Roundcube.

http://trac.roundcube.net/wiki/Howto_Upgrade

Migrate Policyd database

Policyd database stores blacklist/whitelist, throttling, etc. To migrate its data, simply export this database on old server, then import it on new server.

Personal tools