Docker DB backup Process #2415
Unanswered
scott-dunt
asked this question in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
"Borrowing" from another project that also runs PostgreSQL in a Docker container, you can backup, actually dump the Outline DB from the Linux command line as:
if you run this from a CRON schedule, you will need to find the absolute path to the docker command, Cron often does not have the same path as user has, so it may not find the command without the path.
exec
tells docker to run the following commandspg_dump outline -U outline -F c
INSIDE the containeroutline-wiki_postgres_1
is the name docker-compose assigned to my Outline postgres container.. you can find that in the Docker PS output.pg_dump
is a tool included in PostgreSQL docker images that will dump the specified DB to Standard out in a format that the commandpg_restore
can process.outline -U outline -F c
is the name of the database, then the User name -U , finally setting the output to a "custom" format (-F c)you can find the DB and username in your docker-compose file:
Finally the
> outline.dump
redirects the data pg_dump is sending to 'Standard out' to a file for storage.To restore the DB use:
Docker Exec doc: https://docs.docker.com/engine/reference/commandline/exec/
Docs on pg_dump command: https://www.postgresql.org/docs/11/app-pgdump.html
Docs on pg_restore: https://www.postgresql.org/docs/11/app-pgrestore.html
Beta Was this translation helpful? Give feedback.
All reactions