PostgreSQL Backup – Slow Performance Using gzip

backupcompressionpostgresql

We are currently backing up some schemas in Postgres using this command:

pg_dump -h localhost -n test_schema mydb | gzip > /data1/backup/test_chema.dmp.gz

And we are getting a rate of 50 Megabytes per minute, which is pretty slow, we think this could be improved.

Disk seems to be OK so is CPU.

Any thoughts on how this can get improved?

Best Answer

Use directory mode and run several parallel jobs:

pg_dump -F d -j 4 -h localhost -n test_schema -f /data1/backup/test_schema mydb

That will automatically compress the backup.