Skip to content

Commit 4edc414

Browse files
committed
Documentation: partial restore update
1 parent ecd37a7 commit 4edc414

File tree

1 file changed

+65
-3
lines changed

1 file changed

+65
-3
lines changed

Documentation.md

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Current version - 2.1.5
1818
* [Setting up Backup from Standby](#setting-up-backup-from-standby)
1919
* [Setting up Cluster Verification](#setting-up-cluster-verification)
2020
* [Setting up PTRACK Backups](#setting-up-ptrack-backups)
21+
* [Setting up Partial Restore](#setting-up-partial-restore)
2122
* [Configuring the Remote Mode](#configuring-the-remote-mode)
2223

2324
5. [Usage](#usage)
@@ -28,7 +29,9 @@ Current version - 2.1.5
2829
* [External directories](#external-directories)
2930
* [Verifying a Cluster](#verifying-a-cluster)
3031
* [Validating a Backup](#validating-a-backup)
32+
* [Partial Validation](#partial-validation)
3133
* [Restoring a Cluster](#restoring-a-cluster)
34+
* [Partial Restore](#partial-restore)
3235
* [Performing Point-in-Time (PITR) Recovery](#performing-point-in-time-pitr-recovery)
3336
* [Using pg_probackup in the Remote Mode](#using-pg_probackup-in-the-remote-mode)
3437
* [Running pg_probackup on Parallel Threads](#running-pg_probackup-on-parallel-threads)
@@ -125,6 +128,7 @@ As compared to other backup solutions, pg_probackup offers the following benefit
125128
- Backup from replica: avoid extra load on the master server by taking backups from a standby
126129
- External directories: add to backup content of directories located outside of the PostgreSQL data directory (PGDATA), such as scripts, configs, logs and pg_dump files
127130
- Backup Catalog: get list of backups and corresponding meta information in `plain` or `json` formats
131+
- Partial Restore: restore the only specified databases or skip the specified databases.
128132

129133
To manage backup data, pg_probackup creates a `backup catalog`. This is a directory that stores all backup files with additional meta information, as well as WAL archives required for point-in-time recovery. You can store backups for different instances in separate subdirectories of a single backup catalog.
130134

@@ -518,6 +522,26 @@ If *backup_id* belong to incremental backup, then all its parents starting from
518522

519523
If you omit all the parameters, all backups are validated.
520524

525+
#### Partial Validation
526+
527+
If you have enabled [partial restore](#setting-up-partial-restore) before taking backups, you can validate or exclude from validation the arbitraty number of specific databases using [partial restore options](#partial-restore-options) with the [validate](#validate) command.
528+
529+
To validate only one or more databases, run the `validate` command with the following options:
530+
531+
pg_probackup validate -B backup_dir --instance instance_name -i backup_id --db-include=database_name
532+
533+
The option `--db-include` can be specified multiple times. For example, to validate only databases "db1" and "db2", run the following command:
534+
535+
pg_probackup validate -B backup_dir --instance instance_name -i backup_id --db-include=db1 --db-include=db2
536+
537+
To exclude one or more specific databases from validation, run the following options:
538+
539+
pg_probackup validate -B backup_dir --instance instance_name -i backup_id --db-exclude=database_name
540+
541+
The option `--db-exclude` can be specified multiple times. For example, to exclude the databases "db1" and "db2" from validation, run the following command:
542+
543+
pg_probackup validate -B backup_dir --instance instance_name -i backup_id --db-exclude=db1 --db-exclude=db2
544+
521545
### Restoring a Cluster
522546

523547
To restore the database cluster from a backup, run the restore command with at least the following options:
@@ -542,6 +566,30 @@ If you are restoring an STREAM backup, the restore is complete at once, with the
542566

543567
>NOTE: By default, the [restore](#restore) command validates the specified backup before restoring the cluster. If you run regular backup validations and would like to save time when restoring the cluster, you can specify the `--no-validate` flag to skip validation and speed up the recovery.
544568
569+
#### Partial Restore
570+
571+
If you have enabled [partial restore](#setting-up-partial-restore) before taking backups, you can restore or exclude from restore the arbitraty number of specific databases using [partial restore options](#partial-restore-options) with the [restore](#restore) commands.
572+
573+
To restore only one or more databases, run the restore command with the following options:
574+
575+
pg_probackup restore -B backup_dir --instance instance_name --db-include=database_name
576+
577+
The option `--db-include` can be specified multiple times. For example, to restore only databases `db1` and `db2`, run the following command:
578+
579+
pg_probackup restore -B backup_dir --instance instance_name --db-include=db1 --db-include=db2
580+
581+
To exclude one or more specific databases from restore, run the following options:
582+
583+
pg_probackup restore -B backup_dir --instance instance_name --db-exclude=database_name
584+
585+
The option `--db-exclude` can be specified multiple times. For example, to exclude the databases `db1` and `db2` from restore, run the following command:
586+
587+
pg_probackup restore -B backup_dir --instance instance_name -i backup_id --db-exclude=db1 --db-exclude=db2
588+
589+
Partial restore rely on lax behaviour of PostgreSQL recovery process toward truncated files. Files of excluded databases restored as null sized files, allowing recovery to work properly. After successfull starting of PostgreSQL cluster, you must drop excluded databases using `DROP DATABASE` command.
590+
591+
>NOTE: The databases `template0` and `template1` are always restored.
592+
545593
### Performing Point-in-Time (PITR) Recovery
546594

547595
If you have enabled [continuous WAL archiving](#setting-up-continuous-wal-archiving) before taking backups, you can restore the cluster to its state at an arbitrary point in time (recovery target) using [recovery target options](#recovery-target-options) with the [restore](#restore) and [validate](#validate) commands.
@@ -1009,6 +1057,7 @@ For details on usage, see the section [Creating a Backup](#creating-a-backup).
10091057
[-T OLDDIR=NEWDIR] [--external-mapping=OLDDIR=NEWDIR] [--skip-external-dirs]
10101058
[-R | --restore-as-replica] [--no-validate] [--skip-block-validation]
10111059
[recovery_options] [logging_options] [remote_options]
1060+
[partial_restore_options]
10121061

10131062
Restores the PostgreSQL instance from a backup copy located in the *backup_dir* backup catalog. If you specify a [recovery target option](#recovery-target-options), pg_probackup will find the closest backup and restores it to the specified recovery target. Otherwise, the most recent backup is used.
10141063

@@ -1032,7 +1081,7 @@ Disables block-level checksum verification to speed up validation. During automa
10321081
--no-validate
10331082
Skips backup validation. You can use this flag if you validate backups regularly and would like to save time when running restore operations.
10341083

1035-
Additionally [Recovery Target Options](#recovery-target-options), [Remote Mode Options](#remote-mode-options), [Logging Options](#logging-options) and [Common Options](#common-options) can be used.
1084+
Additionally [Recovery Target Options](#recovery-target-options), [Remote Mode Options](#remote-mode-options), [Logging Options](#logging-options), [Partial Restore](#partial-restore) and [Common Options](#common-options) can be used.
10361085

10371086
For details on usage, see the section [Restoring a Cluster](#restoring-a-cluster).
10381087

@@ -1065,9 +1114,12 @@ For details on usage, see the section [Verifying a Cluster](#verifying-a-cluster
10651114
[--help] [--instance instance_name] [-i backup_id]
10661115
[-j num_threads] [--progress]
10671116
[--skip-block-validation]
1068-
[recovery_options] [logging_options]
1117+
[recovery_target_options] [logging_options]
1118+
[partial_restore_options]
1119+
1120+
Verifies that all the files required to restore the cluster are present and not corrupted. If *instance_name* is not specified, pg_probackup validates all backups available in the backup catalog. If you specify the *instance_name* without any additional options, pg_probackup validates all the backups available for this backup instance. If you specify the *instance_name* with a [recovery target options](#recovery-target-options) and/or a *backup_id*, pg_probackup checks whether it is possible to restore the cluster using these options.
10691121

1070-
Verifies that all the files required to restore the cluster are present and not corrupted. If *instance_name* is not specified, pg_probackup validates all backups available in the backup catalog. If you specify the *instance_name* without any additional options, pg_probackup validates all the backups available for this backup instance. If you specify the *instance_name* with a [recovery target option](#recovery-target-options) and/or a *backup_id*, pg_probackup checks whether it is possible to restore the cluster using these options.
1122+
If you specify the [partial restore options](#partial-restore-options) and a *backup_id*, pg_probackup checks whether it is possible to restore the cluster using these options.
10711123

10721124
For details, see the section [Validating a Backup](#validating-a-backup).
10731125

@@ -1354,6 +1406,16 @@ Specifies pg_probackup installation directory on the remote system.
13541406
--ssh-options=ssh_options
13551407
Specifies a string of SSH command-line options. For example, the following options can used to set keep-alive for ssh connections opened by pg_probackup: `--ssh-options='-o ServerAliveCountMax=5 -o ServerAliveInterval=60'`. Full list of possible options can be found on [ssh_config manual page](https://man.openbsd.org/ssh_config.5).
13561408

1409+
#### Partial Restore Options
1410+
1411+
This section describes the options related to partial restore of cluster from backup. These options can be used with [restore](#restore) and [validate](#validate) commands.
1412+
1413+
--db-exclude=dbname
1414+
Specifies database name to exclude from restore. All other databases in the cluster will be restored as usual, including `template0` and `template1`. This option can be specified multiple times for multiple databases.
1415+
1416+
--db-include=dbname
1417+
Specifies database name to restore from backup. All other databases in the cluster will not be restored, with exception of `template0` and `template1`. This option can be specified multiple times for multiple databases.
1418+
13571419
#### Replica Options
13581420

13591421
This section describes the options related to taking a backup from standby.

0 commit comments

Comments
 (0)