Hasty Briefsbeta

Bilingual

How to Back Up PostgreSQL in Docker (Local, S3, and Plakar)

15 hours ago
  • PostgreSQL backups in Docker can be done using pg_dumpall with gzip, storing locally or to S3, with cron scheduling and pruning.
  • Traditional daily full SQL dumps are inefficient because even small changes require transferring the entire database each day, leading to high storage and transfer costs.
  • Plakar offers deduplication by storing chunks across snapshots, drastically reducing transfer and storage (e.g., ~64 GB/year vs ~12.5 TB for a growing 10 GB DB).
  • Setting up Plakar involves creating a repository (local or S3), configuring aliases and a passphrase, and using scripts for backup and restore.
  • Plakar supports incremental-like snapshots that are standalone; pruning policies (e.g., keep 1 per day for 7 days) automate deletion of old snapshots.
  • For S3, install the Plakar S3 plugin, add a store alias with AWS credentials, and then use the same backup/restore scripts with the S3 repository.
  • Plakar simplifies switching between storage backends (local, S3, others) with nearly identical commands, and its built-in maintenance handles data cleanup.