Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6a79870

Browse files
author
Artur Zakirov
committed
Disallow page backups from standby
1 parent 653615b commit 6a79870

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

backup.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,6 @@ do_backup_database(parray *backup_list, bool smooth_checkpoint)
111111
/* repack the options */
112112
pgBackup *prev_backup = NULL;
113113

114-
/* Block backup operations on a standby */
115-
from_replica = pg_is_in_recovery();
116-
if (pg_is_standby() && !from_replica)
117-
elog(ERROR, "Backup cannot run on a standby.");
118-
119114
elog(LOG, "database backup start");
120115

121116
/* Initialize size summary */
@@ -423,6 +418,15 @@ do_backup(bool smooth_checkpoint)
423418
/* setup cleanup callback function */
424419
in_backup = true;
425420

421+
/* Block backup operations on a standby */
422+
from_replica = pg_is_in_recovery();
423+
if (pg_is_standby() && !from_replica)
424+
elog(ERROR, "backup is not allowed for standby");
425+
426+
/* Page backup is not allowed for replica instance */
427+
if (from_replica && current.backup_mode == BACKUP_MODE_DIFF_PAGE)
428+
elog(ERROR, "page backup is not allowed for standby");
429+
426430
/* show configuration actually used */
427431
elog(LOG, "========================================");
428432
elog(LOG, "backup start");

doc/pg_probackup.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,13 @@ This mode should be used with caution as it allows to delete WAL files required
291291

292292
### Backup from Standby
293293

294-
If replication is in use, starting with PostgreSQL 9.6 a backup can be taken not only from primary server, but also from standby. Backup taken from standby is absolutely interchangeable with backup taken from primary (bearing in mind possible replication delay).
294+
If replication is in use, starting with PostgreSQL 9.6 a backup can be taken not only from primary server, but also from standby. Backup taken from standby is absolutely interchangeable with backup taken from primary (bearing in mind possible replication delay). Page-level incremental backups are not allowed to perform from standby.
295295

296-
Currently it is required for primary database server to have full\_page\_writes turned on (in future this requirement may be relaxed in the case checksums are enabled on data pages).
296+
Currently it is required for primary database server to have `full_page_writes` turned `on` (in future this requirement may be relaxed in the case checksums are enabled on data pages).
297297

298-
The same backup directory can be used for pg\_probackup on both servers, primary and standby, as long as it is accessible in both server's file systems. This way all backups, taken from either primary or standby, are shown together and could be managed from one server or from the other.
298+
The same backup directory can be used for `pg_probackup` on both servers, primary and standby, as long as it is accessible in both server's file systems. This way all backups, taken from either primary or standby, are shown together and could be managed from one server or from the other.
299299

300-
A backup can be used to restore primary database server as well as standby. It depends on the server on which pg\_probackup is executed with restore command. Note that recovered PostgreSQL will always run as primary server if started right after the pg\_probackup. To run it as standby, edit recovery.conf file created by pg\_probackup: at least delete every parameter that specify recovery target (recovery\_target, recovery\_target\_time, and recovery\_target\_xid), change target timeline to 'latest', and add standby\_mode = 'on'. Probably primary\_conninfo should be added too for streaming replication, and hot\_standby = 'on' in database configuration parameters for hot standby mode.
300+
A backup can be used to restore primary database server as well as standby. It depends on the server on which `pg_probackup` is executed with restore command. Note that recovered PostgreSQL will always run as primary server if started right after the `pg_probackup`. To run it as standby, edit `recovery.conf` file created by `pg_probackup`: at least delete every parameter that specify recovery target (`recovery_target`, `recovery_target_time`, and `recovery_target_xid`), change target timeline to `latest`, and add `standby_mode = on`. Probably `primary_conninfo` should be added too for streaming replication, and `hot_standby = on` in database configuration parameters for hot standby mode.
301301

302302
### Backup Retention Policy
303303

@@ -480,11 +480,11 @@ Specifies whether to stop just after the specified recovery target (true), or ju
480480

481481
Specifies recovering into a particular timeline.
482482

483-
-T OLDDIR=NEWDIR
484-
--tablespace-mapping=OLDDIR=NEWDIR
483+
-T olddir=newdir
484+
--tablespace-mapping=olddir=newdir
485485

486-
Relocate the tablespace in directory `OLDDIR` to `NEWDIR` during restore. Both
487-
`OLDDIR` and `NEWDIR` must be absolute paths.
486+
Relocate the tablespace in directory `olddir` to `newdir` during restore. Both
487+
`olddir` and `newdir` must be absolute paths.
488488

489489
### Delete options:
490490

tests/validate_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_validate_wal_1(self):
7777
# Validate to unreal xid
7878
self.assertIn(six.b("ERROR: not enough WAL records to xid"),
7979
self.validate_pb(node, options=["--xid=%d" % (int(target_xid) + 1000)]))
80-
80+
8181
# Validate with backup ID
8282
self.assertIn(six.b("INFO: backup validation completed successfully on"),
8383
self.validate_pb(node, id_backup))

0 commit comments

Comments
 (0)