Welcome to Headwind MDM Q&A, where you can ask questions and receive answers from other members of the community.

Please do not post bug reports, missing feature requests, or demo inquiries. If you have such an inquiry, submit a contact form.

0 votes
I need to migrate a working service to another server, please help me how to do that?
by (36.8k points)
edited by

1 Answer

0 votes

Here are general steps to perform the migration:

  1. Install the required software on a new server;
  2. Copy the Headwind MDM database
  3. Copy the uploaded APKs and other files
  4. Copy the Headwind MDM files (executable, configuration, other files)
  5. Copy the SSL certificates and set up Tomcat (if required)
  6. Set up ports using iptables (if required)
  7. Make sure the new server works
  8. Change the DNS record

Here is the detailed manual.

1. Install the required software

sudo apt update

sudo apt install openjdk-8-jdk aapt tomcat8 postgresql

2. Copy the Headwind MDM database

2.1. Make a dump of the database on the legacy server

su - postgres

cd /tmp

pg_dump hmdm > hmdm_dump.sql

2.2. Copy the dump file to the new server

2.3. Create the database on the new server

Notice: keep the old password. The database access credentials can be found in the Headwind MDM configuration file: /var/lib/tomcat8/conf/Catalina/localhost/ROOT.xml (or .../hmdm.xml).

su postgres

psql

postgres=# CREATE USER hmdm WITH PASSWORD 'topsecret';

postgres=# CREATE DATABASE hmdm WITH OWNER=hmdm;

postgres=# \q

2.4. Fill the database with the dump

su postgres

psql hmdm < hmdm_dump.sql

3. Copy the uploaded APKs and other files to the new server

Files are located in the directory /var/lib/tomcat9/work/files. We recommend to archive all them, copy to the new server, then unzip.

cd /var/lib/tomcat9/work/files

zip -r hmdmfiles.zip *

scp hmdmfiles.zip user@my.new.server

To unzip the files, use the following commands on the new server

mv hmdmfiles.zip /var/lib/tomcat9/work/files

cd /var/lib/tomcat9/work/files

unzip hmdmfiles.zip

rm hmdmfiles.zip

chown -R tomcat:tomcat *

4. Copy the Headwind MDM files to the new server

Headwind MDM uses files stored in the following directories

  • /opt/hmdm/*
  • /var/lib/tomcat8/webapps/*.war
  • /var/lib/tomcat8/conf/Catalina/localhost/*.xml

Important! /var/lib/tomcat8/conf is a link, not a directory, so do not copy a whole directory, copy its contents only.

For example, you can copy files between servers using scp:

scp /var/lib/tomcat8/conf/Catalina/localhost/ROOT.xml user@new.server.com:/var/lib/tomcat8/conf/Catalina/localhost

If you're using FTP to copy files, copy /etc/tomcat8/Catalina/localhost instead of /var/lib/tomcat8/conf/Catalina/localhost, because FTP doesn't resolve Linux links.

5. Copy the SSL certificates and set up Tomcat

This step is required if you are using HTTPS

5.1. Copy the JKS file (Java Key Store) from the old to the new server

5.2. Set up the path and password to the JKS file in /var/lib/tomcat8/conf/server.xml

5.3. If you're using LetsEncrypt and set up automatic certificate renewal, copy the certificate renewal scripts to the new server

See more details about HTTPS here: https://qa.h-mdm.com/1240/

6. Set up ports using iptables

This step is required if you're using standard ports (80 or 443) instead of default Tomcat ports 8080 and 8443. See details here: https://qa.h-mdm.com/1533/

7. Make sure the new server is working

Try to open the web panel on a new server using http and IP address. It must show the login window. Notice: https may not work if you do not specify the domain name. Also, some functions like QR code generation or app uploads may not work as well.

7. Change the DNS record

If everything is working well, change the DNS record so the domain name of your MDM points to the new server.

by (36.8k points)
edited by
will this migrate also the devices?
also please check out the article https://qa.h-mdm.com/17774/
...