Cleanup migrate.to.new.iredmail.server.html.

New: openldap.structure.html.
This commit is contained in:
Zhang Huangbin 2018-10-02 12:02:22 +02:00
parent a143dc4493
commit 23cac8fdc8
5 changed files with 166 additions and 105 deletions

View File

@ -0,0 +1,56 @@
# OpenLDAP data structure configured by iRedMail
This is a brief introduction of the OpenLDAP data structure configured by
iRedMail. It may help a little if you want to migrate from/to other LDAP server.
## LDAP schema files
iRedMail requires 7 LDAP schema files listed below, 5 are shipped by OpenLDAP,
1 shipped by Amavisd, one by iRedMail:
* core.schema
* corba.schema
* cosine.schema
* inetorgperson.schema
* nis.schema
* amavisd.schema (names are different on different linux/bsd distros)
* iredmail.schema
If you're migrating to other LDAP server, it must include them all, otherwise
you may not be able to add or update mail accounts.
## Data structure
OpenLDAP configured by iRedMail has hard-coded / predictable structure, and
Postfix / Dovecot / iRedAPD /... are configured to query LDAP based on this
structure.
```
dc=xx,dc=xx
|- o=domains
|- domainName=example.com
|- ou=Aliases
|- ou=Groups
|- ...
|- ou=Users
|- mail=postmaster@example.com
|- mail=xxx
|- ...
```
With this predictable structure:
* it's easy to narrow down the query scope, the narrower the scope is, the
better performance you gain.
* no need to performing a query first to get the full dn of ldap object you're
going to modify.
If you don't use this structure:
* you have to update Postfix/Dovecot/iRedAPD/... config files to use different
query scopes and filters.
* The web-based admin panel - iRedAdmin(-Pro) - heavily relies on the
predictable structure, if you use different structure, you cannot manage mail
accounts with iRedAdmin(-Pro).

View File

