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.
On the Primary Server:
Switch the user to zenpostgres by running the command su zenpostgres
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
cd /opt/microfocus/zenworks/share/pgsql/bin
Start PSQL connection by running ./psql.
Close the database dangling connections by running the following command:
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid = pg_backend_pid();
Drop the following databases and users:
DROP DATABASE ZENWORKS;
DROP DATABASE ZENWORKSAUDIT;
DROP USER ZENAUDITADMIN;
DROP USER ZENADMIN;
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';
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>';
Exit PSQL.