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 backup and restore with pg_dumpall #38

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

Conversation

eduardoteles17
Copy link

Hello, This project has helped me a lot!

In my environments I need to back up more than one database. But there is no possibility to use pg_dumpall so I decided to implement it.

I added a new variable BACKUP_ALL to switch between pg_dump and pg_dumpall. I also made the variable POSTGRES_DATABASE optional if BACKUP_ALL is true. And I added the option to restore the backup containing all banks

Thank you very much for this project and I hope this PR can help to improve even more

@eeshugerman
Copy link
Owner

Thanks for the PR! I hope to take a closer look and test later this week.

One minor reservation I have is that, best I can tell, pg_dumpall does not compress the archive? Can you confirm, and/or do you see a way to enable compression? We use -F custom with pg_dump, which is compressed, and still people ask about adding gzip, so I'm sure it will come up soon with pg_dumpall.

@eduardoteles17
Copy link
Author

As you pointed out, pg_dumpall still doesn't have the compression function built in, but I can implement it using gzip as a way around the lack of that function for now

@eeshugerman
Copy link
Owner

OK, great, please do!

@eeshugerman eeshugerman linked an issue Aug 29, 2023 that may be closed by this pull request
@eduardoteles17
Copy link
Author

Done, I added compression using gzip

@eeshugerman
Copy link
Owner

Done, I added compression using gzip

Thank you! I do intend to merge this, but I'm afraid it might be a bit (a few weeks perhaps) before I get to it. There are many combos of options to test, especially now with BACKUP_ALL -- I really need to look into automating that. Also I'm a little concerned about how messy/complicated the filename/tempfile handling is becoming (not your fault!), so I may experiment with mktemp or something to see if that can be cleaned up. Anyway, thanks for your patience and thanks again for the PR!

@sitole
Copy link

sitole commented Oct 8, 2023

Wow, iam doing apps with database-per-tenant and this is what I am missing!

Btw Iam already user of this tool

@schonert
Copy link

schonert commented Jan 9, 2024

@eeshugerman anything we can do to help push this forward?

-p $POSTGRES_PORT \
-U $POSTGRES_USER \
$PGDUMP_EXTRA_OPTS \
> db.dump

Choose a reason for hiding this comment

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

Maybe we want to pipe directly to gzip here?
| gzip > db.dump.gz

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.

Support for backing up all databases
5 participants