pg_dump and compression #975
Labels
No labels
blocked
breaking
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No milestone
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
borgmatic-collective/borgmatic#975
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
I'm using borgmatic to backup postgresql database and the default export options are
--format custom. By default for custom formatpg_dumpcompresses the export file using gzip as explained in the documentation.I can set an additional
pg_dumpflag withoptions: --compression=none.Question
What's the best way to export the database if I set
compression: auto,zstdin the borgmatic config?Does
pg_dumpproduce a compressed backup with high entropy due to compression, rendering borg deduplication useless?Additional
https://www.postgresql.org/docs/current/app-pgdump.html
dump_format = database.get('format', None if database_name == 'all' else 'custom')This is a great question, and I honestly don't know the answer. My instinct says not to double compress, but that's just instinct. I'd actually recommend answering this experimentally. Something like the following:
Start with Borg compression enabled and Postgresql compression enabled.
borgmatic createand time how long it takes.borgmatic infoand observe the compressed size vs. original size vs. deduplicated size of the archive.borgmatic createagain, timing how long it takes.borgmatic infoagain and check the sizes for the second archive.Disable PostgreSQL compression in the borgmatic configuration file. Then delete the repository and run through the steps above again, noting down the results.
Now compare the results with Postgresql compression and without. Is the observed time/size tradeoff more favorable with or without compression?
Side question: Would you benefit from a
compression:option for PostgreSQL databases in borgmatic config?The behavior may be different for large databases. By the way, my theory is that the best parameters are
--format directory --compression none. I'll test that too.The
compression:option would be great, the default value should benone, I guess.I didn't notice this at first, but they changed the `--compress' option in postgresql 16.
Before:
After:
Double compression
1st run
Duration: 13.43 seconds
2nd run
Duration: 13.43 seconds
Single compression
1st run
Duration: 18.40 seconds
2nd run
Duration: 12.78 seconds
Directory export doesn't work when
docker exec database pg_dump.Thanks for running all that and reporting back! Based on those results, here are my takes:
So I would say, just based on those results, you may want to leave PostgreSQL compression disabled! And I'll leave this ticket open to add that
compressorcompressionoption to borgmatic. Based on your findings with different versions of PostgreSQL, I'll probably just make it a string and lean on the user to set it accordingly based on their version.You might consider filing a separate ticket for this, and I'd be happy to take a look.
pg_dumpindirectoryformat can't be done if extracted usingdocker exec#978The PostgreSQL "compression" option is implemented in main and will be part of the next release!
Released in borgmatic 1.9.13!