This is a really fast way to restore a large Postgres database by omiting the indexes and restoring them later (if necessary).
-
Dump database.
pg_dump -Fc --no-owner my_db -f ~/my_db.dump
-
Create the summary files. One for the indexes and another for everything else.
pg_restore -l ~/my_db.dump | grep -v 'INDEX public' > ~/my_db.list pg_restore -l ~/my_db.dump | grep 'INDEX public' > ~/my_db-indexes.list
-
Restore everything except the indexes (should be pretty fast).
pg_restore --no-owner --jobs=4 --verbose --use-list=$HOME/my_db.list --dbname=my_db ~/my_db.dump
-
If desired, restore the indexes (this part's slow and index creation locks the database).
pg_restore --no-owner --jobs=4 --verbose --use-list=$HOME/my_db-indexes.list --dbname=my_db ~/my_db.dump