7.3 Restoring the Database on another Server

  1. Stop the ZENworks Services on the Primary Servers where the database is to be restored, by running the following configure action:

    microfocus-zenworks-configure -c Start

    After running the command, under Daemons, deselect Micro Focus ZENworks Embedded PostgreSQL, under Action, select Stop.

  2. On the Primary Server:

    1. Switch the user to zenpostgres by running the command su zenpostgres

    2. Enter zenpostgres container prompt by running below command:

      docker exec -it -e PGUSER=<super user retrieved from zman dgcs> -e PGDATABASE=postgres -e PGPASSWORD=<password retrieved from zman dgcs> zenpostgres bash

    3. cd /opt/microfocus/zenworks/share/pgsql/bin

  3. Start PSQL connection by running ./psql.

  4. Close the database dangling connections by running the following command:

    SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid = pg_backend_pid();
  5. Drop the following databases and users:

    • DROP DATABASE ZENWORKS;

    • DROP DATABASE ZENWORKSAUDIT;

    • DROP USER ZENAUDITADMIN;

    • DROP USER ZENADMIN;

  6. Create the database using the following query for the databases that should be restored:

    create database <DB name> with template=template0 encoding='UTF8';

    For example:

    • ZENworks Database: create database zenworks with template=template0 encoding='UTF8';

    • Audit Database: create database zenworksaudit with template=template0 encoding='UTF8';

  7. Run following command to change the password for user 'zenpostgres':

    ALTER ROLE zenpostgres WITH PASSWORD '<password retrieved from zman dgcs of the source db machine>';

  8. Exit PSQL.