Created
September 13, 2017 17:33
-
-
Save ricjcosme/cf576d3d4272cc35de1335a98c547da6 to your computer and use it in GitHub Desktop.
DUMP / RESTORE PostgreSQL Kubernetes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DUMP | |
// pod-name name of the postgres pod | |
// postgres-user database user that is able to access the database | |
// database-name name of the database | |
kubectl exec [pod-name] -- bash -c "pg_dump -U [postgres-user] [database-name]" > database.sql | |
RESTORE | |
// pod-name name of the postgres pod | |
// postgres-user database user that is able to access the database | |
// database-name name of the database | |
cat database.sql | kubectl exec -i [pod-name] -- psql -U [postgres-user] -d [database-name] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@sudonewdev try this
kubectl exec -i [pod-name] -- psql -U [postgres-user] -d [database-name] -f database.sql
or install psql client with :
then :
psql -U [postgres-user] -p [database-port] -h [postgres-ip] -d [database-name] -f database.sql