---
name: "pg_backupcluster"
section: "1"
platform: "linux"
package: "postgresql-common"
version: "278"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/pg_backupcluster"
---

# pg\_backupcluster(1)

simple pg\_basebackup and pg\_dump front-end

## NAME

pg\_backupcluster - simple pg\_basebackup and pg\_dump front-end

## SYNOPSIS

**pg\_backupcluster** \[*options*\] *version* *cluster* *action*

## DESCRIPTION

**pg\_backupcluster** provides a simple interface to create PostgreSQL cluster backups using [**pg\_basebackup**(1)](/pg_basebackup/1.md) and [**pg\_dump**(1)](/pg_dump/1.md).

To ease integration with **systemd** operation, the alternative syntax "**pg\_basebackup** *version***-***cluster* *action*" is also supported.

## ACTIONS

- **createdirectory**

  Create /var/backups/postgresql and /var/backups/postgresql/*version*-*cluster*. This action can be run as root to create the directories required for backups. All other actions will also attempt to create the directories when missing, but can of course only do that when running as root. They will switch to the cluster owner after this step.

- **basebackup**

  Backup using [**pg\_basebackup**(1)](/pg_basebackup/1.md). The resulting basebackup contains the WAL files required to run recovery on startup.

- **dump**

  Backup using [**pg\_dump**(1)](/pg_dump/1.md). Global objects (users, tablespaces) are dumped using [**pg\_dumpall**(1)](/pg_dumpall/1.md) **--globals-only**. Individual databases are dumped into PostgreSQL's custom format.

- **expirebasebackups** *N*

  Remove all but last the *N* basebackups.

- **expiredumps** *N*

  Remove all but last the *N* dumps.

- **deletebroken**

  Remove all broken backups.

- **receivewal**

  Launch pg\_receivewal. WAL files are gzip-compressed in PG 10+.

- **compresswal**

  Compress WAL files in archive.

- **archivecleanup**

  Remove obsolete WAL files from archive using [**pg\_archivecleanup**(1)](/pg_archivecleanup/1.md).

- **list**

  Show dumps, basebackups, and WAL, with size.

## OPTIONS

- **-c --checkpoint=spread\|fast**

  Passed to **pg\_basebackup**. Default is **spread**.

- **-k --keep-on-error**

  Keep broken backup directory on error. By default backups are deleted on error. Broken backups can be cleaned up using the **deletebroken** action.

- **-v --verbose**

  Verbose output, even when not running on a terminal.

- **-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**

  Backup from **pg\_backupcluster ... basebackup**.

  - config.tar.gz

    Tarball of 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 backup run.

- /var/backups/postgresql/*version*-*cluster*/*timestamp***.dump**

  Backup from **pg\_backupcluster ... dump**.

  - config.tar.gz

    Tarball of 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 backup run.

- /var/backups/postgresql/*version*-*cluster*/**wal**

  WAL files from **pg\_receivewal**.

## CAVEATS

For dump-style backups, not all properties of the original cluster are preserved:

- •

  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.

## SEE ALSO

[**pg\_restorecluster**(1)](/pg_restorecluster/1.md), [**pg\_dump**(1)](/pg_dump/1.md), [**pg\_dumpall**(1)](/pg_dumpall/1.md), [**pg\_basebackup**(1)](/pg_basebackup/1.md), [**pg\_receivewal**(1)](/pg_receivewal/1.md), [**pg\_archivecleanup**(1)](/pg_archivecleanup/1.md).

## AUTHOR

Christoph Berg \<myon@debian.org\>
