0

I'm trying to import a db that someone sent me: testdb.tar (43GB size) First I've imported using:

pg_restore --host localhost --port 5432 --username postgres --dbname testdb --role postgres --no-password  --verbose testdb.tar

It took 23 hours to complete. I supose it used just a single core. Now, trying to do it faster, using the available 16 cores, I tried:

pg_restore --host localhost --port 5432 --username postgres --dbname testdb --role postgres --no-password -j 16 --verbose testdb.tar

However, it throws the following error:

pg_restore: error: parallel restore is not supported with this archive file format

Not really sure why it complains.

2 Answers 2

1

Because the "tar" format cannot be restored in parallel.

Use the "custom" or "directory" format of pg_dump so that it can be restored with parallel processes.

But Jeff had a good idea (see the comment): If you untar the backup into a directory, you can then do a parallel restore by pointing pg_restore to that directory.

6
  • I am not sure how was it dumped.. "pg_dump - ..."
    – catalin
    Nov 12, 2020 at 14:15
  • But I know, so I wrote the answer. Nov 12, 2020 at 14:32
  • So I need to run "pg_restore --host localhost --port 5432 --username postgres --dbname testdb --role postgres --no-password --verbose /path/directory/where/tar/file/is/" ?
    – catalin
    Nov 12, 2020 at 14:43
  • 1
    No, you need to take the dump in a different format. If you cannot do that, you have to restore single-threaded. Nov 12, 2020 at 14:44
  • 2
    @catalin If you untar the backup into a directory, you could then do a parallel restore by pointing pg_restore to that directory.
    – jjanes
    Nov 14, 2020 at 0:24
0

I managed to make it work by using "-Fd" and the the directory source name, instead of the tar source file. Exported directory contains files like: 3235.dat.gz ... 3300.dat.gz, log.txt and toc.dat So, it works by using:

pg_restore --host localhost --port 5432 --username postgres --dbname testdb --role postgres --no-password  -Fd -j 16 --verbose /path/to/testdb_directory

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.