Thank you,
oVirt version is:  oVirt Node 4.2.5.1
I manage to fix it with as follow:
  1. engine-cleanup
  2. su - postgres
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/rh/rh-postgresql95/root/usr/lib64/
scl enable rh-postgresql95 -- psql
alter role engine superuser; #(I know it's not good, but I don't care)
\q
  1. restart the machine
  2.  engine-backup --mode=restore --file=backup --log=restore5.log  --restore-permissions   --provision-all-databases #
    1. it failed with the following error but the database was created,
    2. pg_restore: [archiver (db)] Error while PROCESSING TOC:
      pg_restore: [archiver (db)] Error from TOC entry 710; 1255 174984 FUNCTION uuid_generate_v1() engine
      pg_restore: [archiver (db)] could not execute query: ERROR:  function "uuid_generate_v1" already exists with same argument types
          Command was: CREATE FUNCTION uuid_generate_v1() RETURNS uuid
          LANGUAGE plpgsql STABLE
          AS '
      DECLARE
          v_val BIGINT;
          v_4_1_par...
      pg_restore: WARNING:  column "user_role_title" has type "unknown"
      DETAIL:  Proceeding with relation creation anyway.
      WARNING: errors ignored on restore: 1
      2019-01-02 04:28:22 28664: FATAL: Errors while restoring database engine
       
  3. engine-backup --mode=restore --file=backup --log=restore6.log  --scope=files --no-restore-permissions # (this was sucessed )
  4. restart machine
  5.  engine-setup (and replay y to fix the database)
this was a very long night, but ended with great success!!
hope it helps.






