Moving a single-server system to another server
Task description
Starting point:
There is a platform instance installed on a server (possibly virtual) with Debian.
The platform is installed on the local address of the virtual server (say, 172.27.1.121).
The main domain DBMS postgresql is installed on the same machine by the platform installer.
The DBMS is installed in a docker container.
The platform must be moved to another server with a different address (say 172.27.5.122).
Data must be preserved, including the license, configuration, and settings.
Approaches
1. Via export/import.
This option is applicable if the installation is standard, the number of domains is small, and historical data is not important.
2. Via DB backup (pg_basebackup)
A new system is installed, and then instead of an empty domain postgres DB a connection is made to the previously backed-up copy.
This can be done by replacing the DBMS directory with configuration and data, or by configuring a new DBMS instance based on the backup and then replacing the connection string in the configuration.
In this case the following must also be copied from the previous system:
-
The syncroot directory with domain data (including script files).
-
The recpath directory with conversation recordings, if recording was not configured to external storages.
-
The license.
-
The configuration (it will need additional adaptation to the new server addresses).
If the system connected to external DBMS and file storages, then with access to them using the same connection parameters the connection will happen automatically.
The exception is NFS and other mounted file systems, which should be mounted to the server in advance.
If external storages become available under different addresses or credentials, then connection settings to storages must be adjusted in the domains.
3. Via DB script (pg_dump)
Unlike the previous item, the DB is not backed up and connected but a script is created with the pg_dump utility and then applied to the new DB.
The script is created separately for each DB within the DBMS, i.e., 1-2 times per domain.
This method should be used if data must be moved under another DBMS server version, or an existing postgres instance must be enriched with platform databases and data while leaving other existing objects unchanged.
What is needed
1. Installation string with parameters
During the main system installation the following installer launch string with parameters was used:
bash install_ssh.sh \ -u era \ -p 22 \ --host=188.1.1.1 \ --ipaddress=172.27.1.121 \ --postfix=_myinstance \ --master=y \ --masterdomain=era.test \ --srvname=mysrv1 \ --dopginstall=y \ --usereplic=n \ --pgmode=d \ --pgport=5432 \ --pgpostgrespwd=MyPwd1234 \ --pskcookie=123456 \ --usedefaults
If such a string was not used, it must be composed by recovering all used values, including defaults.
2. Active configuration
After logging in to the master domain, open the configuration for editing and copy its content.
An alternative path is to get it from disk; it is located in the cfgv3.json file in the working directory of the node with the mic role, for example in the container it is
/var/lib/era/_workdir/mic1@172.27.1.121/cfgv3.json
and on the host by default
/opt/era_myinstance/lib/_workdir/mic1@172.27.1.121/cfgv3.json
3. License
After logging in to the master domain, open the page /api/admin/v1/lic/download in the browser address bar.
An alternative path is to get it from disk; it is located in the r.lic file in the working directory of the node with the mdc role, for example in the container it is:
/var/lib/era/_workdir/mdc1@172.27.1.121/lic/r.lic
and on the host by default
/opt/era_myinstance/lib/_workdir/mdc1@172.27.1.121/lic/r.lic
4. Files
The syncroot directory contains domain files available to all servers of the deployed platform. For example, script files.
The directory should be copied entirely to the new system: it (secure/keys/) stores installation key files, without which the secrets of the restored DB (passwords, tokens, configuration secrets) are not decrypted.
Key files from it (secure/keys/*.json) are placed into the installer directory of the new first server before installation: the installer does not create a new key but uses the previous one (the key of the configuration that was active — the installation parameter cryptokid), and there is no re-encryption on configuration activation. The directory is copied together with the DB replacement, before starting the platform with it, with addition. The procedure, including without a placed key, is in Encryption and keys.
Platform installation options with backup DB connection.
There are two options:
1. Install the platform with a new DB and then replace the DB.
1.1. Install a new platform instance on the current local address with the same installation parameters (mainly DB passwords), placing the key files from the syncroot backup (more). Adjust the parameters that are necessary (for example, installation address, volume directory binding). It is important that the DB is installed with the same version.
1.2. Prepare the DB on the source for backup.
1.3. Replace the DB. That is, back up the DB, disable the backup state, replace the target DB directory. Or back up directly to the postgres installation point, having previously renamed the previous data folder.
2. Install the platform connecting to a new pre-prepared DB.
2.1. Manually install the DB on the new server (only postgresql) of the same version as on the source server.
2.2. Back up the DB from the source server into a new folder on the destination server /var/lib/postgresql/14/era.
2.3. Install a new platform instance (with the key files placed as in item 1.1), in the DB server installation section choosing "connect to an existing DB" and entering your DB server address and port. If everything is local — up to 127.0.0.1
Further operations
*.4. Upload the license.
*.5. Log in to the master domain as admin, open configurations, find the latest one, adjust it if necessary by changing addresses (and, unlikely, paths).
*.6. Copy the syncroot directory from the previous server (preferably together with the DB replacement, before starting the platform with it; in any case before activating the configuration from item *.5: it contains installation keys).
*.7. Copy the era_recpath directory from the previous server.
*.8. Install the product layer and custom packages.