PG_BACKUPCLUSTER(1)

πŸ’– PG_BACKUPCLUSTER(1) πŸ’–

okay bestie, this is pg_backupcluster β€” a Debian PostgreSQL infrastructure babe. she's a little front-end and she's about to make your whole backup situation iconic. pull up a chair 🫢


✨ NAME ✨

pg_backupcluster β€” a simple pg_basebackup and pg_dump front-end. that's it, that's the girl.


🌸 SYNOPSIS 🌸

pg_backupcluster [options] version cluster action

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically pg_backupcluster gives you the simplest possible interface for making PostgreSQL cluster backups, and she does it using pg_basebackup(1) and pg_dump(1). no cap. πŸ’…

and because systemd integration needs to be easy too, there's an alternate syntax that also works:

pg_basebackup version-cluster action

literally both are fine, she just wants you to win. ✨


πŸŽ€ ACTIONS πŸŽ€

  • createdirectory β€” makes /var/backups/postgresql and /var/backups/postgresql/version-cluster. this one's the one you run as root to set up the dirs backups need. all the other actions will also try to create the directories if they're missing, but bestie they can obviously only do that if they're running as root. after that step they switch over to the cluster owner. 🫑
  • basebackup β€” backup time, using pg_basebackup(1). the basebackup it spits out contains the WAL files you need to run recovery on startup. slay.
  • dump β€” backup via pg_dump(1). global objects (users, tablespaces) get dumped using pg_dumpall(1) --globals-only. individual databases get dumped into PostgreSQL's custom format.
  • expirebasebackups N β€” removes all but the last N basebackups. bye girl πŸ‘‹
  • expiredumps N β€” removes all but the last N dumps.
  • deletebroken β€” removes all broken backups. the cleanup we love to see.
  • receivewal β€” launches pg_receivewal. WAL files are gzip-compressed in PG 10+.
  • compresswal β€” compresses WAL files in the archive.
  • archivecleanup β€” removes obsolete WAL files from the archive using pg_archivecleanup(1).
  • list β€” shows dumps, basebackups, and WAL, with size. the receipts. 🧾

✨ OPTIONS ✨

  • -c, --checkpoint=spread|fast β€” passed straight to pg_basebackup. default is spread.
  • -k, --keep-on-error β€” keeps the broken backup directory when there's an error. by default, backups get deleted on error. you can clean up broken backups later with the deletebroken action. πŸ’€
  • -v, --verbose β€” verbose output, even when you're not running on a terminal. she's chatty and she owns it.
  • -Z level, --compress=level β€” passed to pg_dump, pg_basebackup and pg_receivewal. default is pg_dump's default compression, gzip for pg_basebackup, and 5 for pg_receivewal.

🌈 FILES 🌈

  • /var/backups/postgresql β€” default root directory for cluster backup directories.
  • /var/backups/postgresql/version-cluster β€” default directory for cluster backups.
  • /var/backups/postgresql/version-cluster/timestamp.basebackup β€” the backup from pg_backupcluster ... basebackup. here's what's inside her:
    • config.tar.gz β€” tarball of the cluster configuration directory (postgresql.conf, pg_hba.conf, ...) in /etc/postgresql.
    • tablespace.tar.gz, pg_wal.tar.gz, backup_manifest β€” tablespace and WAL tarballs and backup info written by pg_basebackup.
    • status β€” completion timestamp of the backup run.
  • /var/backups/postgresql/version-cluster/timestamp.dump β€” the backup from pg_backupcluster ... dump. contents:
    • config.tar.gz β€” tarball of the cluster configuration directory (postgresql.conf, pg_hba.conf, ...) in /etc/postgresql.
    • createcluster.opts β€” options (encoding, locale, data checksums) to be passed to pg_createcluster for restoring this cluster.
    • globals.sql β€” global objects (roles, tablespaces) from pg_dumpall --globals-only.
    • databases.sql β€” SQL commands to create databases and restore database-level options.
    • database.dump β€” database dumps from pg_dump --format=custom.
    • status β€” completion timestamp of the backup run.
  • /var/backups/postgresql/version-cluster/wal β€” WAL files from pg_receivewal.

πŸ™ˆ CAVEATS πŸ™ˆ

okay listen, for dump-style backups, not all properties of the original cluster are preserved. important. keep reading:

  • In PostgreSQL 10 and earlier, ALTER ROLE ... IN DATABASE is not supported.
  • Not all initdb options are carried over. currently supported are --encoding, --lc-collate, --lc-collate, and -k --data-checksums.
⚠️ the earliest PostgreSQL version supported for dumps is 9.3. for basebackups, the earliest supported version is 9.1. receivewal (and hence archive recovery) are supported in 9.5 and later. don't try it on your ancient fossil, bestie 😭

πŸ‘‘ SEE ALSO πŸ‘‘

pg_restorecluster(1), pg_dump(1), pg_dumpall(1), pg_basebackup(1), pg_receivewal(1), pg_archivecleanup(1).


πŸ’œ AUTHOR πŸ’œ

Christoph Berg <myon@debian.org> β€” the icon, the legend. 🫢


and that's the whole page, bestie!! this babe ships in Debian, dated 2026-07-28, and she's forever our PG_BACKUPCLUSTER(1). go make some backups, you're doing amazing sweetie πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from