Installation

Suggest edits

Prerequisites

Postgres backup API must be installed on the same server as Barman.

The Postgres backup API packages depend on the Barman packages so if you are not installing alongside an existing Barman installation then the Barman packages will also be installed.

It is recommended that you follow the Barman documentation to ensure your Barman installation is fully functional before continuing with Postgres backup API.

Available platforms

Postgres backup API packages are available on the following platforms.

Debian/Ubuntu

Supported versions of Debian and Ubuntu are:

  • Debian 10 (buster)
  • Debian 11 (bullseye)
  • Ubuntu 18.04 (bionic)
  • Ubuntu 20.04 (focal)

Official Debian packages for Postgres backup API are distributed by EnterpriseDB and made available through the EDB public APT repositories. The required repository can be enabled by following the instructions at that website.

Install pg-backup-api as follows:

sudo apt-get install pg-backup-api

RHEL/CentOS

Postgres backup API is supported on RHEL 7 and 8 in addition to binary compatible alternatives such as CentOS and Rocky.

Official RPM packages for Postgres backup API are distributed by EnterpriseDB and made available through the EDB public YUM repositories. The required repository can be enabled by following the instructions at that website.

Note

If you have not already installed Barman, or if the enabled repositories have changed since Barman was installed, you will also need to install the Extra Packages Enterprise Linux (EPEL) repository and the PostgreSQL Global Development Group RPM repository.

Install pg-backup-api as follows:

sudo yum install pg-backup-api

SLES

Postgres backup API is supported on SLES 15 SP3 and SLES 12 SP5.

Postgres backup API packages for SLES are distributed by EnterpriseDB and made available through the EDB public zypper repositories. The required repository can be enabled by following the instructions at that website.

Note

For SLES 12 only: If you have not already installed Barman then you will need to enable the OpenSUSE python backports repositories as described in the Barman documentation.

Install pg-backup-api as follows:

sudo zypper install pg-backup-api

Post installation steps

Once the packages are installed you can start the pg-backup-api service:

sudo systemctl start pg-backup-api

Enable the service so that it is started automatically on reboot:

sudo systemctl enable pg-backup-api

Postgres backup API is now serving requests on localhost port 7480. Test everything is ok by making a request to the status endpoint:

curl http://localhost:7480/status
"OK"

Confirm details of your Barman installation are being reported via the diagnose endpoint:

curl http://localhost:7480/diagnose
{
  "global": {
     ...
   },
   ...
}

You can now query Barman over HTTP, however because Postgres backup API works over plain HTTP it is restricted to serving on localhost only. To securely enable remote access follow the instructions in securing Postgres backup API.

Send a new task to perform a recover by providing metadata like this:

curl -X POST http://localhost:7480/servers/<SERVER_NAME>/operations -H "content-type: application/json" -d@payload-pg-backup-api.json
{
  "operation_id": {  "20221227T115428" },
   ...
}

The json payload should look like this:

{"operation_type": "recover",
 "backup_id": "latest",
 "remote_ssh_command": "ssh postgres@locahost",
 "destination_directory": "/var/lib/pgdata"}

Congrats! Carry on with Operations for further information about how to create tasks operations with the API.


Could this page be better? Report a problem or suggest an addition!