You can use Veeam Agent for Linux to create transactionally consistent backups of Veeam Agent machines that run the PostgreSQL database system.
You can use Veeam Explorer for PostgreSQL to restore PostgreSQL instances from a Veeam Agent for Linux backup. For information about item-level recovery of PostgreSQL systems, see the Restoring PostgreSQL Items section of the Veeam Backup & Replication User Guide.
How PostgreSQL Processing Works
After Veeam Agent for Linux finishes database system processing, Veeam Agent proceeds to the next step of the backup process. To learn more, see How Backup Works.
To ensure that the backed-up data is in the consistent state, Veeam Agent performs the PostgreSQL database processing using an internal component: pgsqlagent. To process the database system, Veeam Agent performs the following operations:
- When the backup job starts, Veeam Agent scans the Veeam Agent computer for PostgreSQL instances.
By default, Veeam Agent recursively scans the /etc and /var/lib directories for the configuration files of PostgreSQL instances. If your instance is stored in a custom location, you must specify its location in the PostgreSQL configuration file — VeeamPostgreSQLAgent.xml. You must create this file in the /etc/veeam/ directory. To explicitly include or exclude specific directories in/from processing, you can use the following elements in the configuration file:
- AddConfigDirs — use this element to specify paths to directories that you want Veeam Agent to scan.
- ExcludeConfigDirs — use this element to specify paths to directories that you do not want Veeam Agent to scan.
You can specify directories that you want to include and directories that you want to exclude in the same configuration file.
An example of the VeeamPostgreSQLAgent.xml file:
<config AddConfigDirs="/opt/psql/" ExcludeConfigDirs="/var/lib/postgresql/13/main45/,/var/lib/postgresql/13/maindd/" />
- If a PostgreSQL instance is detected, Veeam Agent collects information about its state and configuration settings. The following Veeam Agent behavior depends on the collected information:
- Shutdown state
- Backup state
- Running instance with WAL level set as minimal
- Running instance with WAL level set as archival, replica or logical
To learn more about the WAL level setting, see PostgreSQL documentation.
Veeam Agent stores all collected data about PostgreSQL instances in the .VBM file, which allows Veeam Agent to restore PostgreSQL instance as an application item. To learn more, see Restoring PostgreSQL Items in the Veeam Backup & Replication User Guide.
- Veeam Agent creates a snapshot of the volume and proceeds to the next step of the backup process.
To learn more about backup process, see How Backup Works.
If the database instance is shut down, Veeam Agent skips it and tries to connect to the next instance. The skipped database instance will be included in the backup. You cannot restore such PostgreSQL instance as an independent item using Veeam Explorer for PostgreSQL. You can restore such database instance only using either volume-level or file-level restore.To learn more about restoring volumes and files, see Data Restore.
If the database instance is in the backup state, depending on the selected PostgreSQL Processing option, Veeam Agent performs the backup job differently:
- If the PostgreSQL processing is set to Require successful processing, the backup job will fail.
- If the PostgreSQL processing is set to Try application processing, ignore failures, Veeam Agent will skip the instance that is in the backup state and will try to connect to the next instance. The skipped database instance will not be included in the backup.
If the database is running and the WAL level is set as minimal, Veeam Agent forces a WAL checkpoint. This command fastens the database system restore. To learn more, see PostgreSQL documentation.
Keep in mind that the backup of a PostgreSQL instance with the minimal WAL level does not contain logs. As a result, you can restore your instance only to image-level backup state.
If the database instance is running and the WAL level is set as archival, replica or logical, Veeam Agent performs the following operations:
- Prepares the PostgreSQL instance and starts the on-line backup.
- Creates a snapshot of the instance.
- Stops the on-line backup.
Veeam Agent for Linux can connect to the PostgreSQL database system using one of the following methods:
- Database user with password — Veeam Agent uses the PostgreSQL account credentials that you specify in the backup job settings.
- Database user with password file — Veeam Agent the PostgreSQL database system to use account credentials that are stored in the .pgpass password file. To learn more about password file configuration, see Preparing Password File for PostgreSQL Processing.
- System user without password — Veeam Agent uses the peer authentication. In the peer authentication method, Veeam Agent for Linux uses the OS account as the PostgreSQL database user name.
Requirements and Limitations for PostgreSQL Processing
- Veeam Agent supports processing of PostgreSQL database systems version 12, 13, 14, 15 and 16.
- Veeam Agent does not support processing of PostgreSQL database clusters with enabled streaming replication.