Skip to content

[v1.0.0b] - Postgresql backup restore fails when not user postgres superuser #1500

@wipash

Description

@wipash

First Check

  • This is not a feature request
  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Mealie documentation, with the integrated search.
  • I already read the docs and didn't find an answer.

What is the issue you are experiencing?

Postgresql version: 14.4
Mealie version: 1.0.0beta-3

When restoring a backup using the builtin backup restore functionality, the backup fails if Mealie is configured to use a user other than the postgres superuser.

The cause seems to be in the drop_all() function of alchemy_exporter.py. Postgres doesn't allow SET session_replication_role = 'replica' if you are not a superuser.

Log from postgres server:

2022-07-22 04:42:24.951 GMT [424] ERROR:  permission denied to set parameter "session_replication_role"
2022-07-22 04:42:24.951 GMT [424] STATEMENT:  SET session_replication_role = 'replica'
2022-07-22 04:42:24.952 GMT [424] ERROR:  current transaction is aborted, commands ignored until end of transaction block
2022-07-22 04:42:24.952 GMT [424] STATEMENT:  SET session_replication_role = 'origin'

Mealie is deployed with these environment variables:

        TZ: Pacific/Auckland
        TOKEN_TIME: 43830
        DB_ENGINE: postgres
        POSTGRES_USER: mealie
        POSTGRES_PASSWORD: longandcomplexpassword
        POSTGRES_SERVER: my.postgres.server
        POSTGRES_PORT: 5432
        POSTGRES_DB: mealie
        BASE_URL: https://mealie.myhouse.com

If I set mealie to use the postgres superuser account, the restore works as expected.

Deployment

Docker (Linux)

Deployment Details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions