Skip to content

Instantly share code, notes, and snippets.

@Ivan-Feofanov
Created October 30, 2018 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ivan-Feofanov/4585d81956a326f17fd35cffb656963b to your computer and use it in GitHub Desktop.
Save Ivan-Feofanov/4585d81956a326f17fd35cffb656963b to your computer and use it in GitHub Desktop.
backup postgres db in kubernetes
DB_NAME=$1
NAMESPACE=$@
POD=$(kubectl -n="$NAMESPACE" get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' --selector=app=postgres)
kubectl -n="$NS" exec "$POD" pg_dump -Fc --no-acl --no-owner -h localhost -U postgres -w "$DB_NAME"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment