From 754f02228e84ac791b66b494e13d523e590490b7 Mon Sep 17 00:00:00 2001 From: Alexey Savchkov Date: Wed, 24 May 2023 15:13:01 +0300 Subject: [PATCH 01/12] PBCKP-624 Remove outdated installation instructions for Standard and Enterprise --- LICENSE | 2 +- README.md | 91 ++++++++++++++----------------------------------------- 2 files changed, 24 insertions(+), 69 deletions(-) diff --git a/LICENSE b/LICENSE index 0ba831507..66476e8a9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2015-2020, Postgres Professional +Copyright (c) 2015-2023, Postgres Professional Portions Copyright (c) 2009-2013, NIPPON TELEGRAPH AND TELEPHONE CORPORATION Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group diff --git a/README.md b/README.md index 7486a6ca6..b804eb1fb 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ `pg_probackup` is a utility to manage backup and recovery of PostgreSQL database clusters. It is designed to perform periodic backups of the PostgreSQL instance that enable you to restore the server in case of a failure. The utility is compatible with: -* PostgreSQL 9.6, 10, 11, 12, 13, 14, 15; +* PostgreSQL 11, 12, 13, 14, 15; As compared to other backup solutions, `pg_probackup` offers the following benefits that can help you implement different backup strategies and deal with large amounts of data: * Incremental backup: page-level incremental backup allows you to save disk space, speed up backup and restore. With three different incremental modes, you can plan the backup strategy in accordance with your data flow. @@ -74,113 +74,68 @@ Installers are available in release **assets**. [Latests](https://github.com/pos #DEB Ubuntu|Debian Packages sudo sh -c 'echo "deb [arch=amd64] https://repo.postgrespro.ru/pg_probackup/deb/ $(lsb_release -cs) main-$(lsb_release -cs)" > /etc/apt/sources.list.d/pg_probackup.list' sudo wget -O - https://repo.postgrespro.ru/pg_probackup/keys/GPG-KEY-PG_PROBACKUP | sudo apt-key add - && sudo apt-get update -sudo apt-get install pg-probackup-{15,14,13,12,11,10} -sudo apt-get install pg-probackup-{15,14,13,12,11,10}-dbg +sudo apt-get install pg-probackup-{15,14,13,12,11} +sudo apt-get install pg-probackup-{15,14,13,12,11}-dbg #DEB-SRC Packages sudo sh -c 'echo "deb-src [arch=amd64] https://repo.postgrespro.ru/pg_probackup/deb/ $(lsb_release -cs) main-$(lsb_release -cs)" >>\ /etc/apt/sources.list.d/pg_probackup.list' && sudo apt-get update -sudo apt-get source pg-probackup-{15,14,13,12,11,10} +sudo apt-get source pg-probackup-{15,14,13,12,11} #DEB Astra Linix Orel sudo sh -c 'echo "deb [arch=amd64] https://repo.postgrespro.ru/pg_probackup/deb/ stretch main-stretch" > /etc/apt/sources.list.d/pg_probackup.list' sudo wget -O - https://repo.postgrespro.ru/pg_probackup/keys/GPG-KEY-PG_PROBACKUP | sudo apt-key add - && sudo apt-get update -sudo apt-get install pg-probackup-{15,14,13,12,11,10}{-dbg,} +sudo apt-get install pg-probackup-{15,14,13,12,11}{-dbg,} #RPM Centos Packages rpm -ivh https://repo.postgrespro.ru/pg_probackup/keys/pg_probackup-repo-centos.noarch.rpm -yum install pg_probackup-{15,14,13,12,11,10} -yum install pg_probackup-{15,14,13,12,11,10}-debuginfo +yum install pg_probackup-{15,14,13,12,11} +yum install pg_probackup-{15,14,13,12,11}-debuginfo #RPM RHEL Packages rpm -ivh https://repo.postgrespro.ru/pg_probackup/keys/pg_probackup-repo-rhel.noarch.rpm -yum install pg_probackup-{15,14,13,12,11,10} -yum install pg_probackup-{15,14,13,12,11,10}-debuginfo +yum install pg_probackup-{15,14,13,12,11} +yum install pg_probackup-{15,14,13,12,11}-debuginfo #RPM Oracle Linux Packages rpm -ivh https://repo.postgrespro.ru/pg_probackup/keys/pg_probackup-repo-oraclelinux.noarch.rpm -yum install pg_probackup-{15,14,13,12,11,10} -yum install pg_probackup-{15,14,13,12,11,10}-debuginfo +yum install pg_probackup-{15,14,13,12,11} +yum install pg_probackup-{15,14,13,12,11}-debuginfo #SRPM Centos|RHEL|OracleLinux Packages -yumdownloader --source pg_probackup-{15,14,13,12,11,10} +yumdownloader --source pg_probackup-{15,14,13,12,11} #RPM SUSE|SLES Packages zypper install --allow-unsigned-rpm -y https://repo.postgrespro.ru/pg_probackup/keys/pg_probackup-repo-suse.noarch.rpm -zypper --gpg-auto-import-keys install -y pg_probackup-{15,14,13,12,11,10} -zypper install pg_probackup-{15,14,13,12,11,10}-debuginfo +zypper --gpg-auto-import-keys install -y pg_probackup-{15,14,13,12,11} +zypper install pg_probackup-{15,14,13,12,11}-debuginfo #SRPM SUSE|SLES Packages -zypper si pg_probackup-{15,14,13,12,11,10} +zypper si pg_probackup-{15,14,13,12,11} #RPM ALT Linux 8 sudo sh -c 'echo "rpm https://repo.postgrespro.ru/pg_probackup/rpm/latest/altlinux-p8 x86_64 vanilla" > /etc/apt/sources.list.d/pg_probackup.list' sudo apt-get update -sudo apt-get install pg_probackup-{15,14,13,12,11,10} -sudo apt-get install pg_probackup-{15,14,13,12,11,10}-debuginfo +sudo apt-get install pg_probackup-{15,14,13,12,11} +sudo apt-get install pg_probackup-{15,14,13,12,11}-debuginfo #RPM ALT Linux 9 sudo sh -c 'echo "rpm https://repo.postgrespro.ru/pg_probackup/rpm/latest/altlinux-p9 x86_64 vanilla" > /etc/apt/sources.list.d/pg_probackup.list' sudo apt-get update -sudo apt-get install pg_probackup-{15,14,13,12,11,10} -sudo apt-get install pg_probackup-{15,14,13,12,11,10}-debuginfo +sudo apt-get install pg_probackup-{15,14,13,12,11} +sudo apt-get install pg_probackup-{15,14,13,12,11}-debuginfo #RPM ALT Linux 10 sudo sh -c 'echo "rpm https://repo.postgrespro.ru/pg_probackup/rpm/latest/altlinux-p10 x86_64 vanilla" > /etc/apt/sources.list.d/pg_probackup.list' sudo apt-get update -sudo apt-get install pg_probackup-{15,14,13,12,11,10} -sudo apt-get install pg_probackup-{15,14,13,12,11,10}-debuginfo -``` - -#### pg_probackup for PostgresPro Standard and Enterprise -```shell -#DEB Ubuntu|Debian Packages -sudo sh -c 'echo "deb [arch=amd64] https://repo.postgrespro.ru/pg_probackup-forks/deb/ $(lsb_release -cs) main-$(lsb_release -cs)" > /etc/apt/sources.list.d/pg_probackup-forks.list' -sudo wget -O - https://repo.postgrespro.ru/pg_probackup-forks/keys/GPG-KEY-PG_PROBACKUP | sudo apt-key add - && sudo apt-get update -sudo apt-get install pg-probackup-{std,ent}-{14,13,12,11,10,9.6} -sudo apt-get install pg-probackup-{std,ent}-{14,13,12,11,10,9.6}-dbg - -#DEB Astra Linix Orel -sudo sh -c 'echo "deb [arch=amd64] https://repo.postgrespro.ru/pg_probackup-forks/deb/ stretch main-stretch" > /etc/apt/sources.list.d/pg_probackup.list' -sudo wget -O - https://repo.postgrespro.ru/pg_probackup-forks/keys/GPG-KEY-PG_PROBACKUP | sudo apt-key add - && sudo apt-get update -sudo apt-get install pg-probackup-{std,ent}-{12,11,10,9.6}{-dbg,} - - -#RPM Centos Packages -rpm -ivh https://repo.postgrespro.ru/pg_probackup-forks/keys/pg_probackup-repo-forks-centos.noarch.rpm -yum install pg_probackup-{std,ent}-{14,13,12,11,10,9.6} -yum install pg_probackup-{std,ent}-{14,13,12,11,10,9.6}-debuginfo - -#RPM RHEL Packages -rpm -ivh https://repo.postgrespro.ru/pg_probackup-forks/keys/pg_probackup-repo-forks-rhel.noarch.rpm -yum install pg_probackup-{std,ent}-{14,13,12,11,10,9.6} -yum install pg_probackup-{std,ent}-{14,13,12,11,10,9.6}-debuginfo - -#RPM Oracle Linux Packages -rpm -ivh https://repo.postgrespro.ru/pg_probackup-forks/keys/pg_probackup-repo-forks-oraclelinux.noarch.rpm -yum install pg_probackup-{std,ent}-{14,13,12,11,10,9.6} -yum install pg_probackup-{std,ent}-{14,13,12,11,10,9.6}-debuginfo - -#RPM ALT Linux 7 -sudo sh -c 'echo "rpm https://repo.postgrespro.ru/pg_probackup-forks/rpm/latest/altlinux-p7 x86_64 forks" > /etc/apt/sources.list.d/pg_probackup_forks.list' -sudo apt-get update -sudo apt-get install pg_probackup-{std,ent}-{14,13,12,11,10,9.6} -sudo apt-get install pg_probackup-{std,ent}-{14,13,12,11,10,9.6}-debuginfo - -#RPM ALT Linux 8 -sudo sh -c 'echo "rpm https://repo.postgrespro.ru/pg_probackup-forks/rpm/latest/altlinux-p8 x86_64 forks" > /etc/apt/sources.list.d/pg_probackup_forks.list' -sudo apt-get update -sudo apt-get install pg_probackup-{std,ent}-{14,13,12,11,10,9.6} -sudo apt-get install pg_probackup-{std,ent}-{14,13,12,11,10,9.6}-debuginfo - -#RPM ALT Linux 9 -sudo sh -c 'echo "rpm https://repo.postgrespro.ru/pg_probackup-forks/rpm/latest/altlinux-p9 x86_64 forks" > /etc/apt/sources.list.d/pg_probackup_forks.list' && sudo apt-get update -sudo apt-get install pg_probackup-{std,ent}-{14,13,12,11,10,9.6} -sudo apt-get install pg_probackup-{std,ent}-{14,13,12,11,10,9.6}-debuginfo +sudo apt-get install pg_probackup-{15,14,13,12,11} +sudo apt-get install pg_probackup-{15,14,13,12,11}-debuginfo ``` Once you have `pg_probackup` installed, complete [the setup](https://postgrespro.github.io/pg_probackup/#pbk-install-and-setup). +For users of Postgres Pro products, commercial editions of pg_probackup are available for installation from the corresponding Postgres Pro product repository. + ## Building from source ### Linux From eb160266253f6fa059f59e52a19d9e215018c431 Mon Sep 17 00:00:00 2001 From: Alexey Savchkov Date: Wed, 1 Nov 2023 23:22:51 +0700 Subject: [PATCH 02/12] Add psycopg2 to the testing environment --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6f99d0f27..c3ad89568 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -72,8 +72,7 @@ jobs: - name: Install Testgres run: | git clone -b no-port-for --single-branch --depth 1 https://github.com/postgrespro/testgres.git - cd testgres - python setup.py install + pip3 install psycopg2 ./testgres # Grant the Github runner user full control of the workspace for initdb to successfully process the data folder - name: Test Probackup From 0c02283931b9389cec50b42be2f0f1be464b7955 Mon Sep 17 00:00:00 2001 From: vshepard Date: Tue, 25 Jun 2024 16:41:08 +0200 Subject: [PATCH 03/12] [NOJIRA] remove distutils --- tests/archive_test.py | 5 ----- tests/backup_test.py | 12 +++++------- tests/helpers/ptrack_helpers.py | 27 ++++++++++++--------------- tests/replica_test.py | 9 --------- tests/retention_test.py | 1 - 5 files changed, 17 insertions(+), 37 deletions(-) diff --git a/tests/archive_test.py b/tests/archive_test.py index 00fd1f592..9bd37aa55 100644 --- a/tests/archive_test.py +++ b/tests/archive_test.py @@ -8,7 +8,6 @@ import subprocess from sys import exit from time import sleep -from distutils.dir_util import copy_tree class ArchiveTest(ProbackupTest, unittest.TestCase): @@ -1243,10 +1242,6 @@ def test_archive_catalog(self): self.add_instance(backup_dir, 'replica', replica) self.set_archiving(backup_dir, 'replica', replica, replica=True) - copy_tree( - os.path.join(backup_dir, 'wal', 'master'), - os.path.join(backup_dir, 'wal', 'replica')) - replica.slow_start(replica=True) # FULL backup replica diff --git a/tests/backup_test.py b/tests/backup_test.py index dc60228b5..5ec6f1c6e 100644 --- a/tests/backup_test.py +++ b/tests/backup_test.py @@ -4,7 +4,6 @@ from time import sleep, time from .helpers.ptrack_helpers import base36enc, ProbackupTest, ProbackupException import shutil -from distutils.dir_util import copy_tree from testgres import ProcessType, QueryException import subprocess @@ -2330,14 +2329,13 @@ def test_backup_with_less_privileges_role(self): # bgwriter_pid = node.auxiliary_pids[ProcessType.BackgroundWriter][0] # gdb_checkpointer = self.gdb_attach(bgwriter_pid) - copy_tree( - os.path.join(backup_dir, 'wal', 'node'), - os.path.join(backup_dir, 'wal', 'replica')) - replica.slow_start(replica=True) - # self.switch_wal_segment(node) - # self.switch_wal_segment(node) + # make sure replica will archive wal segment with backup start point + lsn = self.switch_wal_segment(node, and_tx=True) + replica.poll_query_until(f"select pg_last_wal_replay_lsn() >= '{lsn}'") + replica.execute('CHECKPOINT') + replica.poll_query_until(f"select redo_lsn >= '{lsn}' from pg_control_checkpoint()") self.backup_node( backup_dir, 'replica', replica, diff --git a/tests/helpers/ptrack_helpers.py b/tests/helpers/ptrack_helpers.py index 27d982856..2420be462 100644 --- a/tests/helpers/ptrack_helpers.py +++ b/tests/helpers/ptrack_helpers.py @@ -1701,29 +1701,26 @@ def version_to_num(self, version): num = num * 100 + int(re.sub(r"[^\d]", "", part)) return num - def switch_wal_segment(self, node): + def switch_wal_segment(self, node, sleep_seconds=1, and_tx=False): """ - Execute pg_switch_wal/xlog() in given node + Execute pg_switch_wal() in given node Args: node: an instance of PostgresNode or NodeConnection class """ if isinstance(node, testgres.PostgresNode): - if self.version_to_num( - node.safe_psql('postgres', 'show server_version').decode('utf-8') - ) >= self.version_to_num('10.0'): - node.safe_psql('postgres', 'select pg_switch_wal()') - else: - node.safe_psql('postgres', 'select pg_switch_xlog()') + with node.connect('postgres') as con: + if and_tx: + con.execute('select txid_current()') + con.execute('select pg_switch_wal()') + lsn = con.execute('select pg_switch_wal()')[0][0] else: - if self.version_to_num( - node.execute('show server_version')[0][0] - ) >= self.version_to_num('10.0'): - node.execute('select pg_switch_wal()') - else: - node.execute('select pg_switch_xlog()') + node.execute('select pg_switch_wal()') + lsn = node.execute('select pg_switch_wal()')[0][0] - sleep(1) + if sleep_seconds > 0: + sleep(sleep_seconds) + return lsn def wait_until_replica_catch_with_master(self, master, replica): diff --git a/tests/replica_test.py b/tests/replica_test.py index 17fc5a823..e96e0dfa7 100644 --- a/tests/replica_test.py +++ b/tests/replica_test.py @@ -4,7 +4,6 @@ from datetime import datetime, timedelta import subprocess import time -from distutils.dir_util import copy_tree from testgres import ProcessType from time import sleep @@ -718,10 +717,6 @@ def test_replica_stop_lsn_null_offset_next_record(self): self.set_replica(master, replica, synchronous=True) self.set_archiving(backup_dir, 'replica', replica, replica=True) - copy_tree( - os.path.join(backup_dir, 'wal', 'master'), - os.path.join(backup_dir, 'wal', 'replica')) - replica.slow_start(replica=True) self.switch_wal_segment(master) @@ -980,10 +975,6 @@ def test_replica_toast(self): self.set_replica(master, replica, synchronous=True) self.set_archiving(backup_dir, 'replica', replica, replica=True) - copy_tree( - os.path.join(backup_dir, 'wal', 'master'), - os.path.join(backup_dir, 'wal', 'replica')) - replica.slow_start(replica=True) self.switch_wal_segment(master) diff --git a/tests/retention_test.py b/tests/retention_test.py index 88432a00f..cf422fe04 100644 --- a/tests/retention_test.py +++ b/tests/retention_test.py @@ -3,7 +3,6 @@ from datetime import datetime, timedelta from .helpers.ptrack_helpers import ProbackupTest, ProbackupException from time import sleep -from distutils.dir_util import copy_tree class RetentionTest(ProbackupTest, unittest.TestCase): From 98863ae0cdf1b5e7a10a9cb65db5d417527a8761 Mon Sep 17 00:00:00 2001 From: Stepan Neretin Date: Wed, 24 Jul 2024 22:45:44 +0700 Subject: [PATCH 04/12] [PBCKP-1238] Warning when using the community Version of pg_pro backup 2 for ENT - Call check_version in add_instance subcmd to get correct error --- src/backup.c | 3 +-- src/pg_probackup.c | 8 +++++++- src/pg_probackup.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/backup.c b/src/backup.c index 78c3512e9..ae2fada25 100644 --- a/src/backup.c +++ b/src/backup.c @@ -66,7 +66,6 @@ static bool pgpro_support(PGconn *conn); static bool pg_is_checksum_enabled(PGconn *conn); static bool pg_is_in_recovery(PGconn *conn); static bool pg_is_superuser(PGconn *conn); -static void check_server_version(PGconn *conn, PGNodeInfo *nodeInfo); static void confirm_block_size(PGconn *conn, const char *name, int blcksz); static void rewind_and_mark_cfs_datafiles(parray *files, const char *root, char *relative, size_t i); static bool remove_excluded_files_criterion(void *value, void *exclude_args); @@ -947,7 +946,7 @@ do_backup(InstanceState *instanceState, pgSetBackupParams *set_backup_params, /* * Confirm that this server version is supported */ -static void +void check_server_version(PGconn *conn, PGNodeInfo *nodeInfo) { PGresult *res = NULL; diff --git a/src/pg_probackup.c b/src/pg_probackup.c index fa67ddff5..1e5e65b1b 100644 --- a/src/pg_probackup.c +++ b/src/pg_probackup.c @@ -980,7 +980,13 @@ main(int argc, char *argv[]) wal_file_path, wal_file_name, batch_size, !no_validate_wal); break; case ADD_INSTANCE_CMD: - return do_add_instance(instanceState, &instance_config); + { + PGNodeInfo nodeInfo; + pgNodeInit(&nodeInfo); + instanceState->conn = pgut_connect(dbhost, dbport, dbname, dbuser); + check_server_version(instanceState->conn, &nodeInfo); + return do_add_instance(instanceState, &instance_config); + } case DELETE_INSTANCE_CMD: return do_delete_instance(instanceState); case INIT_CMD: diff --git a/src/pg_probackup.h b/src/pg_probackup.h index ae99e0605..495b895f6 100644 --- a/src/pg_probackup.h +++ b/src/pg_probackup.h @@ -1225,6 +1225,7 @@ extern const char *base36enc_to(long unsigned int value, char buf[ARG_SIZE_HINT extern long unsigned int base36dec(const char *text); extern uint32 parse_server_version(const char *server_version_str); extern uint32 parse_program_version(const char *program_version); +void check_server_version(PGconn *conn, PGNodeInfo *nodeInfo); extern bool parse_page(Page page, XLogRecPtr *lsn); extern int32 do_compress(void* dst, size_t dst_size, void const* src, size_t src_size, CompressAlg alg, int level, const char **errormsg); From dc7d38132d6fb863a6acc3c2a8971f0b73fe4fe3 Mon Sep 17 00:00:00 2001 From: Alexey Savchkov Date: Fri, 11 Oct 2024 10:28:12 +0700 Subject: [PATCH 05/12] Trim the minor ALT Linux versions in the installation instructions --- doc/pgprobackup.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/pgprobackup.xml b/doc/pgprobackup.xml index 10e766239..4f05da26a 100644 --- a/doc/pgprobackup.xml +++ b/doc/pgprobackup.xml @@ -924,7 +924,7 @@ yumdownloader --source pg_probackup-16 . /etc/os-release -echo "rpm http://repo.postgrespro.ru/pg_probackup/rpm/latest/altlinux-p$VERSION_ID x86_64 vanilla" | \ +echo "rpm http://repo.postgrespro.ru/pg_probackup/rpm/latest/altlinux-p${VERSION_ID%%.*} x86_64 vanilla" | \ sudo tee /etc/apt/sources.list.d/pg_probackup.list @@ -934,7 +934,7 @@ sudo tee /etc/apt/sources.list.d/pg_probackup.list . /etc/os-release -echo "rpm http://repo.postgrespro.ru/pg_probackup/rpm/latest/altlinux-$VERSION_ID x86_64 vanilla" | \ +echo "rpm http://repo.postgrespro.ru/pg_probackup/rpm/latest/altlinux-${VERSION_ID%%.*} x86_64 vanilla" | \ sudo tee /etc/apt/sources.list.d/pg_probackup.list From 556a4f0c0a05e7d828026bff2784db4eb2b997bc Mon Sep 17 00:00:00 2001 From: Daria Lepikhova Date: Sat, 18 Jan 2025 16:37:39 +0700 Subject: [PATCH 06/12] PBCKP-1527: Update copyrights to 2025 --- LICENSE | 2 +- README.md | 8 ++++---- src/archive.c | 2 +- src/backup.c | 2 +- src/catalog.c | 2 +- src/catchup.c | 2 +- src/checkdb.c | 2 +- src/configure.c | 2 +- src/data.c | 2 +- src/datapagemap.c | 2 +- src/delete.c | 2 +- src/dir.c | 2 +- src/help.c | 2 +- src/init.c | 2 +- src/merge.c | 2 +- src/parsexlog.c | 2 +- src/pg_probackup.c | 2 +- src/pg_probackup.h | 2 +- src/pg_probackup_state.h | 2 +- src/ptrack.c | 2 +- src/restore.c | 2 +- src/show.c | 2 +- src/stream.c | 2 +- src/util.c | 2 +- src/utils/configuration.c | 2 +- src/utils/configuration.h | 2 +- src/utils/json.c | 2 +- src/utils/json.h | 2 +- src/utils/logger.c | 2 +- src/utils/logger.h | 2 +- src/utils/pgut.c | 2 +- src/utils/pgut.h | 2 +- src/utils/remote.h | 2 +- src/utils/thread.c | 2 +- src/utils/thread.h | 2 +- src/validate.c | 2 +- 36 files changed, 39 insertions(+), 39 deletions(-) diff --git a/LICENSE b/LICENSE index 66476e8a9..4fed760f8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2015-2023, Postgres Professional +Copyright (c) 2015-2025, Postgres Professional Portions Copyright (c) 2009-2013, NIPPON TELEGRAPH AND TELEPHONE CORPORATION Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group diff --git a/README.md b/README.md index 2279b97a4..4e235a54a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ `pg_probackup` is a utility to manage backup and recovery of PostgreSQL database clusters. It is designed to perform periodic backups of the PostgreSQL instance that enable you to restore the server in case of a failure. The utility is compatible with: -* PostgreSQL 11, 12, 13, 14, 15, 16 +* PostgreSQL 11, 12, 13, 14, 15, 16, 17 As compared to other backup solutions, `pg_probackup` offers the following benefits that can help you implement different backup strategies and deal with large amounts of data: * Incremental backup: page-level incremental backup allows you to save disk space, speed up backup and restore. With three different incremental modes, you can plan the backup strategy in accordance with your data flow. @@ -41,9 +41,9 @@ Regardless of the chosen backup type, all backups taken with `pg_probackup` supp ## ptrack support `PTRACK` backup support provided via following options: -* vanilla PostgreSQL 11, 12, 13, 14, 15, 16 with [ptrack extension](https://github.com/postgrespro/ptrack) -* Postgres Pro Standard 11, 12, 13, 14, 15, 16 -* Postgres Pro Enterprise 11, 12, 13, 14, 15, 16 +* vanilla PostgreSQL 11, 12, 13, 14, 15, 16, 17 with [ptrack extension](https://github.com/postgrespro/ptrack) +* Postgres Pro Standard 11, 12, 13, 14, 15, 16, 17 +* Postgres Pro Enterprise 11, 12, 13, 14, 15, 16, 17 ## Limitations diff --git a/src/archive.c b/src/archive.c index 7d753c8b3..b1c4ea347 100644 --- a/src/archive.c +++ b/src/archive.c @@ -3,7 +3,7 @@ * archive.c: - pg_probackup specific archive commands for archive backups. * * - * Portions Copyright (c) 2018-2022, Postgres Professional + * Portions Copyright (c) 2018-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/backup.c b/src/backup.c index ae2fada25..76b2b8a5d 100644 --- a/src/backup.c +++ b/src/backup.c @@ -3,7 +3,7 @@ * backup.c: backup DB cluster, archived WAL * * Portions Copyright (c) 2009-2013, NIPPON TELEGRAPH AND TELEPHONE CORPORATION - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/catalog.c b/src/catalog.c index b29090789..3ec6da97c 100644 --- a/src/catalog.c +++ b/src/catalog.c @@ -3,7 +3,7 @@ * catalog.c: backup catalog operation * * Portions Copyright (c) 2009-2011, NIPPON TELEGRAPH AND TELEPHONE CORPORATION - * Portions Copyright (c) 2015-2019, Postgres Professional + * Portions Copyright (c) 2015-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/catchup.c b/src/catchup.c index 00752b194..39fd37d26 100644 --- a/src/catchup.c +++ b/src/catchup.c @@ -2,7 +2,7 @@ * * catchup.c: sync DB cluster * - * Copyright (c) 2021-2022, Postgres Professional + * Copyright (c) 2021-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/checkdb.c b/src/checkdb.c index 2a7d4e9eb..24c80657e 100644 --- a/src/checkdb.c +++ b/src/checkdb.c @@ -9,7 +9,7 @@ * instance can be logically verified using extensions * amcheck or amcheck_next. * - * Portions Copyright (c) 2019-2019, Postgres Professional + * Portions Copyright (c) 2019-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/configure.c b/src/configure.c index 964548343..59f164fa9 100644 --- a/src/configure.c +++ b/src/configure.c @@ -2,7 +2,7 @@ * * configure.c: - manage backup catalog. * - * Copyright (c) 2017-2019, Postgres Professional + * Copyright (c) 2017-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/data.c b/src/data.c index 1a9616bae..d88b06b62 100644 --- a/src/data.c +++ b/src/data.c @@ -3,7 +3,7 @@ * data.c: utils to parse and backup data pages * * Portions Copyright (c) 2009-2013, NIPPON TELEGRAPH AND TELEPHONE CORPORATION - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/datapagemap.c b/src/datapagemap.c index 7e4202a72..49ce91334 100644 --- a/src/datapagemap.c +++ b/src/datapagemap.c @@ -5,7 +5,7 @@ * * This is a fairly simple bitmap. * - * Copyright (c) 2013-2019, PostgreSQL Global Development Group + * Copyright (c) 2013-2025, PostgreSQL Global Development Group * *------------------------------------------------------------------------- */ diff --git a/src/delete.c b/src/delete.c index f48ecc95f..1c628e04f 100644 --- a/src/delete.c +++ b/src/delete.c @@ -3,7 +3,7 @@ * delete.c: delete backup files. * * Portions Copyright (c) 2009-2013, NIPPON TELEGRAPH AND TELEPHONE CORPORATION - * Portions Copyright (c) 2015-2019, Postgres Professional + * Portions Copyright (c) 2015-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/dir.c b/src/dir.c index 4b1bc2816..a5bde57f3 100644 --- a/src/dir.c +++ b/src/dir.c @@ -3,7 +3,7 @@ * dir.c: directory operation utility. * * Portions Copyright (c) 2009-2013, NIPPON TELEGRAPH AND TELEPHONE CORPORATION - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/help.c b/src/help.c index e18706a13..eacef9a48 100644 --- a/src/help.c +++ b/src/help.c @@ -2,7 +2,7 @@ * * help.c * - * Copyright (c) 2017-2021, Postgres Professional + * Copyright (c) 2017-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/init.c b/src/init.c index 837e2bad0..6afb5706c 100644 --- a/src/init.c +++ b/src/init.c @@ -3,7 +3,7 @@ * init.c: - initialize backup catalog. * * Portions Copyright (c) 2009-2011, NIPPON TELEGRAPH AND TELEPHONE CORPORATION - * Portions Copyright (c) 2015-2019, Postgres Professional + * Portions Copyright (c) 2015-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/merge.c b/src/merge.c index e8f926795..3692fee8a 100644 --- a/src/merge.c +++ b/src/merge.c @@ -2,7 +2,7 @@ * * merge.c: merge FULL and incremental backups * - * Copyright (c) 2018-2022, Postgres Professional + * Copyright (c) 2018-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/parsexlog.c b/src/parsexlog.c index 7df169fbf..3dd591e52 100644 --- a/src/parsexlog.c +++ b/src/parsexlog.c @@ -5,7 +5,7 @@ * * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California - * Portions Copyright (c) 2015-2019, Postgres Professional + * Portions Copyright (c) 2015-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/pg_probackup.c b/src/pg_probackup.c index 1e5e65b1b..b72efa93a 100644 --- a/src/pg_probackup.c +++ b/src/pg_probackup.c @@ -35,7 +35,7 @@ * which includes info about pgdata directory and connection. * * Portions Copyright (c) 2009-2013, NIPPON TELEGRAPH AND TELEPHONE CORPORATION - * Portions Copyright (c) 2015-2021, Postgres Professional + * Portions Copyright (c) 2015-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/pg_probackup.h b/src/pg_probackup.h index 495b895f6..175aa5589 100644 --- a/src/pg_probackup.h +++ b/src/pg_probackup.h @@ -3,7 +3,7 @@ * pg_probackup.h: Backup/Recovery manager for PostgreSQL. * * Portions Copyright (c) 2009-2013, NIPPON TELEGRAPH AND TELEPHONE CORPORATION - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/pg_probackup_state.h b/src/pg_probackup_state.h index 56d852537..a1b221f46 100644 --- a/src/pg_probackup_state.h +++ b/src/pg_probackup_state.h @@ -2,7 +2,7 @@ * * pg_probackup_state.h: Definitions of internal pg_probackup states * - * Portions Copyright (c) 2021, Postgres Professional + * Portions Copyright (c) 2021-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/ptrack.c b/src/ptrack.c index d27629e45..ba97088c1 100644 --- a/src/ptrack.c +++ b/src/ptrack.c @@ -2,7 +2,7 @@ * * ptrack.c: support functions for ptrack backups * - * Copyright (c) 2021 Postgres Professional + * Copyright (c) 2021-2025 Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/restore.c b/src/restore.c index f9310dcee..0be151a99 100644 --- a/src/restore.c +++ b/src/restore.c @@ -3,7 +3,7 @@ * restore.c: restore DB cluster and archived WAL. * * Portions Copyright (c) 2009-2013, NIPPON TELEGRAPH AND TELEPHONE CORPORATION - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/show.c b/src/show.c index 810262df6..0732c6a7a 100644 --- a/src/show.c +++ b/src/show.c @@ -3,7 +3,7 @@ * show.c: show backup information. * * Portions Copyright (c) 2009-2011, NIPPON TELEGRAPH AND TELEPHONE CORPORATION - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/stream.c b/src/stream.c index 77453e997..d94c9564e 100644 --- a/src/stream.c +++ b/src/stream.c @@ -2,7 +2,7 @@ * * stream.c: pg_probackup specific code for WAL streaming * - * Portions Copyright (c) 2015-2020, Postgres Professional + * Portions Copyright (c) 2015-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/util.c b/src/util.c index 3c0a33453..019d20644 100644 --- a/src/util.c +++ b/src/util.c @@ -3,7 +3,7 @@ * util.c: log messages to log file or stderr, and misc code. * * Portions Copyright (c) 2009-2011, NIPPON TELEGRAPH AND TELEPHONE CORPORATION - * Portions Copyright (c) 2015-2021, Postgres Professional + * Portions Copyright (c) 2015-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/utils/configuration.c b/src/utils/configuration.c index f049aa1be..47497850f 100644 --- a/src/utils/configuration.c +++ b/src/utils/configuration.c @@ -3,7 +3,7 @@ * configuration.c: - function implementations to work with pg_probackup * configurations. * - * Copyright (c) 2017-2019, Postgres Professional + * Copyright (c) 2017-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/utils/configuration.h b/src/utils/configuration.h index 59da29bd5..da86b9db0 100644 --- a/src/utils/configuration.h +++ b/src/utils/configuration.h @@ -3,7 +3,7 @@ * configuration.h: - prototypes of functions and structures for * configuration. * - * Copyright (c) 2018-2019, Postgres Professional + * Copyright (c) 2018-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/utils/json.c b/src/utils/json.c index 2c8e0fe9b..1bcb4e644 100644 --- a/src/utils/json.c +++ b/src/utils/json.c @@ -2,7 +2,7 @@ * * json.c: - make json document. * - * Copyright (c) 2018-2019, Postgres Professional + * Copyright (c) 2018-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/utils/json.h b/src/utils/json.h index f80832e69..f635e1f3c 100644 --- a/src/utils/json.h +++ b/src/utils/json.h @@ -2,7 +2,7 @@ * * json.h: - prototypes of json output functions. * - * Copyright (c) 2018-2019, Postgres Professional + * Copyright (c) 2018-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/utils/logger.c b/src/utils/logger.c index 7ea41f74e..ade57e529 100644 --- a/src/utils/logger.c +++ b/src/utils/logger.c @@ -2,7 +2,7 @@ * * logger.c: - log events into log file or stderr. * - * Copyright (c) 2017-2019, Postgres Professional + * Copyright (c) 2017-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/utils/logger.h b/src/utils/logger.h index adc5061e0..9e2cb958f 100644 --- a/src/utils/logger.h +++ b/src/utils/logger.h @@ -2,7 +2,7 @@ * * logger.h: - prototypes of logger functions. * - * Copyright (c) 2017-2019, Postgres Professional + * Copyright (c) 2017-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/utils/pgut.c b/src/utils/pgut.c index 9559fa644..df09dbdc6 100644 --- a/src/utils/pgut.c +++ b/src/utils/pgut.c @@ -3,7 +3,7 @@ * pgut.c * * Portions Copyright (c) 2009-2013, NIPPON TELEGRAPH AND TELEPHONE CORPORATION - * Portions Copyright (c) 2017-2021, Postgres Professional + * Portions Copyright (c) 2017-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/utils/pgut.h b/src/utils/pgut.h index 1b7b7864c..6fea4d022 100644 --- a/src/utils/pgut.h +++ b/src/utils/pgut.h @@ -3,7 +3,7 @@ * pgut.h * * Portions Copyright (c) 2009-2013, NIPPON TELEGRAPH AND TELEPHONE CORPORATION - * Portions Copyright (c) 2017-2021, Postgres Professional + * Portions Copyright (c) 2017-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/utils/remote.h b/src/utils/remote.h index dc98644ab..582210142 100644 --- a/src/utils/remote.h +++ b/src/utils/remote.h @@ -2,7 +2,7 @@ * * remote.h: - prototypes of remote functions. * - * Copyright (c) 2017-2019, Postgres Professional + * Copyright (c) 2017-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/utils/thread.c b/src/utils/thread.c index 1c469bd29..4127701f0 100644 --- a/src/utils/thread.c +++ b/src/utils/thread.c @@ -2,7 +2,7 @@ * * thread.c: - multi-platform pthread implementations. * - * Copyright (c) 2018-2019, Postgres Professional + * Copyright (c) 2018-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/utils/thread.h b/src/utils/thread.h index 2eaa5fb45..d79e2d8d0 100644 --- a/src/utils/thread.h +++ b/src/utils/thread.h @@ -2,7 +2,7 @@ * * thread.h: - multi-platform pthread implementations. * - * Copyright (c) 2018-2019, Postgres Professional + * Copyright (c) 2018-2025, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/validate.c b/src/validate.c index 0887b2e7a..3bff3f756 100644 --- a/src/validate.c +++ b/src/validate.c @@ -3,7 +3,7 @@ * validate.c: validate backup files. * * Portions Copyright (c) 2009-2011, NIPPON TELEGRAPH AND TELEPHONE CORPORATION - * Portions Copyright (c) 2015-2019, Postgres Professional + * Portions Copyright (c) 2015-2025, Postgres Professional * *------------------------------------------------------------------------- */ From 99e11e9ae29391e0b12b4a89d2f9aa7f642240cd Mon Sep 17 00:00:00 2001 From: Daria Lepikhova Date: Tue, 21 Jan 2025 16:45:31 +0700 Subject: [PATCH 07/12] PBCKP-1527: Remove version 11 and 12 from README --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4e235a54a..16aec1dcc 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ `pg_probackup` is a utility to manage backup and recovery of PostgreSQL database clusters. It is designed to perform periodic backups of the PostgreSQL instance that enable you to restore the server in case of a failure. The utility is compatible with: -* PostgreSQL 11, 12, 13, 14, 15, 16, 17 +* PostgreSQL 13, 14, 15, 16, 17 As compared to other backup solutions, `pg_probackup` offers the following benefits that can help you implement different backup strategies and deal with large amounts of data: * Incremental backup: page-level incremental backup allows you to save disk space, speed up backup and restore. With three different incremental modes, you can plan the backup strategy in accordance with your data flow. @@ -41,9 +41,9 @@ Regardless of the chosen backup type, all backups taken with `pg_probackup` supp ## ptrack support `PTRACK` backup support provided via following options: -* vanilla PostgreSQL 11, 12, 13, 14, 15, 16, 17 with [ptrack extension](https://github.com/postgrespro/ptrack) -* Postgres Pro Standard 11, 12, 13, 14, 15, 16, 17 -* Postgres Pro Enterprise 11, 12, 13, 14, 15, 16, 17 +* vanilla PostgreSQL 13, 14, 15, 16, 17 with [ptrack extension](https://github.com/postgrespro/ptrack) +* Postgres Pro Standard 13, 14, 15, 16, 17 +* Postgres Pro Enterprise 13, 14, 15, 16, 17 ## Limitations From 8d83a90c9671c90f0b04e2366e8cff1101292de3 Mon Sep 17 00:00:00 2001 From: Viktoria Shepard Date: Tue, 16 Sep 2025 15:44:44 +0200 Subject: [PATCH 08/12] Edit requirements.txt Update testgres version --- tests/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/requirements.txt b/tests/requirements.txt index e2ac18bea..31e01aeb5 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -5,7 +5,7 @@ # git+https://github.com/postgrespro/testgres.git@ # 3. From a local directory # /path/to/local/directory/testgres -git+https://github.com/postgrespro/testgres.git@archive-command-exec#egg=testgres-pg_probackup2&subdirectory=testgres/plugins/pg_probackup2 +testgres==1.8.5 allure-pytest deprecation pexpect From b803c072a571296ff02f26548d8d46c7dbedc083 Mon Sep 17 00:00:00 2001 From: Alexey Savchkov Date: Tue, 7 Oct 2025 10:25:28 +0700 Subject: [PATCH 09/12] Add version.sh --- version.sh | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 version.sh diff --git a/version.sh b/version.sh new file mode 100755 index 000000000..0e271bcd4 --- /dev/null +++ b/version.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash + +# Output the program version based on the state of the repository (source code +# and tags). +# Tags must be in the form of +# x.y.z, e.g. 3.1.0 +# or +# x.y.z-, e.g. 3.1.0-beta2 +# If the tag consists only of the version number (i.e. it doesn't contain a +# prerelease part) and this number is equal to the version in the header file +# then the version is considered a release and no additional version data is +# appended to it by default (but can be forced by "-p" and "-r" command line +# arguments). Otherwise, provided Git is available, the prerelease part and Git +# revision are automatically added to the version. + +cd `dirname "$0"` + +while getopts p:r:sv: opt; do + case $opt in + p) prerelease=$OPTARG;; + r) revision=$OPTARG;; + s) ID=semver;; + v) version=$OPTARG;; + esac +done + +if [ -z "$ID" ]; then + . /etc/os-release +fi +case $ID in + altlinux | astra | debian | ubuntu) + # The only scheme that properly sorts metadata and prerelease fields is + # when the both are specified after a '~' + presep='~'; metasep='~';; + centos | opensuse-leap | redos) + presep='~'; metasep=^;; + *) # semver + presep=-; metasep=+ +esac + +if [ -z "$version" ]; then + version=`grep '#define PROGRAM_VERSION' src/pg_probackup.h | cut -f 2 | tr -d '"'` +fi + +if which git >/dev/null 2>&1; then + tag=`git describe --tags 2> /dev/null` + # Shallow cloned repository may not have tags + if [ -z "$prerelease" -a "$tag" ]; then + f1=`cut -d - -f 1 <<< $tag` + f2=`cut -d - -f 2 <<< $tag` + # Append the prerelease part only if the tag refers to the current version + # Assume that the prerelease part contains letters + if [ $f1 = $version ] && expr "$f2" : "[1-9]*[a-zA-Z]" 1>/dev/null; then + prerelease="$f2" + fi + fi + if [ -z "$revision" ]; then + revision=g`git rev-parse --short HEAD` + fi +fi + +out=$version${prerelease:+$presep$prerelease} +if [ "$tag" != $version -a "$revision" ]; then + out=$out$metasep`date +%Y%m%d`$revision +fi + +echo $out From 0148fa8defd1217848d3ad91d879e9e102bd8b9a Mon Sep 17 00:00:00 2001 From: Japin Li Date: Wed, 4 Jun 2025 16:15:15 +0800 Subject: [PATCH 10/12] Fix warning about shadows a previous local variable --- src/catalog.c | 102 +++++++++++++++++++++++------------------------ src/stream.c | 10 ++--- src/utils/file.c | 8 ++-- 3 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/catalog.c b/src/catalog.c index 3ec6da97c..409d9141f 100644 --- a/src/catalog.c +++ b/src/catalog.c @@ -1755,16 +1755,16 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance) for (i = 0; i < parray_num(timelineinfos); i++) { - timelineInfo *tlinfo = parray_get(timelineinfos, i); + timelineInfo *tlInfo = parray_get(timelineinfos, i); for (j = 0; j < parray_num(backups); j++) { pgBackup *backup = parray_get(backups, j); - if (tlinfo->tli == backup->tli) + if (tlInfo->tli == backup->tli) { - if (tlinfo->backups == NULL) - tlinfo->backups = parray_new(); + if (tlInfo->backups == NULL) + tlInfo->backups = parray_new(); - parray_append(tlinfo->backups, backup); + parray_append(tlInfo->backups, backup); } } } @@ -1772,10 +1772,10 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance) /* determine oldest backup and closest backup for every timeline */ for (i = 0; i < parray_num(timelineinfos); i++) { - timelineInfo *tlinfo = parray_get(timelineinfos, i); + timelineInfo *tlInfo = parray_get(timelineinfos, i); - tlinfo->oldest_backup = get_oldest_backup(tlinfo); - tlinfo->closest_backup = get_closest_backup(tlinfo); + tlInfo->oldest_backup = get_oldest_backup(tlInfo); + tlInfo->closest_backup = get_closest_backup(tlInfo); } /* determine which WAL segments must be kept because of wal retention */ @@ -1845,18 +1845,18 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance) for (i = 0; i < parray_num(timelineinfos); i++) { int count = 0; - timelineInfo *tlinfo = parray_get(timelineinfos, i); + timelineInfo *tlInfo = parray_get(timelineinfos, i); /* * Iterate backward on backups belonging to this timeline to find * anchor_backup. NOTE Here we rely on the fact that backups list * is ordered by start_lsn DESC. */ - if (tlinfo->backups) + if (tlInfo->backups) { - for (j = 0; j < parray_num(tlinfo->backups); j++) + for (j = 0; j < parray_num(tlInfo->backups); j++) { - pgBackup *backup = parray_get(tlinfo->backups, j); + pgBackup *backup = parray_get(tlInfo->backups, j); /* sanity */ if (XLogRecPtrIsInvalid(backup->start_lsn) || @@ -1886,12 +1886,12 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance) if (count == instance->wal_depth) { elog(LOG, "On timeline %i WAL is protected from purge at %X/%X", - tlinfo->tli, + tlInfo->tli, (uint32) (backup->start_lsn >> 32), (uint32) (backup->start_lsn)); - tlinfo->anchor_lsn = backup->start_lsn; - tlinfo->anchor_tli = backup->tli; + tlInfo->anchor_lsn = backup->start_lsn; + tlInfo->anchor_tli = backup->tli; break; } } @@ -1916,7 +1916,7 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance) * If closest_backup is not available, then general WAL purge rules * are applied. */ - if (XLogRecPtrIsInvalid(tlinfo->anchor_lsn)) + if (XLogRecPtrIsInvalid(tlInfo->anchor_lsn)) { /* * Failed to find anchor_lsn in our own timeline. @@ -1942,7 +1942,7 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance) xlogInterval *interval = NULL; TimeLineID tli = 0; /* check if tli has closest_backup */ - if (!tlinfo->closest_backup) + if (!tlInfo->closest_backup) /* timeline has no closest_backup, wal retention cannot be * applied to this timeline. * Timeline will be purged up to oldest_backup if any or @@ -1952,47 +1952,47 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance) continue; /* sanity for closest_backup */ - if (XLogRecPtrIsInvalid(tlinfo->closest_backup->start_lsn) || - tlinfo->closest_backup->tli <= 0) + if (XLogRecPtrIsInvalid(tlInfo->closest_backup->start_lsn) || + tlInfo->closest_backup->tli <= 0) continue; /* * Set anchor_lsn and anchor_tli to protect whole timeline from purge * In the example above: tli3. */ - tlinfo->anchor_lsn = tlinfo->closest_backup->start_lsn; - tlinfo->anchor_tli = tlinfo->closest_backup->tli; + tlInfo->anchor_lsn = tlInfo->closest_backup->start_lsn; + tlInfo->anchor_tli = tlInfo->closest_backup->tli; /* closest backup may be located not in parent timeline */ - closest_backup = tlinfo->closest_backup; + closest_backup = tlInfo->closest_backup; - tli = tlinfo->tli; + tli = tlInfo->tli; /* * Iterate over parent timeline chain and * look for timeline where closest_backup belong */ - while (tlinfo->parent_link) + while (tlInfo->parent_link) { /* In case of intermediate timeline save to keep_segments * begin_segno and switchpoint segment. * In case of final timelines save to keep_segments * closest_backup start_lsn segment and switchpoint segment. */ - XLogRecPtr switchpoint = tlinfo->switchpoint; + XLogRecPtr switchpoint = tlInfo->switchpoint; - tlinfo = tlinfo->parent_link; + tlInfo = tlInfo->parent_link; - if (tlinfo->keep_segments == NULL) - tlinfo->keep_segments = parray_new(); + if (tlInfo->keep_segments == NULL) + tlInfo->keep_segments = parray_new(); /* in any case, switchpoint segment must be added to interval */ interval = palloc(sizeof(xlogInterval)); GetXLogSegNo(switchpoint, interval->end_segno, instance->xlog_seg_size); /* Save [S1`, S2] to keep_segments */ - if (tlinfo->tli != closest_backup->tli) - interval->begin_segno = tlinfo->begin_segno; + if (tlInfo->tli != closest_backup->tli) + interval->begin_segno = tlInfo->begin_segno; /* Save [B1, S1] to keep_segments */ else GetXLogSegNo(closest_backup->start_lsn, interval->begin_segno, instance->xlog_seg_size); @@ -2002,27 +2002,27 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance) * covered by other larger interval. */ - GetXLogFileName(begin_segno_str, tlinfo->tli, interval->begin_segno, instance->xlog_seg_size); - GetXLogFileName(end_segno_str, tlinfo->tli, interval->end_segno, instance->xlog_seg_size); + GetXLogFileName(begin_segno_str, tlInfo->tli, interval->begin_segno, instance->xlog_seg_size); + GetXLogFileName(end_segno_str, tlInfo->tli, interval->end_segno, instance->xlog_seg_size); elog(LOG, "Timeline %i to stay reachable from timeline %i " "protect from purge WAL interval between " "%s and %s on timeline %i", tli, closest_backup->tli, begin_segno_str, - end_segno_str, tlinfo->tli); + end_segno_str, tlInfo->tli); - parray_append(tlinfo->keep_segments, interval); + parray_append(tlInfo->keep_segments, interval); continue; } continue; } /* Iterate over backups left */ - for (j = count; j < parray_num(tlinfo->backups); j++) + for (j = count; j < parray_num(tlInfo->backups); j++) { XLogSegNo segno = 0; xlogInterval *interval = NULL; - pgBackup *backup = parray_get(tlinfo->backups, j); + pgBackup *backup = parray_get(tlInfo->backups, j); /* * We must calculate keep_segments intervals for ARCHIVE backups @@ -2039,7 +2039,7 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance) continue; /* no point in clogging keep_segments by backups protected by anchor_lsn */ - if (backup->start_lsn >= tlinfo->anchor_lsn) + if (backup->start_lsn >= tlInfo->anchor_lsn) continue; /* append interval to keep_segments */ @@ -2057,8 +2057,8 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance) else interval->end_segno = segno; - GetXLogFileName(begin_segno_str, tlinfo->tli, interval->begin_segno, instance->xlog_seg_size); - GetXLogFileName(end_segno_str, tlinfo->tli, interval->end_segno, instance->xlog_seg_size); + GetXLogFileName(begin_segno_str, tlInfo->tli, interval->begin_segno, instance->xlog_seg_size); + GetXLogFileName(end_segno_str, tlInfo->tli, interval->end_segno, instance->xlog_seg_size); elog(LOG, "Archive backup %s to stay consistent " "protect from purge WAL interval " @@ -2066,10 +2066,10 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance) backup_id_of(backup), begin_segno_str, end_segno_str, backup->tli); - if (tlinfo->keep_segments == NULL) - tlinfo->keep_segments = parray_new(); + if (tlInfo->keep_segments == NULL) + tlInfo->keep_segments = parray_new(); - parray_append(tlinfo->keep_segments, interval); + parray_append(tlInfo->keep_segments, interval); } } @@ -2081,27 +2081,27 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance) for (i = 0; i < parray_num(timelineinfos); i++) { XLogSegNo anchor_segno = 0; - timelineInfo *tlinfo = parray_get(timelineinfos, i); + timelineInfo *tlInfo = parray_get(timelineinfos, i); /* * At this point invalid anchor_lsn can be only in one case: * timeline is going to be purged by regular WAL purge rules. */ - if (XLogRecPtrIsInvalid(tlinfo->anchor_lsn)) + if (XLogRecPtrIsInvalid(tlInfo->anchor_lsn)) continue; /* * anchor_lsn is located in another timeline, it means that the timeline * will be protected from purge entirely. */ - if (tlinfo->anchor_tli > 0 && tlinfo->anchor_tli != tlinfo->tli) + if (tlInfo->anchor_tli > 0 && tlInfo->anchor_tli != tlInfo->tli) continue; - GetXLogSegNo(tlinfo->anchor_lsn, anchor_segno, instance->xlog_seg_size); + GetXLogSegNo(tlInfo->anchor_lsn, anchor_segno, instance->xlog_seg_size); - for (j = 0; j < parray_num(tlinfo->xlog_filelist); j++) + for (j = 0; j < parray_num(tlInfo->xlog_filelist); j++) { - xlogFile *wal_file = (xlogFile *) parray_get(tlinfo->xlog_filelist, j); + xlogFile *wal_file = (xlogFile *) parray_get(tlInfo->xlog_filelist, j); if (wal_file->segno >= anchor_segno) { @@ -2110,13 +2110,13 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance) } /* no keep segments */ - if (!tlinfo->keep_segments) + if (!tlInfo->keep_segments) continue; /* Protect segments belonging to one of the keep invervals */ - for (k = 0; k < parray_num(tlinfo->keep_segments); k++) + for (k = 0; k < parray_num(tlInfo->keep_segments); k++) { - xlogInterval *keep_segments = (xlogInterval *) parray_get(tlinfo->keep_segments, k); + xlogInterval *keep_segments = (xlogInterval *) parray_get(tlInfo->keep_segments, k); if ((wal_file->segno >= keep_segments->begin_segno) && wal_file->segno <= keep_segments->end_segno) diff --git a/src/stream.c b/src/stream.c index d94c9564e..25429f9a7 100644 --- a/src/stream.c +++ b/src/stream.c @@ -592,7 +592,7 @@ parse_tli_history_buffer(char *history, TimeLineID tli) if (curLineLen > 0) { char *ptr; - TimeLineID tli; + TimeLineID currTLI; uint32 switchpoint_hi; uint32 switchpoint_lo; int nfields; @@ -605,7 +605,7 @@ parse_tli_history_buffer(char *history, TimeLineID tli) if (*ptr == '\0' || *ptr == '#') continue; - nfields = sscanf(tempStr, "%u\t%X/%X", &tli, &switchpoint_hi, &switchpoint_lo); + nfields = sscanf(tempStr, "%u\t%X/%X", &currTLI, &switchpoint_hi, &switchpoint_lo); if (nfields < 1) { @@ -615,11 +615,11 @@ parse_tli_history_buffer(char *history, TimeLineID tli) if (nfields != 3) elog(ERROR, "Syntax error in timeline history: \"%s\". Expected a transaction log switchpoint location.", tempStr); - if (last_timeline && tli <= last_timeline->tli) + if (last_timeline && currTLI <= last_timeline->tli) elog(ERROR, "Timeline IDs must be in increasing sequence: \"%s\"", tempStr); entry = pgut_new(TimeLineHistoryEntry); - entry->tli = tli; + entry->tli = currTLI; entry->end = ((uint64) switchpoint_hi << 32) | switchpoint_lo; last_timeline = entry; @@ -628,7 +628,7 @@ parse_tli_history_buffer(char *history, TimeLineID tli) result = parray_new(); parray_append(result, entry); elog(VERBOSE, "parse_tli_history_buffer() found entry: tli = %X, end = %X/%X", - tli, switchpoint_hi, switchpoint_lo); + currTLI, switchpoint_hi, switchpoint_lo); /* we ignore the remainder of each line */ } diff --git a/src/utils/file.c b/src/utils/file.c index fa08939f5..b49c97d0c 100644 --- a/src/utils/file.c +++ b/src/utils/file.c @@ -2499,7 +2499,7 @@ fio_send_pages_impl(int out, char* buf) int fio_send_file_gz(const char *from_fullpath, FILE* out, char **errormsg) { - fio_header hdr; + fio_header header; int exit_code = SEND_OK; char *in_buf = pgut_malloc(CHUNK_SIZE); /* buffer for compressed data */ char *out_buf = pgut_malloc(OUT_BUF_SIZE); /* 1MB buffer for decompressed data */ @@ -2507,13 +2507,13 @@ fio_send_file_gz(const char *from_fullpath, FILE* out, char **errormsg) /* decompressor */ z_stream *strm = NULL; - hdr.cop = FIO_SEND_FILE; - hdr.size = path_len; + header.cop = FIO_SEND_FILE; + header.size = path_len; // elog(VERBOSE, "Thread [%d]: Attempting to open remote compressed WAL file '%s'", // thread_num, from_fullpath); - IO_CHECK(fio_write_all(fio_stdout, &hdr, sizeof(hdr)), sizeof(hdr)); + IO_CHECK(fio_write_all(fio_stdout, &header, sizeof(header)), sizeof(header)); IO_CHECK(fio_write_all(fio_stdout, from_fullpath, path_len), path_len); for (;;) From 7874bc45dc7582bb42ce8b10917e27cb486b94ee Mon Sep 17 00:00:00 2001 From: Japin Li Date: Wed, 4 Jun 2025 16:20:13 +0800 Subject: [PATCH 11/12] Fix warning about mixed declarations and code --- src/backup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backup.c b/src/backup.c index 76b2b8a5d..e1ebdb2c7 100644 --- a/src/backup.c +++ b/src/backup.c @@ -505,12 +505,12 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn, /* copy pg_control at very end */ if (backup_isok) { + char from_fullpath[MAXPGPATH]; + char to_fullpath[MAXPGPATH]; elog(progress ? INFO : LOG, "Progress: Backup file \"%s\"", src_pg_control_file->rel_path); - char from_fullpath[MAXPGPATH]; - char to_fullpath[MAXPGPATH]; join_path_components(from_fullpath, instance_config.pgdata, src_pg_control_file->rel_path); join_path_components(to_fullpath, current.database_dir, src_pg_control_file->rel_path); From 4c841052197f96dc4b9c7b8b9a56d96bd64ebe66 Mon Sep 17 00:00:00 2001 From: Japin Li Date: Wed, 4 Jun 2025 16:56:08 +0800 Subject: [PATCH 12/12] Fix warning about no previous declaration --- src/pg_probackup.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/pg_probackup.h b/src/pg_probackup.h index 175aa5589..9ae66a3a2 100644 --- a/src/pg_probackup.h +++ b/src/pg_probackup.h @@ -431,6 +431,8 @@ typedef struct InstanceConfig extern ConfigOption instance_options[]; extern InstanceConfig instance_config; extern time_t current_time; +extern bool no_validate; +extern IncrRestoreMode incremental_mode; typedef struct PGNodeInfo { @@ -805,9 +807,12 @@ extern pid_t my_pid; extern __thread int my_thread_num; extern int num_threads; extern bool stream_wal; +extern bool no_color; extern bool show_color; extern bool progress; +extern bool no_sync; extern bool is_archive_cmd; /* true for archive-{get,push} */ +extern time_t start_time; /* In pre-10 'replication_slot' is defined in receivelog.h */ extern char *replication_slot; #if PG_VERSION_NUM >= 100000 @@ -816,6 +821,7 @@ extern bool temp_slot; extern bool perm_slot; /* backup options */ +extern bool backup_logs; extern bool smooth_checkpoint; /* remote probackup options */ @@ -827,8 +833,15 @@ extern bool exclusive_backup; extern bool delete_wal; extern bool delete_expired; extern bool merge_expired; +extern bool force; extern bool dry_run; +/* archive push options */ +extern int batch_size; + +/* archive get options */ +extern bool no_validate_wal; + /* ===== instanceState ===== */ typedef struct InstanceState @@ -858,11 +871,18 @@ typedef struct InstanceState /* show options */ extern ShowFormat show_format; +extern bool show_archive; + +/* set backup options */ +extern int64 ttl; /* checkdb options */ +extern bool need_amcheck; extern bool heapallindexed; extern bool checkunique; +extern bool amcheck_parent; extern bool skip_block_validation; +extern bool skip_external_dirs; /* current settings */ extern pgBackup current;