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 Windows Primary Server:
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>
cd "%ZENSERVER_HOME%\share\postgres\bin\"
On the Linux server:
Switch the user to zenpostgres by running the command su zenpostgres
Open the terminal and set the following variables based on the existing configuration.
export LD_LIBRARY_PATH=//opt/novell/zenworks/share/pgsql/lib:$LD_LIBRARY_PATH
export PATH=$PATH:opt/novell/zenworks/share/pgsql/bin;
export PGPORT=54327;
export PGUSER=<Postgres super user retrieved from zman dgcs of the target database device>;
export PGDATABASE=postgres;
export PGPASSWORD=<password retrieved from zman dgcs of the target database device>;
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.
Set the following variables again:
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 8-3 Example for Windows Primary Server
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 of the source database device>
SET PGDATABASE=postgres
SET PGPASSWORD=<password retrieved from zman dgcs of the source database device>;
Example 8-4 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$LD_LIBRARY_PATH;
export PATH=$PATH:/opt/microfocus/zenworks/share/pgsql/bin;
export PGPORT=54327;
export PGDATA=/var/opt/microfocus/pgsql/data;
export PGUSER=<super user retrieved from zman dgcs of the source database device>;
export PGDATABASE=postgres;
export PGPASSWORD=<password retrieved from zman dgcs of the source database device>;
Restore the database by running the following commands:
On Windows: In the Command prompt, run the following commands:
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
-f <filename>: Uses the filename as the source of SQL commands
-l <filename>: Writes all query output into the file, in addition to the normal output destination
-o <filename>: Logs all query output into the file
All the errors will be redirected to <error_log_location>.
psql.exe -v ON_ERROR_STOP=0 -f c:\tmp\postgres_dump.sql -o c:\tmp\postgres_log.txt -L c:\tmp\postgres_log.log >c:\postgres\postgres_log.err 2>&1
On Linux: