Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to specify custom schema to back-up in postgres #139

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

esune
Copy link
Member

@esune esune commented Dec 19, 2024

Added the ability to specify a custom schema name for backups in postgres when using the configuration file spec.
Following the convention used for JDBC, the schema can be specified by adding ?currentSchema=my_schema to the database spec.

This was developed as a set of postgres-specific overrides since other supported database providers do not have the concept of schema and it was simpler to customize one instance of the function to grab the database name from the connection spec rather than handling the different scenarios in the same function, but it can be refactored if necessary.

One thing this pattern could also be used for in the future is to specify the auth database for mongodb in the spec rather than using an environment variable like it is currently set-up to do.

Opening in draft mode while testing.

@esune esune requested review from i5okie and WadeBarnes December 19, 2024 22:45
Copy link
Member

@WadeBarnes WadeBarnes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good so far. A few comments and recommendations ...

The TABLE_SCHEMA variable has been used to this point to define the schema for verification. It's used by backup.mariadb.plugin and backup.postgres.plugin. The downside - It's global, hance this PR.

I think the TABLE_SCHEMA variable should be deprecated in favor of this new approach, where the new approach would contextually override the value in TABLE_SCHEMA.

Being able to backup a specific schema is an interesting addition, but I'm not sure it should be the default. The way it has worked up to now is the backup is a full backup, and then the verification verifies the schema of interest. This way when you restore the database, you're restoring a snapshot of everything, not just a single schema.

I also see that the new schema configuration setting is not being used for verification, the verification process is still only using the TABLE_SCHEMA variable.

docker/backup.postgres.plugin Outdated Show resolved Hide resolved
@esune
Copy link
Member Author

esune commented Dec 21, 2024

Implementation was updated to support backupSchema and verifySchema parameters:

  • if backupSchema is specified, only the matching schema will be backed-up, otherwise the default mode will be used to backup everything
  • if verifySchema is specified, the specified schema name will be used for verification. Code falls-back to use TABLE_SCHEMA if nothing is specified, which in turn falls back to verifying public if unset

Pondering whether to use backupSchema/verifySchema or just backup/verify as parameters: the first naming convention is explicit, but might be redundant given what the code is for?

More testing currently underway.

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