Highlighted
Super Contributor.
Super Contributor.
385 views

using zman restore embedded PostgreSQL

ZCMVersion Old/New Server are same 2020 update1

ZoneName

Sceanrio:

1. I had backup

(1)internal CA

(2)zenserver backup file

(3)postgres 3 account password by zman dgca/dgc/dgcs

(4) backup content-repo

(5 )backup postgreSQL to a folder by using zman

 

But I  try to restore ... I confused restore embedded postgreSQL by using zman....I read "Restoring the Database Backup Taken Using the ZMAN
Command" section in zen_sys_db_mgmt.pdf, I am not famaliar postgreSQL or SQL export, 

Who had tested step3-8 ??

 

Thanks!!

 

Wencheng

Labels (1)
Tags (1)
0 Likes
18 Replies
Highlighted
Knowledge Partner
Knowledge Partner

Re: using zman restore embedded PostgreSQL

On upgraded systems the names of the zenworks and audit databases might differ from the defaults. You should check that first. There are different ways to do so, likely easiest will be to check the "Database Key" in

/etc/opt/novell/zenworks/datamodel/zdm.xml

and

/etc/opt/novell/zenworks/datamodel/zenaudit.xml

As for step 3: this has to be done in a "psql shell". You cannot drop a database which has active connections (i've read somewhere that a "force" option has been introduced in postgres 13, but you likely won't have this version). The problem is that some of the connections getting killed by the SQL statement might get reestablished before you can issue the drop command. So i think it's easier to stop ALL zenworks services except zenpostgresql.service and skip step 3.

In step 7 the username will likely be "zenpostgres", the database name will be the one you've grabbed from the corresponding xml file mentioned above.

In step 8 you'll have to specify a dbname. With the parameters used this should be "postgres". It references the name of a DB to initially connect to (to re-create the DB you've just dropped). Now, with the command line from the docs, you'll quickly see a few errors as the parameters try to drop the DB again which obviously will fail as you've already done this in step 7. You can safely ignore these errors. Your DB will get recreated and filled with data. Afterwards bounce the box.

 

0 Likes
Highlighted
Respected Contributor.
Respected Contributor.

Re: using zman restore embedded PostgreSQL

Hello

So I did step 3 to drop the zenworks database upon restoring it would not restore since there was no existing database ( it was obvious since i dropped it) i tried recreating but zenadmin has no permission to create databases and I don't know how to get the postgres user password.

Is there anyway to create a zenworks database or is dropping the database necessary?

Thanks,

Lyle

 

0 Likes
Highlighted
Knowledge Partner
Knowledge Partner

Re: using zman restore embedded PostgreSQL

These commands should run as "postgres superuser", i.e. with the account you get with "zman dgcs". The account will likely be "zenpostgres". The restore command would be something like

pg_restore --host=localhost --port=54327 --username=zenpostgres --format=directory --dbname=postgres -C -c <<full path to zenDB_pg_dump>>

Note that the name of the DB to be restored is taken from the backup itself, the "--dbname" parameter specifies an existing DB to connect to. So if you want to restore the "zenworks" DB you'd still have to pass

--dbname=postgres

 

0 Likes
Highlighted
Super Contributor.
Super Contributor.

Re: using zman restore embedded PostgreSQL

HI 

   I had checked both ZCM server (old / new install) setting...I indeed using same setting by check zdm.xml and zenaudit.xml

ZoneName: NewZCM

databasename : (1)ZCM Database: zenworks_newzcm (2)Audit Database:zen_audit_newzcm

 

About step-3...whether I need run some commands to let me type these SQLcommand (these SQL command is 3 lines or 1 line) ?

 

Wencheng

0 Likes
Highlighted
Respected Contributor.
Respected Contributor.

Re: using zman restore embedded PostgreSQL

How I did step 3:

was to go to the postgres directory (cause my zenworks is installed in a windows server)
using the terminal and ran the command :

psql -h localhost -p 54327 -U zenpostgres postgres

this would let you login to the postgres terminal


then ran the commands in step 3

0 Likes
Highlighted
Knowledge Partner
Knowledge Partner

Re: using zman restore embedded PostgreSQL

SET PGPASSWORD=<<pwd of zenpostgres>>
psql --host=localhost --port=54327 -U zenpostgres postgres

\l


That's a lowercase "Lima" after the backslash. It will list the existings databases. Grab the name of the DB you want to replace, which might be a plain "zenworks", but could also be something containing the zone's name on "adult" installations. For this example let's go on with "zenworks".


SELECT * FROM pg_stat_activity WHERE datname = 'zenworks';


This should list any open connections from the DB's point of view.


Clear them with


SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'zenworks';

That's all in one line. To exit the "psql shell" type

\q

 

Highlighted
Respected Contributor.
Respected Contributor.

Re: using zman restore embedded PostgreSQL

Hello @mathiasbraun 

yeah using the database postgres seems to work it shows no error when I ran the pg_restore command.

after restoring the configuration and database I still could not access the ZCC still on error 404?

do I need to restore my repo-content and certificate also?

when i ran zac zeninfo I get an error on the application that the zenadmin password is mismatched

****EDIT*****

oh and is there a way to check if the database restoration is successful?

- figured out theres a verbose option so I see no error when restoring the database backup as it drops and creates the needed database

Thanks,

Lyle

0 Likes
Highlighted
Super Contributor.
Super Contributor.

Re: using zman restore embedded PostgreSQL

About content-repo folder...

Yes...After restore all setting (CA/ZCM Server and DB)...you could copy the content-repo folder from older server to new server...the folder include all files the you deliver to ZCM managed devices

Highlighted
Respected Contributor.
Respected Contributor.

Re: using zman restore embedded PostgreSQL

Thank you, i just have to access my ZCM though I still cant since it still displays an error 404

0 Likes
Highlighted
Knowledge Partner
Knowledge Partner

Re: using zman restore embedded PostgreSQL

The main question is:

What are you trying to accomplish?

Do you just want to replace a given DB with a backup on the same box the backup was taken on?

Or are you performing a disaster recovery?

 

0 Likes
Highlighted
Respected Contributor.
Respected Contributor.

Re: using zman restore embedded PostgreSQL

I'm performing a disaster recovery I have my old zenworks 2020 server and restoring it all on a newly installed zenworks 2020 server both on windows server 2012 R2

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.