defaang icon indicating copy to clipboard operation
defaang copied to clipboard

[DX] Figure out how to make a local backup

Open ykdojo opened this issue 2 years ago • 9 comments

Description

Now that we have more questions in our production database (ref: #232), we should figure out how to make a local backup.

Current plan: follow this.

ykdojo avatar Oct 02 '22 18:10 ykdojo

Hey @ykdojo Can you assign me this issue under Hacktoberfest 2022 label? I would love to contribute in this issue

aakashraj01 avatar Oct 02 '22 18:10 aakashraj01

Update:

I tried the methods described in the blog post, but it didn't quite work - I got a connection error.

I used pgAdmin and it seems like I was able to get a backup, but I had trouble restoring the production/dev databases from the backups, too.

ykdojo avatar Oct 03 '22 17:10 ykdojo

Update:

I tried the methods described in the blog post, but it didn't quite work - I got a connection error.

I used pgAdmin and it seems like I was able to get a backup, but I had trouble restoring the production/dev databases from the backups, too.

I also tried but error is coming always.

aakashraj01 avatar Oct 04 '22 10:10 aakashraj01

Hey @ykdojo I managed to make this work on my copy of defaang db in Supa bootstraped with supabase.sql file.

Instead of using the connection string (which errors because it needs a tls certificate, it could still be done), I used the pooling connection string, which is below the connection string in the settings panel. Pooling must be enabled.

poolingconnstring

Worth noting I run pg_dump in a Postgres docker container, much easier to setup than installing Postgres locally.

CerealPlayer avatar Oct 08 '22 05:10 CerealPlayer

@CerealPlayer sounds good. Were you able to restore a DB from that?

ykdojo avatar Oct 11 '22 15:10 ykdojo

Yes! it generated a dump.sql with all the info I had stored in my copy of defaang.

CerealPlayer avatar Oct 11 '22 16:10 CerealPlayer

How did you upload it back to Supabase? That was another part I had trouble with.

ykdojo avatar Oct 11 '22 16:10 ykdojo

This helps. The best approach would be to pg_dump certain tables that we know are critical and then pg_restore only those, since a full pg_dump would backup all schemas, and supabase doesn't support creating an empty database yet.

CerealPlayer avatar Oct 11 '22 17:10 CerealPlayer

The best approach would be to pg_dump certain tables that we know are critical and then pg_restore only those, since a full pg_dump would backup all schemas, and supabase doesn't support creating an empty database yet.

Got it. Backing up a database and restoring it seems like a pretty basic feature to have, though (I remember I had it in Heroku when I was using it).

ykdojo avatar Oct 12 '22 16:10 ykdojo