Skip to content

Conversation

@leonardocouy
Copy link

@leonardocouy leonardocouy commented Dec 10, 2025

Summary

Add an optional "Schemas" field to PostgreSQL database settings, allowing users to specify which schemas to include in backups and restores using a comma-separated list.

Motivation

When backing up managed PostgreSQL databases or databases with restricted internal schemas, the backup user may not have access to all schemas. This causes pg_dump to fail with permission errors like:

pg_dump: error: permission denied for schema internal_schema

By filtering backups to only include specific schemas (e.g., public), users can successfully backup their databases without permission errors.

My use case was to back up only the public and drizzle schemas from the Supabase DB, because this one doesn't allow backing up other internal schemas.

Changes

Backend

  • Migration: Add schemas column to postgresql_databases table
  • Model: Add Schemas field to PostgresqlDatabase struct
  • Backup: Modify buildPgDumpArgs() to append --schema flags
  • Restore: Modify pg_restore args to support --schema filtering

Frontend

  • Add "Schemas" input field with tooltip in database edit form
  • Display schemas in read-only database view
  • Increase restore modal width to accommodate new field

Usage

Setting the Schemas field to public,custom_schema generates:

# Backup
pg_dump ... --schema public --schema custom_schema

# Restore
pg_restore ... --schema public --schema custom_schema

Leave the field empty for full database backup/restore (default behavior).

Screenshots

Schema field with tooltip when configuring backup

image

Schema field with tooltip in restore modal

image

Testing

  • Tested backup with schema filtering
  • Tested restore with schema filtering
  • Frontend builds without errors
  • Backend builds without errors

How to Test

If you'd like to test this feature, a pre-built Docker image is available:

docker pull leoflores/postgresus:latest

Then run it with your preferred configuration or build locally or replace the image in your existing Postgresus deployment.

Add optional "Schemas" field to PostgreSQL database settings allowing
users to specify which schemas to include in backups (comma-separated).

This solves permission issues when backing up some of databases that
have restricted internal schemas (auth, storage, realtime).

Changes:
- Add schemas column to postgresql_databases table (migration)
- Update PostgresqlDatabase model with Schemas field
- Modify buildPgDumpArgs() to append --schema flags for each schema
- Modify pg_restore args to support --schema filtering on restore
- Add Schemas input field to frontend edit form with tooltip
- Display schemas in read-only database view

Example usage: Setting schemas to "public,drizzle" generates:
  pg_dump ... --schema public --schema drizzle
  pg_restore ... --schema public --schema drizzle
@RostislavDugin RostislavDugin changed the base branch from main to develop December 10, 2025 10:17
@RostislavDugin RostislavDugin merged commit 5944d7c into RostislavDugin:develop Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants