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

How to backup/restore postgres database? #54

Open
Raruto opened this issue Jul 21, 2022 · 2 comments
Open

How to backup/restore postgres database? #54

Raruto opened this issue Jul 21, 2022 · 2 comments
Labels
docs Improvements or additions to documentation

Comments

@Raruto
Copy link
Collaborator

Raruto commented Jul 21, 2022

Currently the readme only explains how to log in as a postgres user, but how is it possible to dump the data? (ie. how to export a dump.sql file on host machine?)

This is what I found on stackoverflow:

backup psql:

docker exec -t g3w-suite-docker-postgis-1 pg_dumpall -c -U postgres > dump.sql

restore psql:

cat dump.sql | docker exec -i g3w-suite-docker-postgis-1 psql -U postgres

but I think it still needs a few minor tweaks to work: backup-restore-a-dockerized-postgresql-database

@Raruto
Copy link
Collaborator Author

Raruto commented Jul 21, 2022

As per #54 (comment):

docker exec -t g3w-suite-docker-postgis-1 pg_dumpall -c -U postgres > dump.sql

# dump.sql
# pg_dumpall: could not connect to database "template1": FATAL:  Peer authentication failed for user "postgres"

adding -h localhost:

docker exec -t g3w-suite-docker-postgis-1 pg_dumpall -c -U postgres -h localhost > dump.sql 

# dump.sql created as empty file (command line interface hangs indefinitely)

@Raruto
Copy link
Collaborator Author

Raruto commented Aug 17, 2022

In this case the shared volume of postgis service has the following mapping:

- g3wsuite-pg-data:/var/lib/postgresql

As per docker documentation on how backup restore or migrate data volumes, you can find that folder under in this location:

# Linux 

/var/lib/docker/volumes/
# Windows (WSL 2)

\\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes

More info:

@Raruto Raruto added the docs Improvements or additions to documentation label Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant