A function for finalizing an on-line backup.
This entry relates to a PostgreSQL feature which is part of PostgreSQL 15, due to be released in late 2022.

pg_backup_stop() is a system function for finalizng an on-line backup commenced with pg_backup_start().

pg_backup_stop() was added in PostgreSQL 15, replacing pg_stop_backup()


pg_backup_stop ( [wait_for_archive boolean ] ) → 
        record ( lsn pg_lsn, labelfile text, spcmapfile text )

Following execution of pg_backup_start() to start the online backup, the data directory should be copied by a reliable method (e.g. rsync) to another location. On completion of this process, pg_backup_stop() is called and returns a backup label file and a tablespace map file are returned which must be placed in the copy target location.

Note that it is generally preferable to use a backup utility such as Barman or pgbackrest to manage the process of backing up a PostgreSQL instance, and a tool such as repmgr to clone PostgreSQL instances.

Change history


Example usage for :

postgres=# SELECT pg_backup_start('foo');
(1 row)

postgres=# SELECT * FROM pg_backup_stop();
NOTICE:  WAL archiving is not enabled; you must ensure that all required WAL segments are copied through other means to complete the backup
    lsn    |                           labelfile                           | spcmapfile 
 0/7D37068 | START WAL LOCATION: 0/4000028 (file 000000010000000000000004)+| 
           | CHECKPOINT LOCATION: 0/4000060                               +| 
           | BACKUP METHOD: streamed                                      +| 
           | BACKUP FROM: primary                                         +| 
           | START TIME: 2022-05-28 09:52:22 JST                          +| 
           | LABEL: foo                                                   +| 
           | START TIMELINE: 1                                            +| 
           |                                                               | 
(1 row)

In this example, no tablespace map file is returned.


Backup, System function

See also