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

Allow replication in pg_hba for pg_basebackup #751

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

cmantsch
Copy link

What kind of change does this PR introduce?

Add an entry in pg_hba.conf to allow replication connections. This allows fast andeasy backups using pg_basebackup (pg_basebackup -D /tmp/mybasebackup -U postgres -h 127.0.0.1)

What is the current behavior?

Trying to create backups with pg_basebackup fails due to the lack of permissions for replication ("all" does not match replication, as the comment in pg_hba.conf states)

What is the new behavior?

Backups using pg_basebackup can be created without authentication inside the container and with password authentication outside the container

Additional context

Creating backups with a classic dump can be challenging with all the features supabase uses in Postgres. Basebackups copy the whole data directory of the Postgres instance and can easily (and fast!) be restored by copying it back.

@cmantsch cmantsch requested a review from a team as a code owner October 10, 2023 12:35
@darora
Copy link
Contributor

darora commented Oct 13, 2023

@cmantsch is this for use with a self-hosted setup? We'll likely want to provide a mechanism to easily supply your own pg_hba file, I think..

Note that you can always use the CLI to take a dump https://supabase.com/docs/guides/platform/migrating-and-upgrading-projects#backup-your-old-database

@cmantsch
Copy link
Author

Yes, this is for self-hosted.

Supabase CLI DB dumps don't work really well for me as it seems to miss some things that was custom added to the db besides supabase. That resulted in broken supabase installations. Basebackup is rock-solid for me and also way faster than taking a normal dump. Restoring a 1GB db takes less than 30 seconds and that even includes stopping and starting the docker stack.

@darora
Copy link
Contributor

darora commented Oct 19, 2023

Yeah I think we'll want to solve for this by allowing custom pg_hba files for self-hosted setups, rather than including this in the default. fyi @sweatybridge

Supabase CLI DB dumps don't work really well for me as it seems to miss some things that was custom added to the db besides supabase.

Could you elaborate on the sort of custom things that are being missed? Are there any github issues discussing this problem?

@NiklasPor
Copy link

Hey, yes this would be super helpful. We're also using pg_basebackup for more efficient backups and this was a small pain to setup.

What we did was we just overwrote the base file, by mounting our own configuration on-top.

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.

None yet

3 participants