Bug 960760

Summary: Unable to restore from 3.1 LogCollector DB backup file
Product: Red Hat Enterprise Virtualization Manager Reporter: Eli Mesika <emesika>
Component: ovirt-engineAssignee: Eli Mesika <emesika>
Status: CLOSED CURRENTRELEASE QA Contact: Dušan Kajan <dkajan>
Severity: unspecified Docs Contact:
Priority: urgent    
Version: 3.2.0CC: acathrow, bazulay, cpelland, iheim, jkt, lpeer, pstehlik, Rhev-m-bugs, yeylon, yzaslavs
Target Milestone: ---Keywords: ZStream
Target Release: 3.3.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: infra
Fixed In Version: is7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 973275 (view as bug list) Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 976337    
Bug Blocks: 973275    
Attachments:
Description Flags
Restore output none

Description Eli Mesika 2013-05-07 21:33:27 UTC
Description of problem:
Unable to restore from 3.1 LogCollector DB backup file

backup files created with LogCollector on 3.1 will fail to restore.
This is due to the fact that LogCollector is using PG pg_dump utility with the TAR format in order to backup the database.
Unfortunately, there is a bug (Tom Lane claims that this is a feature,) that in case that TAR format is used the -c flag of pg_dump is not honoured and will create always DROP statements for all database objects in the generated restore.sql script.
(See 
http://www.postgresql.org/message-id/E1TrqX7-0002qd-4e@wrigleys.postgresql.org)

The DROP statements caused DB errors when attempting to restore the backup by 
1) dropping existing DB
2) re creating a new blank db with teh same name
3) using pg_restore to restore database from the backup file

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.create a database backup from LogCollector on 3.1 or use and existing one or use pg_dump with -F t flag to generate this file
2.drop the database using dropdb
3.recreate the database using createdb
4.try to use pg_restore to restore the database from the file in 1)
  
Actual results:
Lots of errors on the DROP statements 

Expected results:

We should be able to restore the database from the LogCollector DB backup file

Additional info:

The only way to resolve that is to create a utility that will 

1) Open the backup TAR file to a directory D
2) Do sed operations on the restore.sql to remove unneeded statements 

After that, the database should be restored with:

psql -U engine -f <D>/restore.sql engine

where <D> is the directory to which the TAR was extracted in 1)

Comment 3 Ilanit Stein 2013-07-15 06:49:26 UTC
Verified on is5:

Comment 4 Ilanit Stein 2013-07-15 07:26:34 UTC
Created attachment 773571 [details]
Restore output

Comment 6 Ilanit Stein 2013-07-16 07:45:22 UTC
Checked on is5, 
Back to assign:
In case that engine is the only database installed, the language plpgsql is removed with the database, and not installed again, by the restore script. 
This fail the restore, and also require to run engine-cleanup\engine-setup in order to connect to the rhevm via GUI.

Comment 7 Eli Mesika 2013-07-23 19:38:38 UTC
fixed in commit: e5acad1

Comment 8 Dušan Kajan 2013-11-22 14:46:55 UTC
everything seems to be fine, use this steps:

[root@dk-rh33 ~]# service ovirt-engine stop
[root@dk-rh33 ~]# pg_dump -F t -U postgres engine >backup.tar
[root@dk-rh33 ~]# dropdb -U postgres engine
[root@dk-rh33 ~]# createdb -U postgres engine
[root@dk-rh33 ~]# pg_restore -d engine -U postgres backup.tar 
[root@dk-rh33 ~]# service ovirt-engine start
database was restored correctly, althoug it gave me this warnings :
pg_restore: WARNING:  column "storage_pool_id" has type "unknown"
DETAIL:  Proceeding with relation creation anyway.
pg_restore: WARNING:  column "storage_pool_name" has type "unknown"
DETAIL:  Proceeding with relation creation anyway.


setting as verified

Comment 9 Itamar Heim 2014-01-21 22:29:14 UTC
Closing - RHEV 3.3 Released

Comment 10 Itamar Heim 2014-01-21 22:29:18 UTC
Closing - RHEV 3.3 Released

Comment 11 Itamar Heim 2014-01-21 22:32:13 UTC
Closing - RHEV 3.3 Released