From 4659dc0de80a73a01e0d05c8a7f954dad4d3a771 Mon Sep 17 00:00:00 2001 From: timo Date: Sat, 6 May 2017 03:19:10 +0200 Subject: [PATCH] Added chapter on migrating from MC v0.14 --- docs/mc14_import.md | 94 ++++++++++++++++++++++++++++++++++++++++++++ docs/requirements.md | 6 +-- mkdocs.yml | 2 +- 3 files changed, 98 insertions(+), 4 deletions(-) diff --git a/docs/mc14_import.md b/docs/mc14_import.md index e69de29bb..a77aa05d7 100644 --- a/docs/mc14_import.md +++ b/docs/mc14_import.md @@ -0,0 +1,94 @@ +**WARNING** Please be adviced that this guide is a first draft. Mailcow: dockerized changed quite a lot on its DB configuration. It now uses the InnoDB file format `Barracuda` and the `utf8mb4` character set. There is also some change to the DB / TABLE structure. + +Also note that this guide doesn't touch on the users settings like *Spamlevels*, *TLS Settings*, etc. nor the export / import of your roundcube or SOGo settings. + +Lastly please check the section on how to [import / restore](backup_maildir/#restore) your maildir backup to get an idea how to migrate your mails. + +## Create mailcow db backups + +First you need to modify the table `mailcow`. Mailcow-dockerized adds three and moves two existing columns in the table `mailbox`. The columns `tls_enforce_in` and `tls_enforce_out` get moved two rows up (behind `domain`). The columns `key`, `multiple_bookings` and `wants_tagged_subject` need to be added after `tls_enforce_out`. + +It should look like this: + +``` +MariaDB [mailcow]> desc mailbox; ++----------------------+--------------+------+-----+-------------------+-----------------------------+ +| Field | Type | Null | Key | Default | Extra | ++----------------------+--------------+------+-----+-------------------+-----------------------------+ +| username | varchar(255) | NO | PRI | NULL | | +| password | varchar(255) | NO | | NULL | | +| name | varchar(255) | YES | | NULL | | +| maildir | varchar(255) | NO | | NULL | | +| quota | bigint(20) | NO | | 0 | | +| local_part | varchar(255) | NO | | NULL | | +| domain | varchar(255) | NO | MUL | NULL | | +| tls_enforce_in | tinyint(1) | NO | | 0 | | +| tls_enforce_out | tinyint(1) | NO | | 0 | | +| kind | varchar(100) | NO | | | | +| multiple_bookings | tinyint(1) | NO | | 0 | | +| wants_tagged_subject | tinyint(1) | NO | | 0 | | +| created | datetime | NO | | CURRENT_TIMESTAMP | | +| modified | datetime | YES | | NULL | on update CURRENT_TIMESTAMP | +| active | tinyint(1) | NO | | 1 | | ++----------------------+--------------+------+-----+-------------------+-----------------------------+ +``` + +You can do this with a UI like [Adminer](https://www.adminer.org/#download) or use the MySQL CLI like : + +``` +MariaDB [mailcow]> ALTER TABLE mailbox MODIFY COLUMN tls_enforce_in TINYINT(1) NOT NULL DEFAULT '0' AFTER domain, +MODIFY COLUMN tls_enforce_out TINYINT(1) NOT NULL DEFAULT '0' AFTER tls_enforce_in; +MariaDB [mailcow]> ALTER TABLE mailbox ADD COLUMN `kind` VARCHAR(255) NOT NULL AFTER `tls_enforce_out`, +ADD COLUMN `multiple_bookings` TINYINT(1) NOT NULL DEFAULT '0' AFTER `kind`, +ADD COLUMN `wants_tagged_subject` TINYINT(1) NOT NULL DEFAULT '0' AFTER `multiple_bookings`; +MariaDB [mailcow]> DESC mailbox; +``` + +When this is done we can backup the tables: + +``` +mysqldump --replace --no-create-info --default-character-set=utf8mb4 \ + -u $MAILCOWDB_USER -p$MAILCOWDB_PW $MAILCOWDB_NAME \ + alias alias_domain domain domain_admins mailbox quota2 sender_acl > backup_mailcow.sql +``` + +> **--replace**: Write `REPLACE` statements rather than `INSERT` statements +> **--no-create-info**: Don't write `CREATE TABLE` statements. +> **--default-character-set** make sure our exported default charset is *utf8mb4*. +> *Remember to adjust your mysql details* `MAILCOWDB_*` + + +## Prepare mailcow: dockerized + +Visit your new installation (http://host.domain.tld) with a browser of your choice to initiate the empty database. Check if the DB is initiated afterwards: + +``` +# source mailcow.conf +# docker-compose exec mysql-mailcow mysql -u${DBUSER} -p${DBPASS} ${DBNAME} +MariaDB [mailcow]> show tables; ++-------------------------------+ +| Tables_in_mailcow | ++-------------------------------+ +| admin | +| alias | +[...] +``` + +## Import your backups: + + ``` + # source mailcow.conf + # docker exec -i $(docker-compose ps -q mysql-mailcow) mysql -u${DBUSER} -p${DBPASS} ${DBNAME} < backup_mailcow.sql + ``` + + Recalculate used quota with `doveadm`: + + ``` + # docker-compose exec dovecot-mailcow doveadm quota recalc -A + ``` + + Restart SOGo: + + ``` + # docker-compose restart sogo-mailcow + ``` diff --git a/docs/requirements.md b/docs/requirements.md index 27c1de03d..479790960 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -20,8 +20,8 @@ Please make sure that your system has at least the following resources: Please check if any of mailcow's standard ports are open and not blocked by other applications: -```bash -netstat -tulpn | grep -E -w '25|80|110|143|443|465|587|993|995' +``` +# netstat -tulpn | grep -E -w '25|80|110|143|443|465|587|993|995' ``` If this command returns any results please remove or stop the application running on that port. You may also adjust mailcows ports via the `mailcow.conf` configuration file. @@ -40,7 +40,7 @@ If you have a firewall already up and running please make sure that these ports | Dovecot POP3 | TCP | 110 | dovecot-mailcow | `${POP_PORT}` | | Dovecot POP3S | TCP | 995 | dovecot-mailcow | `${POPS_PORT}` | | Dovecot ManageSieve | TCP | 4190 | dovecot-mailcow | `${SIEVE_PORT}` | -| HTTP(S) | TCP | 80/443 | nginx-mailcow | `${HTTP_PORT}`/`${HTTPS_PORT}` | +| HTTP(S) | TCP | 80/443 | nginx-mailcow | `${HTTP_PORT}` / `${HTTPS_PORT}` | ## Date and Time diff --git a/mkdocs.yml b/mkdocs.yml index 9b81a6cf6..8268cf5a2 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -8,7 +8,7 @@ markdown_extensions: pages: - 'Information & Support': 'index.md' - 'Prerequisites': - - 'System Requirements': 'requirements.md' + - 'Prepare Your System': 'requirements.md' - 'DNS Setup': 'dns.md' - 'Migrating from mailcow 0.14': 'mc14_import.md' - 'Installation & Update':