@ -61,62 +61,17 @@ 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.
All mail accounts are stored in database `vmail`.
__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.
* If both old and new servers are running same iRedMail version, you can simply
export `vmail` database on old server, then import it on new server.
```mysql
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
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](./iredmail.releases.html).
* If old server is running an old iRedMail version, there might be some changes
in SQL structure, please read all upgrade tutorials for the old iRedMail
release, then apply SQL structure related changes to make sure old server
has same SQL structure. After you have same SQL structure on both servers,
you can simply export `vmail` database on old server, then import it on new
server. Check [upgrade tutorials for iRedMail](./iredmail.releases.html).
## Migrate mailboxes (Maildir format)

View File

@ -234,6 +234,7 @@
<li><a href="amavisd.sql.db.html">Explanation of Amavisd SQL database</a></li>
<li><a href="backup.restore.html">Backup and restore</a></li>
<li><a href="file.locations.html">Locations of configuration and log files of major components</a></li>
<li><a href="openldap.structure.html">OpenLDAP data structure configured by iRedMail</a></li>
<li><a href="why.no.sieve.support.in.sogo.html">Why no sieve support (Vacation, Forwarding) in SOGo Groupware</a></li>
</ul><div class="footer">
<p style="text-align: center; color: grey;">All documents are available in <a href="https://bitbucket.org/zhb/iredmail-docs/src">BitBucket repository</a>, and published under <a href="http://creativecommons.org/licenses/by-nd/3.0/us/" target="_blank">Creative Commons</a> license. You can <a href="https://bitbucket.org/zhb/iredmail-docs/get/tip.tar.bz2">download the latest version</a> for offline reading. If you found something wrong, please do <a href="https://www.iredmail.org/contact.html">contact us</a> to fix it.</p>

View File

@ -94,57 +94,21 @@ please update your mail client applications to use TLS connection.</p>
<li>Here are all <a href="https://docs.iredmail.org/iredmail.releases.html">upgrade tutorials for iRedMail</a>.</li>
</ul>
<h2 id="mysqlpostgresql-migrate-mail-accounts">MySQL/PostgreSQL: Migrate mail accounts</h2>
<p>All mail accounts are stored in database <code>vmail</code> by default, to migrate mail
accounts, you can simply export this database on old server, then import it
on new server.</p>
<p><strong>IMPORTANT NOTE</strong>: 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.</p>
<pre><code class="mysql">mysql&gt; USE vmail;
mysql&gt; ALTER TABLE mailbox ADD COLUMN bytes BIGINT(20) NOT NULL DEFAULT 0;
mysql&gt; ALTER TABLE mailbox ADD COLUMN messages BIGINT(20) NOT NULL DEFAULT 0;
mysql&gt; ALTER TABLE domain ADD COLUMN defaultlanguage VARCHAR(5) NOT NULL DEFAULT 'en_US';
mysql&gt; ALTER TABLE domain ADD COLUMN defaultuserquota BIGINT(20) NOT NULL DEFAULT '1024';
mysql&gt; ALTER TABLE domain ADD COLUMN defaultuseraliases TEXT;
mysql&gt; ALTER TABLE domain ADD COLUMN disableddomainprofiles VARCHAR(255) NOT NULL DEFAULT '';
mysql&gt; ALTER TABLE domain ADD COLUMN disableduserprofiles VARCHAR(255) NOT NULL DEFAULT '';
mysql&gt; ALTER TABLE domain ADD COLUMN defaultpasswordscheme VARCHAR(10) NOT NULL DEFAULT '';
mysql&gt; ALTER TABLE domain ADD COLUMN minpasswordlength INT(10) NOT NULL DEFAULT 0;
mysql&gt; ALTER TABLE domain ADD COLUMN maxpasswordlength INT(10) NOT NULL DEFAULT 0;
mysql&gt; ALTER TABLE alias ADD COLUMN islist TINYINT(1) NOT NULL DEFAULT 0;
</code></pre>
<p>After imported backup SQL databases, please execute below commands to mark
mail alias accounts and drop above newly created columns:</p>
<pre><code class="mysql">mysql&gt; USE vmail;
mysql&gt; UPDATE alias SET islist=1 WHERE address NOT IN (SELECT username FROM mailbox);
mysql&gt; UPDATE alias SET islist=0 WHERE address=domain; -- domain catch-all account
-- Store values into new column: domain.settings and drop them
mysql&gt; UPDATE domain SET settings='';
mysql&gt; UPDATE domain SET settings=CONCAT(settings, IF(defaultlanguage IS NULL OR defaultlanguage='', '', CONCAT('default_language:', defaultlanguage, ';')));
mysql&gt; UPDATE domain SET settings=CONCAT(settings, IF(defaultuserquota IS NULL OR defaultuserquota=0, '', CONCAT('default_user_quota:', defaultuserquota, ';')));
mysql&gt; UPDATE domain SET settings=CONCAT(settings, IF(defaultuseraliases IS NULL OR defaultuseraliases='', '', CONCAT('default_groups:', defaultuseraliases, ';')));
mysql&gt; UPDATE domain SET settings=CONCAT(settings, IF(minpasswordlength IS NULL OR minpasswordlength=0, '', CONCAT('min_passwd_length:', minpasswordlength, ';')));
mysql&gt; UPDATE domain SET settings=CONCAT(settings, IF(maxpasswordlength IS NULL OR maxpasswordlength=0, '', CONCAT('max_passwd_length:', maxpasswordlength, ';')));
mysql&gt; UPDATE domain SET settings=CONCAT(settings, IF(disableddomainprofiles IS NULL OR disableddomainprofiles='', '', CONCAT('disabled_domain_profiles:', disableddomainprofiles, ';')));
mysql&gt; UPDATE domain SET settings=CONCAT(settings, IF(disableduserprofiles IS NULL OR disableduserprofiles='', '', CONCAT('disabled_user_profiles:', disableduserprofiles, ';')));
mysql&gt; ALTER TABLE domain DROP defaultlanguage;
mysql&gt; ALTER TABLE domain DROP defaultuserquota;
mysql&gt; ALTER TABLE domain DROP defaultuseraliases;
mysql&gt; ALTER TABLE domain DROP minpasswordlength;
mysql&gt; ALTER TABLE domain DROP maxpasswordlength;
mysql&gt; ALTER TABLE domain DROP disableddomainprofiles;
mysql&gt; ALTER TABLE domain DROP disableduserprofiles;
</code></pre>
<p><strong>IMPORTANT NOTE</strong>: 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 <a href="./iredmail.releases.html">upgrade tutorials for iRedMail</a>.</p>
<p>All mail accounts are stored in database <code>vmail</code>.</p>
<ul>
<li>
<p>If both old and new servers are running same iRedMail version, you can simply
export <code>vmail</code> database on old server, then import it on new server.</p>
</li>
<li>
<p>If old server is running an old iRedMail version, there might be some changes
in SQL structure, please read all upgrade tutorials for the old iRedMail
release, then apply SQL structure related changes to make sure old server
has same SQL structure. After you have same SQL structure on both servers,
you can simply export <code>vmail</code> database on old server, then import it on new
server. Check <a href="./iredmail.releases.html">upgrade tutorials for iRedMail</a>.</p>
</li>
</ul>
<h2 id="migrate-mailboxes-maildir-format">Migrate mailboxes (Maildir format)</h2>
<div class="admonition warning">
<p class="admonition-title">Warning</p>

View File

@ -0,0 +1,85 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>OpenLDAP data structure configured by iRedMail</title>
<link rel="stylesheet" type="text/css" href="./css/markdown.css" />
</head>
<body>
<div id="navigation">
<a href="https://www.iredmail.org" target="_blank">
<img alt="iRedMail web site"
src="./images/logo-iredmail.png"
style="vertical-align: middle; height: 30px;"
/>&nbsp;
<span>iRedMail</span>
</a>
&nbsp;&nbsp;//&nbsp;&nbsp;<a href="./index.html">Document Index</a></div><h1 id="openldap-data-structure-configured-by-iredmail">OpenLDAP data structure configured by iRedMail</h1>
<p>This is a brief introduction of the OpenLDAP data structure configured by
iRedMail. It may help a little if you want to migrate from/to other LDAP server.</p>
<h2 id="ldap-schema-files">LDAP schema files</h2>
<p>iRedMail requires 7 LDAP schema files listed below, 5 are shipped by OpenLDAP,
1 shipped by Amavisd, one by iRedMail:</p>
<ul>
<li>core.schema</li>
<li>corba.schema</li>
<li>cosine.schema</li>
<li>inetorgperson.schema</li>
<li>nis.schema</li>
<li>amavisd.schema (names are different on different linux/bsd distros)</li>
<li>iredmail.schema</li>
</ul>
<p>If you're migrating to other LDAP server, it must include them all, otherwise
you may not be able to add or update mail accounts.</p>
<h2 id="data-structure">Data structure</h2>
<p>OpenLDAP configured by iRedMail has hard-coded / predictable structure, and
Postfix / Dovecot / iRedAPD /... are configured to query LDAP based on this
structure.</p>
<pre><code>dc=xx,dc=xx
|- o=domains
|- domainName=example.com
|- ou=Aliases
|- ou=Groups
|- ...
|- ou=Users
|- mail=postmaster@example.com
|- mail=xxx
|- ...
</code></pre>
<p>With this predictable structure:</p>
<ul>
<li>
<p>it's easy to narrow down the query scope, the narrower the scope is, the
better performance you gain.</p>
</li>
<li>
<p>no need to performing a query first to get the full dn of ldap object you're
going to modify.</p>
</li>
</ul>
<p>If you don't use this structure:</p>
<ul>
<li>
<p>you have to update Postfix/Dovecot/iRedAPD/... config files to use different
query scopes and filters.</p>
</li>
<li>
<p>The web-based admin panel - iRedAdmin(-Pro) - heavily relies on the
predictable structure, if you use different structure, you cannot manage mail
accounts with iRedAdmin(-Pro).</p>
</li>
</ul><div class="footer">
<p style="text-align: center; color: grey;">All documents are available in <a href="https://bitbucket.org/zhb/iredmail-docs/src">BitBucket repository</a>, and published under <a href="http://creativecommons.org/licenses/by-nd/3.0/us/" target="_blank">Creative Commons</a> license. You can <a href="https://bitbucket.org/zhb/iredmail-docs/get/tip.tar.bz2">download the latest version</a> for offline reading. If you found something wrong, please do <a href="https://www.iredmail.org/contact.html">contact us</a> to fix it.</p>
</div>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-3293801-21"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-3293801-21');
</script>
</body></html>