Skip to content
Simple backup script for PostgreSQL
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


pg_back is a simple backup script for PostgreSQL.


pg_back uses pg_dumpall to dump roles and tablespaces, pg_dump to dump
each selected database to a separate file. The custom format of
pg_dump is used by default.

A configuration file, by default /etc/pg_back/pg_back.conf, can
hold the configuration to automate the backup. Most options can be
overridden on the command line.

Databases to dump can be specified in the configuration file or on the
command line.  A list of databases can also be excluded. Database
templates can be included, with the exception of template0, because
connection to it are forbidden by default.

The purpose of the script is to allow unattended backups, thus a purge
time can be configured to avoid running out of disk space in the
backup directory. It is set to 30 days by default. A minimum number of backups
can also be kept.

If running on a standby database, il will pause replication for the duration of
the dump.

The script is working out of the box, but you should consider editing
it to fit your needs.


It is best to run it as the postgres user. For example :

    pg_back -b /var/lib/pgsql/9.3/backups

See the help with pg_back -?.


The source code is available on github:

pg_back is developped by Nicolas Thauvin <> under a
classic 2 clauses BSD license. See license block in the script.
You can’t perform that action at this time.