Skip to content

Plain SQL restore is reported successful despite PostgreSQL errors #550

Description

@jlengelsen

Environment

  • Databasement: 1.7.3
  • PostgreSQL
  • Dump format: Plain
  • Backup ownership information: Disabled
  • Backup privilege information: Disabled

Steps to reproduce

  1. Configure a PostgreSQL database server in Databasement using a non-owner role, databasement.
  2. Grant the documented database, schema, table, and default privileges.
  3. Use a source database whose tables and public schema are owned by another role, such as admin.
  4. Create a backup using plain dump format.
  5. Modify data in the source database.
  6. Restore the snapshot back into the same database with database recreation disabled.
  7. Check the restore task status and the restored data.

Expected behavior

The restore should fail when PostgreSQL rejects cleanup or restore statements. The task should report failure and propagate the psql exit status.

Actual behavior

Databasement reports the restore as completed, although the SQL restore contains errors and the original data remains unchanged. psql continues after the errors and the restore is treated as successful.

Example output:

ERROR: must be owner of table restore_probe
ERROR: must be owner of schema public
ERROR: relation "restore_probe" already exists
ERROR: duplicate key value violates unique constraint "restore_probe_pkey"

Additional context

A restore into an empty, pre-created database succeeds. The failure occurs when restoring in place because GRANT ALL PRIVILEGES does not grant ownership of existing tables or schemas.

The plain SQL restore should invoke psql with error stopping enabled, for example:

psql -v ON_ERROR_STOP=1 ...

The restore task should then propagate the non-zero exit status and report the operation as failed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions