Moving the data from an embedded PostgreSQL server to an external PostgreSQL server is a two step process:
Before executing the following steps, ensure that you have reviewed the information documented in the section Important Commands and Locations.
Stop the ZENworks Services on all the Primary Servers by running the following configure action:
microfocus-zenworks-configure -c Start
After running the command, under Action, select Stop.
On the Primary Server on which the Embedded Database is installed, Start the Micro Focus ZENworks Embedded Datastore service using the following steps:
On Windows: Press the Win + R keys on the keyboard to open the Run window. Type services. msc and then hit Enter.
Start the Micro Focus ZENworks Embedded Datastore – PostgreSQL service.
On Linux: Run the following command to start the Micro Focus ZENworks Embedded Datastore – PostgreSQL service.
On SLES 12 and later: systemctl start zenpostgresql.service
Login to the Primary Server that has the database role.
Initiate the backup by setting the following variables:
NOTE:This step is required for Windows only.
PGPORT: <existing source DB port configured>
By default, ZENworks uses 54327
PGDATA: <embedded_database_location>
PGUSER: <existing super user for ZENworks postgres DB> The default user for ZENworks is zenpostgres.
PGDATABASE: <existing database name> ZENworks default is postgres
PGPASSWORD: <password for the above super user PGUSER>
Example 5-1 Example for Windows Primary Server
Set the following environment variables:
Set the PATH for PostgreSQL installation.
Set the PATH for PostgreSQL bin folder.
Open the command prompt and set the following variables based on the existing configuration.
SET PGPORT=54327
SET PGDATA=%ZENSERVER_HOME%\database\pgsql\data
SET PGUSER=<super user retrieved from zman dgcs>
SET PGDATABASE=postgres
SET PGPASSWORD=<password retrieved from zman dgcs>;
Example 5-2 Example for Linux Primary Server:
Open the terminal and set the following variables based on the existing configuration.
export LD_LIBRARY_PATH=/opt/microfocus/zenworks/share/pgsql/lib;
export PATH=$PATH:/opt/microfocus/zenworks/share/pgsql/bin;
On SLES 15: export LD_LIBRARY_PATH=/opt/microfocus/zenworks/share/pgsql/lib:/opt/microfocus/zenworks/share/pgsql/stackbuilder/lib; export LD_LIBRARY_PATH
On SLES 15, the no version information available error message can be ignored.
export PGPORT=54327;
export PGDATA=/var/opt/microfocus/pgsql/data;
export PGUSER=<super user retrieved from zman dgcs>;
export PGDATABASE=postgres;
export PGPASSWORD=<password retrieved from zman dgcs>;
Run the following commands to back up both the databases (ZENworks and Audit):
On Windows:
cd "%ZENSERVER_HOME%\share\postgres\bin\"
pg_dumpall.exe > "<path to sql file>"
Example: pg_dumpall.exe > c:\postgres_dump.sql
On Linux:
cd /opt/microfocus/zenworks/share/pgsql/bin/
./pg_dumpall > "<path to sql file>"
Example: ./pg_dumpall > /tmp/postgres_dump.sql
docker exec -e PGUSER=<super user retrieved from zman dgcs> -e PGDATABASE=postgres -e PGPASSWORD=<password retrieved from zman dgcs> zenpostgres pg_dumpall > /tmp/dump.sql
Example: docker exec -e PGUSER=zenpostgres -e PGDATABASE=postgres -e PGPASSWORD=Zw0#43cf4525d0f5df6395bbbec9c zenpostgres pg_dumpall > /tmp/dump.sql
NOTE:You can ignore the no version information available error message.
On the Primary Server on which the Embedded Database is installed (source database), Stop the Micro Focus ZENworks Embedded Datastore service using the following steps:
On Windows: Press the Win + R keys on the keyboard to open the Run window. Type services. msc and then hit Enter.
Stop the Micro Focus ZENworks Embedded Datastore – PostgreSQL service.
On Linux: Run the following command to start the Micro Focus ZENworks Embedded Datastore – PostgreSQL service.
On SLES 12: systemctl stop zenpostgresql.service
On other SLES versions: /etc/init.d/zenpostgresql stop
Perform the following steps on an external server on which you want to move the PostgreSQL database. After installing PostgreSQL on an external server, ensure that the PostgreSQL database service is running.
To restore the database on an external database server, perform the following steps:
Set the following environment variables:
PGPORT: <target DB port>
PGUSER: <target super user for postgres DB>
PGDATABASE: <target initial connection database name> default is postgres
PGPASSWORD: <password for the above super user i.e. PGUSER>
Example 5-3 Example for Windows Primary Server
Set the following environment variables:
Set the path for PostgreSQL installation.
Set the path for PostgreSQL bin folder.
Open the command prompt and set the following variables based on the existing configuration.
SET PGPORT=54327
SET PGUSER=<PostgreSQL super user>
SET PGDATABASE=postgres
SET PGPASSWORD=<Postgres super user password>
Example 5-4 Example for Linux Primary Server:
Open the terminal and set the following variables based on the existing configuration.
export LD_LIBRARY_PATH=<postgres installation path>/lib;
export PATH=$PATH:<postgres installation path>/bin;
export PGPORT=<Port on which PostgreSQL is configured>;
export PGUSER=<Postgres super user>;
export PGDATABASE=postgres;
export PGPASSWORD=<PostgreSQL super user password>;
Login as PostgreSQL super user and manually 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';
Copy the postgres_dump.sql file that was created in Step 1: Backup the Database on the Embedded Primary Server to the target device.
Restore the database from the backup taken in Step 1: Backup the Database on the Embedded Primary Server, by running the following commands:
On Windows: In the Command prompt, run the following commands:
cd <postgres installation path>\bin
psql.exe -v ON_ERROR_STOP=0 -f c:\postgres_dump.sql -o c:\postgres_dump_log.txt -L c:\postgres_dump_log.log > c:\postgres_dump_log.err 2>&1
On Linux: In the Terminal, run the following commands as PostgreSQL user:
cd <postgres installation path>/bin
./psql -v ON_ERROR_STOP=0 -f /tmp/postgres_dump.sql -o /tmp/postgres_dump _log.txt -L /tmp/postgres_dump_log.log > /tmp/postgres_dump_log.err 2>&1
docker exec -e PGUSER=<super user retrieved from zman dgcs> -e PGDATABASE=postgres -e PGPASSWORD=<password retrieved from zman dgcs> zenpostgres pg_dumpall > /tmp/dump.sql
Example: docker exec -e PGUSER=zenpostgres -e PGDATABASE=postgres -e PGPASSWORD=Zw0#43cf4525d0f5df6395bbbec9c zenpostgres pg_dumpall > /tmp/dump.sql
NOTE:You can ignore the no version information available error message.
After Restoring the database, log into the ZENworks database, and run the below query to delete the database role for the device that has the embedded PostgreSQL database installed by running the following query on the external database server:
delete from zZenServerRoles where Roles = 'Database';
commit;
Update the following changes in zdm.xml and zenaudit.xml for all the Primary Servers in the zone:
Delete the <entry key="Embedded">true</entry>.
Update the value of the Port key with the port on which the external PostgreSQL database is configured.
<entry key="Port"><PORT-of-target-DB-device></entry>
Update the server key value in the zdm.xml and zenaudit.xml files as shown below:
In the target database server, add the loopback IP address.
<entry key="Server"><target_database_server-IP></entry>
In all the other Primary Server, add the IP of the target database server.
<entry key="Server"><target_database_server-IP></entry>
In the new database server, run the following configure actions: microfocus-zenworks-configure -c GenerateOSPProperties
Run microfocus-zenworks-configure -c GenerateContentDatasourceConfigureAction on all the content servers.
After updating the changes, restart all the ZENworks services by running the microfocus-zenworks-configure -c Start configure action.
Ensure that the Micro Focus ZENworks Embedded Datastore service is disabled and not running on the Primary Server that hosted the Embedded PostgreSQL database.
The ZENworks Server now points to new database.
Ensure that you can successfully log into ZCC. After logging into ZCC, go to the Diagnostics page and in the ZENworks Databases panel, verify the Host IP addresses and also verify that the Audit database is connected.