feat(postgresql): Add schema filter for pg_dump and pg_restore #131
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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_dumpto fail with permission errors like: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
schemascolumn topostgresql_databasestableSchemasfield toPostgresqlDatabasestructbuildPgDumpArgs()to append--schemaflagspg_restoreargs to support--schemafilteringFrontend
Usage
Setting the Schemas field to
public,custom_schemagenerates:Leave the field empty for full database backup/restore (default behavior).
Screenshots
Schema field with tooltip when configuring backup
Schema field with tooltip in restore modal
Testing
How to Test
If you'd like to test this feature, a pre-built Docker image is available:
Then run it with your preferred configuration or build locally or replace the image in your existing Postgresus deployment.