From a46b23afc919bfa0d0aa9bdad962b95a3ae407ec Mon Sep 17 00:00:00 2001 From: Laurenz Albe Date: Sat, 20 Jul 2024 00:05:26 +0200 Subject: [PATCH v1] Add documentation and hint for incremental backup on standbys Taking an incremental backup on a streaming replication standby immediately after a base backup can result in the error manifest requires WAL from final timeline n ending at XXX, but this backup starts at YYY This message looks scary, even though the only problem is that the backup would be empty and thus it makes no sense to take it anyway. Add a clarifying errhint and some documentation to mitigate the problem. Author: Laurenz Albe Reviewed-by: Robert Haas, David Steele Discussion: https://postgr.es/m/04f4277e5ed4046773e46837110bed1381a2583f.camel@cybertec.at Backpatch to v17. --- doc/src/sgml/backup.sgml | 9 +++++++++ src/backend/backup/basebackup_incremental.c | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/backup.sgml b/doc/src/sgml/backup.sgml index 91da3c26ba..0f84ebc36e 100644 --- a/doc/src/sgml/backup.sgml +++ b/doc/src/sgml/backup.sgml @@ -925,6 +925,15 @@ test ! -f /mnt/server/archivedir/00000001000000A900000065 && cp pg_wal/0 to manage. For a large database all of which is heavily modified, incremental backups won't be much smaller than full backups. + + + Like a base backup, you can take an incremental backup from a streaming + replication standby server. But since a backup of a standby server cannot + initiate a checkpoint, it is possible that an incremental backup taken + right after a base backup will fail with an error, since it would have + to start with the same checkpoint as the base backup and would therefore + be empty. + diff --git a/src/backend/backup/basebackup_incremental.c b/src/backend/backup/basebackup_incremental.c index 2108702397..85c16182a6 100644 --- a/src/backend/backup/basebackup_incremental.c +++ b/src/backend/backup/basebackup_incremental.c @@ -441,7 +441,8 @@ PrepareForIncrementalBackup(IncrementalBackupInfo *ib, errmsg("manifest requires WAL from final timeline %u ending at %X/%X, but this backup starts at %X/%X", range->tli, LSN_FORMAT_ARGS(range->end_lsn), - LSN_FORMAT_ARGS(backup_state->startpoint)))); + LSN_FORMAT_ARGS(backup_state->startpoint)), + errhint("Perhaps there was too little activity since the previous backup, and this incremental backup would be empty."))); } else { -- 2.45.2