where does pg_dumpall store *.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 &mdash; this, then, is your &ldquo;.bak file&rdquo;.

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 &ldquo;1234&rdquo; is the port number of your new database cluster.