NOTE: Do not use -t parameter for pseudo-tty handling with docker. This can cause errornous handling of piped (binary) output
The parameter -C -c will force recreation of database
docker exec your-db-container pg_dumpall -c -U postgres > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
Custom format dump file for use with pg_restore with recreation of database (-C -c)
docker exec postgres pg_dump -Fc -C -c -U postgres my-database > dump_`date +%d-%m-%Y"_"%H_%M_%S`.dump
NOTE: Do not use -i parameter for stdin handling with docker. This can cause errornous handling of piped (binary) input
cat latestdump.sql | docker exec -i your-db-containe psql -U postgres
Create database (-C)
docker exec -t your-db-container pg_restore -C -U postgres < dump_xxxx-xx-xx_xx_xx_xx.sql
Custom format restore with recreation (drop+create) of database (-C -c)
docker exec -t your-db-container pg_restore -Fc -C -c -U postgres < dump_xxxx-xx-xx_xx_xx_xx.dump