Dumping with pg_dump -j is the half of parallel backups people usually hear about. The restore side is where the waiting often hurts more, and pg_restore has its own switch for it.
pg_restore -j 4 -d appdb appdb.dump
With -j (--jobs), pg_restore runs the slowest steps concurrently: loading data, creating indexes and creating constraints. Each job uses its own connection to the server. The docs suggest starting with the number of CPU cores on the server, and say that values higher than that can still help, while a value that is too high slows things down again.
The rules from the docs are what trip people up:
- It only works with the custom and directory archive formats. A plain SQL file made with
pg_dumphas to go throughpsql. - The input must be a regular file or directory, not a pipe or standard input. So
cat appdb.dump | pg_restore -j 4will not do. - It cannot be combined with
--single-transaction. - It is ignored when pg_restore only writes a script instead of connecting to a database.
A parallel restore is not all-or-nothing the way -1 is, so a failure halfway leaves a partly restored database. I would restore into an empty scratch database first, check it, and only then think about the real one. And do not go overboard with the job count on a small home server: a few jobs and a disk that cannot keep up is just thrashing, which the docs also warn about.
Further reading: PostgreSQL documentation: pg_restore