On Wed, Jan 2, 2019 at 9:38 AM Yedidyah Bar David <didi@redhat.com> wrote:
On Wed, Jan 2, 2019 at 3:45 AM maoz zadok <maozza@gmail.com> wrote:
>
> I really need help here... please!!
> my engine was crashed, I have backups, but the restore failed.
>
> engine-backup --mode=restore --file=backup --log=restore.log --provision-all-databases --restore-permissions
>
> this is the log:
> 2019-01-02 03:39:22 13186: Start of engine-backup mode restore scope all file backup
> 2019-01-02 03:39:22 13186: Setting scl env for rh-postgresql95
> 2019-01-02 03:39:22 13186: OUTPUT: Preparing to restore:
> 2019-01-02 03:39:22 13186: OUTPUT: - Unpacking file 'backup'
> 2019-01-02 03:39:22 13186: Opening tarball backup to /tmp/engine-backup.bGOLRNXeD4
> 2019-01-02 03:39:22 13186: Verifying md5
> 2019-01-02 03:39:22 13186: Verifying version
> 2019-01-02 03:39:22 13186: Reading config
> 2019-01-02 03:39:22 13186: OUTPUT: Restoring:
> 2019-01-02 03:39:22 13186: OUTPUT: - Files
> 2019-01-02 03:39:22 13186: Restoring files
> 2019-01-02 03:39:22 13186: Reloading configuration
> 2019-01-02 03:39:22 13186: OUTPUT: Provisioning PostgreSQL users/databases:
> 2019-01-02 03:39:22 13186: provisionDB: user engine host localhost port 5432 database engine secured False secured_host_validation False
> 2019-01-02 03:39:22 13186: OUTPUT: - user 'engine', database 'engine'
> [ INFO  ] Stage: Initializing
> [ INFO  ] Stage: Environment setup
>           Configuration files: ['/etc/ovirt-engine-setup.conf.d/10-packaging-jboss.conf', '/etc/ovirt-engine-setup.conf.d/10-packaging.conf', '/etc/ovirt-engine-setup.conf.d/20-setup-ovirt-post.conf', '/tmp/engine-backup.bGOLRNXeD4/pg-provision-answer-file']
>           Log file: /var/log/ovirt-engine/setup/ovirt-engine-provisiondb-20190102033923-c7vy1o.log
>           Version: otopi-1.7.8 (otopi-1.7.8-1.el7)
> [ INFO  ] Stage: Environment packages setup
> [ INFO  ] Stage: Programs detection
> [ INFO  ] Stage: Environment customization
> [ INFO  ] Stage: Setup validation
> [WARNING] Cannot validate host name settings, reason: resolved host does not match any of the local addresses
> [ INFO  ] Stage: Transaction setup
> [ INFO  ] Stage: Misc configuration
> [ INFO  ] Stage: Package installation
> [ INFO  ] Stage: Misc configuration
> [ INFO  ] Creating PostgreSQL 'engine' database
> [ INFO  ] Configuring PostgreSQL
> [ INFO  ] Stage: Transaction commit
> [ INFO  ] Stage: Closing up
> [ INFO  ] Stage: Clean up
>           Log file is located at /var/log/ovirt-engine/setup/ovirt-engine-provisiondb-20190102033923-c7vy1o.log
> [ INFO  ] Stage: Pre-termination
> [ INFO  ] Stage: Termination
> [ INFO  ] Execution of provisiondb completed successfully
> 2019-01-02 03:39:28 13186: provisionDB: user ovirt_engine_history host localhost port 5432 database ovirt_engine_history secured False secured_host_validation False
> 2019-01-02 03:39:28 13186: OUTPUT: - user 'ovirt_engine_history', database 'ovirt_engine_history'
> [ INFO  ] Stage: Initializing
> [ INFO  ] Stage: Environment setup
>           Configuration files: ['/etc/ovirt-engine-setup.conf.d/10-packaging-jboss.conf', '/etc/ovirt-engine-setup.conf.d/10-packaging.conf', '/etc/ovirt-engine-setup.conf.d/20-setup-ovirt-post.conf', '/tmp/engine-backup.bGOLRNXeD4/pg-provision-answer-file']
>           Log file: /var/log/ovirt-engine/setup/ovirt-engine-provisiondb-20190102033928-nit1oc.log
>           Version: otopi-1.7.8 (otopi-1.7.8-1.el7)
> [ INFO  ] Stage: Environment packages setup
> [ INFO  ] Stage: Programs detection
> [ INFO  ] Stage: Environment customization
> [ INFO  ] Stage: Setup validation
> [WARNING] Cannot validate host name settings, reason: resolved host does not match any of the local addresses
> [ INFO  ] Stage: Transaction setup
> [ INFO  ] Stage: Misc configuration
> [ INFO  ] Stage: Package installation
> [ INFO  ] Stage: Misc configuration
> [ INFO  ] Creating PostgreSQL 'ovirt_engine_history' database
> [ INFO  ] Configuring PostgreSQL
> [ INFO  ] Stage: Transaction commit
> [ INFO  ] Stage: Closing up
> [ INFO  ] Stage: Clean up
>           Log file is located at /var/log/ovirt-engine/setup/ovirt-engine-provisiondb-20190102033928-nit1oc.log
> [ INFO  ] Stage: Pre-termination
> [ INFO  ] Stage: Termination
> [ INFO  ] Execution of provisiondb completed successfully
> 2019-01-02 03:39:34 13186: OUTPUT: Restoring:
> 2019-01-02 03:39:34 13186: Generating pgpass
> 2019-01-02 03:39:34 13186: Verifying connection
> 2019-01-02 03:39:34 13186: pg_cmd running: psql -w -U engine -h localhost -p 5432  engine -c select 1
>  ?column?
> ----------
>         1
> (1 row)
>
> 2019-01-02 03:39:34 13186: pg_cmd running: psql -w -U engine -h localhost -p 5432  engine -t -c show lc_messages
> 2019-01-02 03:39:34 13186: pg_cmd running: pg_dump -w -U engine -h localhost -p 5432  engine -s
> 2019-01-02 03:39:34 13186: pg_cmd running: psql -w -U ovirt_engine_history -h localhost -p 5432  ovirt_engine_history -c select 1
>  ?column?
> ----------
>         1
> (1 row)
>
> 2019-01-02 03:39:34 13186: pg_cmd running: psql -w -U ovirt_engine_history -h localhost -p 5432  ovirt_engine_history -t -c show lc_messages
> 2019-01-02 03:39:34 13186: pg_cmd running: pg_dump -w -U ovirt_engine_history -h localhost -p 5432  ovirt_engine_history -s
> 2019-01-02 03:39:34 13186: OUTPUT: - Engine database 'engine'
> 2019-01-02 03:39:34 13186: Restoring engine database backup at /tmp/engine-backup.bGOLRNXeD4/db/engine_backup.db
> 2019-01-02 03:39:34 13186: restoreDB: backupfile /tmp/engine-backup.bGOLRNXeD4/db/engine_backup.db user engine host localhost port 5432 database engine orig_user  compressor  format custom jobsnum 2
> 2019-01-02 03:39:34 13186: pg_cmd running: pg_restore -w -U engine -h localhost -p 5432 -d engine -j 2 /tmp/engine-backup.bGOLRNXeD4/db/engine_backup.db
> pg_restore: [archiver (db)] Error while PROCESSING TOC:
> pg_restore: [archiver (db)] Error from TOC entry 7410; 0 0 COMMENT EXTENSION plpgsql
> pg_restore: [archiver (db)] could not execute query: ERROR:  must be owner of extension plpgsql
>     Command was: COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
>
>
>
> pg_restore: [archiver (db)] Error from TOC entry 710; 1255 174984 FUNCTION uuid_generate_v1() engine
> pg_restore: [archiver (db)] could not execute query: ERROR:  function "uuid_generate_v1" already exists with same argument types
>     Command was: CREATE FUNCTION uuid_generate_v1() RETURNS uuid
>     LANGUAGE plpgsql STABLE
>     AS '
> DECLARE
>     v_val BIGINT;
>     v_4_1_par...
> pg_restore: [archiver (db)] could not execute query: ERROR:  must be owner of function uuid_generate_v1
>     Command was: ALTER FUNCTION public.uuid_generate_v1() OWNER TO engine;
>
>
> pg_restore: WARNING:  column "user_role_title" has type "unknown"
> DETAIL:  Proceeding with relation creation anyway.
> pg_restore: WARNING:  no privileges could be revoked for "public"
> pg_restore: WARNING:  no privileges could be revoked for "public"
> pg_restore: WARNING:  no privileges were granted for "public"
> pg_restore: WARNING:  no privileges were granted for "public"
> WARNING: errors ignored on restore: 3
> 2019-01-02 03:39:38 13186: FATAL: Errors while restoring database engine
>
>
> On Wed, Jan 2, 2019 at 1:37 AM maoz zadok <maozza@gmail.com> wrote:
>>
>> please someone, any ideas?
>>
>>
>> engine-backup --mode=restore --file=backup --log=log_file_name --provision-db --restore-permissions
>> Preparing to restore:
>> - Unpacking file 'backup'
>> Restoring:
>> - Files
>> Provisioning PostgreSQL users/databases:
>> - user 'engine', database 'engine'
>> FATAL: Existing database 'engine' or user 'engine' found and temporary ones created - Please clean up everything and try again

Hi Maoz,

"clean up everything" means one of:

1. Reinstall the machine from scratch. This might be the best idea, depending on
how much effort it will take, how much dirt it accumulated, etc.

2. Just clean up the PG database. You didn't write which version you use.

In <= 4.1, we use the OS's default postgresql. Meaning: the service is
called postgresql.service, and the data directory is /var/lib/pgsql/data .

In 4.2, we use SCL PG 9.5. Service name is rh-postgresql95-postgresql.service ,
data directory is /var/opt/rh/rh-postgresql95/lib/pgsql/data .

Above is for el7. In Fedora we always use the OS's default PG.

To clean it up, you should stop the PG service and remove the data directory.
Then try again to restore.

Good luck and best regards,
--
Didi