I was updating my blog and needed to use the same database which I currently have in production. Since my blog is fully dockerized, managing the state of the application between production & development environment is a lot easier.
For this purpose, I have researched and learned two handy commands, one to export the database and the other one to import the database.
Export (dump) with pg_dump
{.single}:
|
|
Import (restore) with psql
{.single}:
|
|
I have noticed successful import even with errors (default PostgreSQL behaviour), because I already had some migrations (in my Django app). Therefore I would recommend first resetting the whole DB and then importing the database. If you want to overwrite this default behaviour and stop upon error, add -set ON_ERROR_STOP=on
{.single} to your command.