PostgreSQL Dump & Restore Entire Database

To backup entire database into a single file:

pg_dumpall > db.out

To restore all object in a script file to specified role:

psql -f db.out postgres