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

Export all databases from service #180

Open
chemicalkosek opened this issue May 9, 2019 · 6 comments
Open

Export all databases from service #180

chemicalkosek opened this issue May 9, 2019 · 6 comments

Comments

@chemicalkosek
Copy link

I have deployed a Prisma Server like this:
https://www.prisma.io/tutorials/deploy-prisma-to-dokku-ct15

I have named the dokku postgres service 'prismadb'.
The Prisma Server is working fine.
But I need to do backup of the service.

dokku postgres:export prismadb > prismadb.dump

gives me:

-- PostgreSQL database dump
--

-- Dumped from database version 11.2 (Debian 11.2-1.pgdg90+1)
-- Dumped by pg_dump version 11.2 (Debian 11.2-1.pgdg90+1)

SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;

--
-- PostgreSQL database dump complete
--

It's empty, but it should contain some data which I have added.
So after doing:
dokku postgres:connect prismadb
prismadb=# \l

I get:

                                 List of databases
   Name    |  Owner   | Encoding |  Collate   |   Ctype    |   Access privileges   
-----------+----------+----------+------------+------------+-----------------------
 postgres  | postgres | UTF8     | en_US.utf8 | en_US.utf8 | 
 prisma    | postgres | UTF8     | en_US.utf8 | en_US.utf8 | 
 prismadb  | postgres | UTF8     | en_US.utf8 | en_US.utf8 | 
 template0 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
(5 rows)

So after checking logs I see that Prisma during deploy is creating a 'prisma' database.
The data is there, I checked.
How can I export all databases from the service?
Seems like the
dokku postgres:export prismadb > prismadb.dump
is only exporting the database which is named like the service.

@josegonzalez
Copy link
Member

Currently, we only support a single database, so the existing functionality is expected.

The code for export is here, pull requests welcome!

@chemicalkosek
Copy link
Author

My Docker knowledge is too thin to help you with the pull request.
Could you somehow point me into direction how would I need to run pg_dumpall or maybe pg_dump against another database within dokku postgres service?

@josegonzalez
Copy link
Member

There isn't any docker knowledge necessary here. I'm quite literally just running the pg_dump command in that script (its a few lines down from the link I sent).

@afunnydev
Copy link

Maybe we could add another argument to specify the table to use in the export. That way, it would be more clear that the db is exporting only one table. Is there any contribution guidelines? Never done this before but I could probably try a PR, looks like simple fix.

@josegonzalez
Copy link
Member

Pull requests welcome. I get to them as I have time.

@Friss
Copy link
Contributor

Friss commented Oct 14, 2019

Looks like a good alternative would be exposing the pg_dumpall command

Though I'm not sure if pg_dumpall would fit in as a replacement for the current functionality or something in addition (and how that fits into the organization of this plugin)

Schlepptop pushed a commit to Schlepptop/dokku-postgres that referenced this issue Jul 18, 2020
✨ Actually clone the service, not just the SERVICE_NAME DB
See dokku#180
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants