Skip to content

Instantly share code, notes, and snippets.

@rudyryk
Last active May 12, 2023 09:12
Show Gist options
  • Save rudyryk/ee0941269095a8b2f800cf9fa1ea3b1d to your computer and use it in GitHub Desktop.
Save rudyryk/ee0941269095a8b2f800cf9fa1ea3b1d to your computer and use it in GitHub Desktop.
Dump PostgresQL database via Docker
#!/bin/sh
export DBUSER=postgres
export DBNAME=database
export DBHOST=localhost
export DBPORT=5432
export DBOPTIONS=
export PGPASSWORD=
docker run --rm -e PGPASSWORD=${PGPASSWORD} postgres:latest pg_dump ${DBOPTIONS} \
--host=${DBHOST} --port=${DBPORT} --username=${DBUSER} \
--format=t --dbname=${DBNAME} | gzip > db-$(date +%Y-%m-%d).tar.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment