I want to dump a database. and I use:


by using this code, data which has been stored on data base is scrolling in the terminal and it says:

PostgreSQL database dump complete

PostgreSQL database cluster dump complete

but I can not find any new .bak file any where. I also used:

pg_dumpall -f test

it goes to next line without showing any message.

finally, where is stored .bak file?!


There is no .bak file until you name it so.

With the last command in your question, the dump is written to the file test — this, then, is your “.bak file”.

In fact, it is an SQL script, because pg_dumpall only supports the plain text format.

You restore such a dump by feeding it to psql:

psql -h hostname -p 1234 -f test -d postgres -U postgres

Where “1234” is the port number of your new database cluster.


By default, pg_dumpall writes its output to stdout, i.e the terminal. There is no .bak file, because you didn't ask it to create one.

Either direct the output to a file or, better still, use pg_dumpall's "-f" argument to name the file you want the output written to:

pg_dumpall ...  > ./backup.bak 
pg_dumpall ...  -f ./backup.bak 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy