Changing distributions
This article describes how to change the distribution BlueMind works on. It can be used to update the distribution (Ubuntu 16.04 to Ubuntu 18.04 for instance).
This procedure is based on installing a target system to which the data is migrated. This new system will then replace the original one at the network level.
Prerequisites
- install BlueMind on the target system in an identical version to the original system and configured with the same external-url. The Setup Wizard must have been run on the target server. E.g.:
- if the original system uses BlueMind 4.0.5, the target system must have BlueMind 4.0.5 installed
- if the original external-url is bluemind.domain.tld, the target system's BlueMind must be configured with the external-url bluemind.domain.tld
- install a valid subscription for this OS
- the target system's root user must be able to authenticate as root on the original server, ideally using key authentication.
- the rsync utility must be installed on both systems.
Migration
Data migration is done in three steps to minimize service downtime:
- hot synchronization of server data to the target server - this is a time-consuming operation but does not cause service interruption
- cold synchronization - quick operation but causes service interruption
- switching servers
Hot synchronization
Allows you to make an initial copy of data without interrupting the service:
connect to the target server as root
stop services on the target servers:
bmctl stop
systemctl stop postfix.servicesynchronize BlueMind data using the rsync utility:
rsync -avH --delete root@origsrv.domain.tld:/var/spool/cyrus/ /var/spool/cyrus/
rsync -avH --delete root@origsrv.domain.tld:/var/lib/cyrus/ /var/lib/cyrus/
rsync -avH --delete root@origsrv.domain.tld:/var/spool/bm-hsm/ /var/spool/bm-hsm/
rsync -avH --delete root@origsrv.domain.tld:/var/spool/sieve/ /var/spool/sieve/
rsync -avH --delete root@origsrv.domain.tld:/var/spool/bm-elasticsearch/ /var/spool/bm-elasticsearch/
rsync -avH --delete root@origsrv.domain.tld:/var/spool/bm-docs/ /var/spool/bm-docs/
rsync -avH --delete root@origsrv.domain.tld:/var/spool/bm-filehosting/ /var/spool/bm-filehosting/
These operations can be interrupted and/or performed several times.
Note: The shorter the time between hot synchronization and cold synchronization, the faster cold synchronization will be.
Cold synchronization
Stop services on the servers (original and target):
bmctl stop
systemctl stop postfix.serviceIn the target server, synchronize the data again:
rsync -avH --delete root@origsrv.domain.tld:/var/spool/cyrus/ /var/spool/cyrus/
rsync -avH --delete root@origsrv.domain.tld:/var/lib/cyrus/ /var/lib/cyrus/
rsync -avH --delete root@origsrv.domain.tld:/var/spool/bm-hsm/ /var/spool/bm-hsm/
rsync -avH --delete root@origsrv.domain.tld:/var/spool/sieve/ /var/spool/sieve/
rsync -avH --delete root@origsrv.domain.tld:/var/spool/bm-elasticsearch/ /var/spool/bm-elasticsearch/
rsync -avH --delete root@origsrv.domain.tld:/var/spool/bm-docs/ /var/spool/bm-docs/
rsync -avH --delete root@origsrv.domain.tld:/var/spool/bm-filehosting/ /var/spool/bm-filehosting/In the target server, restart the PostgreSQL of the original server:
ssh root@origsrv.domain.tld "systemctl start postgresql.service"
In the target server, perform a dump of the original server database:
ssh root@origsrv.domain.tld "PGPASSWORD=bj pg_dump --format=c --username=bj --host localhost bj" > /tmp/dump-bj.sql
ssh root@origsrv.domain.tld "PGPASSWORD=bj pg_dump --format=c --username=bj --host localhost bj-data" > /tmp/dump-bj-data.sqlIn the target server, copy the original server's files to the target server:
rsync -av -r root@origsrv.domain.tld:/etc/bm/\* /etc/bm
rsync -av root@origsrv.domain.tld:/etc/nginx/sw.htpasswd /etc/nginx/sw.htpasswd
rsync -av -r root@origsrv.domain.tld:/etc/bm-hps/\* /etc/bm-hps
rsync -av root@origsrv.domain.tld:/etc/ssl/certs/bm_cert*.pem /etc/ssl/certs
rsync -av -r root@origsrv.domain.tld:/var/lib/bm-ca/\* /var/lib/bm-ca
rsync -av root@origsrv.domain.tld:/usr/share/bm-elasticsearch/config/elasticsearch.yml /usr/share/bm-elasticsearch/config/elasticsearch.yml
rsync -av root@origsrv.domain.tld:/etc/imapd\* /etc/
rsync -av root@origsrv.domain.tld:/etc/cyrus\* /etc/
rsync -av root@origsrv.domain.tld:/etc/bm-webmail/\* /etc/bm-webmail/
rsync -av root@origsrv.domain.tld:/etc/postfix/main.cf /etc/postfix/main.cf
rsync -av root@origsrv.domain.tld:/etc/postfix/master.cf /etc/postfix/master.cf
rsync -av root@origsrv.domain.tld:/etc/postfix/master_relay_transport-flat /etc/postfix/master_relay_transport-flat
rsync -av root@origsrv.domain.tld:/etc/postfix/master_relay_transport.db /etc/postfix/master_relay_transport.db
rsync -av root@origsrv.domain.tld:/etc/postfix/transport-flat /etc/postfix/transport-flat
rsync -av root@origsrv.domain.tld:/etc/postfix/transport.db /etc/postfix/transport.db
rsync -av root@origsrv.domain.tld:/etc/postfix/virtual_alias-flat /etc/postfix/virtual_alias-flat
rsync -av root@origsrv.domain.tld:/etc/postfix/virtual_alias.db /etc/postfix/virtual_alias.db
rsync -av root@origsrv.domain.tld:/etc/postfix/virtual_domains-flat /etc/postfix/virtual_domains-flat
rsync -av root@origsrv.domain.tld:/etc/postfix/virtual_domains.db /etc/postfix/virtual_domains.db
rsync -av root@origsrv.domain.tld:/etc/postfix/virtual_mailbox-flat /etc/postfix/virtual_mailbox-flat
rsync -av root@origsrv.domain.tld:/etc/postfix/virtual_mailbox.db /etc/postfix/virtual_mailbox.dbIn the target server, restart PostgreSQL:
systemctl start postgresql.service
Import the database into the target server:
su - postgres
dropdb bj
dropdb bj-data
createdb bj
createdb bj-data
export nb_cpu=$(cat /proc/cpuinfo |grep "processor"|wc -l)
pg_restore -C --jobs=${nb_cpu} -d bj /tmp/dump-bj.sql
pg_restore -C --jobs=${nb_cpu} -d bj /tmp/dump-bj-data.sql
exit
Switching servers
- Stop the original server
- Reconfigure the target server with the original server's IP address
- Restart the target server and connect to the network instead of the original server so that it can be reached instead of the original server
Post-migration
Log into the BlueMind Administration console as admin0@global.virt and:
- Go to the section Security > Firewall and immediately click "Save" to force the BlueMind firewall's rules regeneration
- Go to System Management > Mail Maintenance, click "Run" to regenerate the mail postfix routing tables
- Go to System Management > System Configuration and replace the old IP address in the "My Networks" field by the new address or the address range for which you want the relay open and click "Save"