DEV Community

Discussion on: Replicate your PostgreSQL database into another server using just one command.

Collapse
 
rhymes profile image
rhymes • Edited

Nice tip!

You just reminded me of one more. If you have a big database you can save some time:

  • using serial dumping with a custom format: pg_dump -Fc | pg_restore (instead of using SQL which is the default)
  • using parallel restore with:
pg_dump -Fc DB_NAME -f DUMP_FILE.gz && pg_restore -d TARGET_DB -j NUM_CORES DUMP_FILE.gz

or

pg_dump -Fd DB_NAME DUMP_FOLDER && pg_restore -d TARGET_DB -j NUM_CORES DUMP_FOLDER
  • using both parallel dumping and parallel restore:
pg_dump -Fd -j NUM_CORES DB_NAME -f DUMP_FOLDER && pg_restore -d TARGET_DB -j NUM_CORES DUMP_FOLDER

Hope it helps :D

Collapse
 
levivm profile image
Levi Velázquez Fullstapps

Thx, nice to know it.