backup-restore.txt
· 203 B · Text
Raw
# BACKUP
docker exec -i <container-name> /bin/bash -c "PGPASSWORD=<passwd> pg_dump --username <user> <db-name>" > ~/db.sql
# RESTORE
cat db.sql | docker exec -i <container-name> psql -U <user> <db-name>
1 | # BACKUP |
2 | docker exec -i <container-name> /bin/bash -c "PGPASSWORD=<passwd> pg_dump --username <user> <db-name>" > ~/db.sql |
3 | |
4 | # RESTORE |
5 | cat db.sql | docker exec -i <container-name> psql -U <user> <db-name> |