<text><backrest/> can be used entirely with command-line parameters but a configuration file is more practical for installations that are complex or set a lot of options. The default location for the configuration file is <file>/etc/pg_backrest.conf</file>.</text>
<config-section-listtitle="Settings">
<!-- CONFIG - COMMAND SECTION -->
<config-sectionid="command"name="Command">
<text>The <setting>command</setting> section defines the location of external commands that are used by <backrest/>.</text>
<summary><backrest/> exe path on the remote host.</summary>
<text>Required only if the path to <exe/> is different on the local and remote systems. If not defined, the remote exe path will be set the same as the local exe path.</text>
<text>Set the buffer size used for copy, compress, and uncompress functions. A maximum of 3 buffers will be in use at a time per thread. An additional maximum of 256K per thread may be used for zlib buffers.</text>
<text>Sets the zlib level to be used for protocol compression when <setting>compress=n</setting> and the database cluster is not on the same host as the backup. Protocol compression is used to reduce network traffic but can be disabled by setting <setting>compress-level-network=0</setting>. When <setting>compress=y</setting> the <setting>compress-level-network</setting> setting is ignored and <setting>compress-level</setting> is used instead so that the file is only compressed once. SSH compression is always disabled.</text>
<text>Sets the location of the remote configuration file. This is only required if the remote configuration file is in a different location than the local configuration file.</text>
<text>Sets the timeout for queries against the database. This includes the <code>pg_start_backup()</code> and <code>pg_stop_backup()</code> functions which can each take a substantial amount of time. Because of this the timeout should be kept high unless you know that these functions will return quickly (i.e. if you have set <setting>startfast=y</setting> and you know that the database cluster will not generate many WAL segments during the backup).</text>
<text>Sets the umask to 0000 so modes in the repository are created in a sensible way. The default directory mode is 0750 and default file mode is 0640. The lock and log directories set the directory and file mode to 0770 and 0660 respectively.
To use the executing user's umask instead specify <setting>neutral-umask=n</setting> in the config file or <setting>--no-neutral-umask</setting> on the command line.</text>
<text>The repository serves as both storage and working area for <backrest/>. In a simple installation where the backups are stored locally on the database server there will be only one repository which will contain everything: backups, archives, logs, locks, etc.
If the backups are being done remotely then the backup server's repository will contain backups, archives, locks and logs while the database server's repository will contain only locks and logs. However, if asynchronous archiving is enabled then the database server's repository will also contain a spool directory for archive logs that have not yet been pushed to the remote repository.
Each system where <backrest/> is installed should have a repository directory configured. Storage requirements vary based on usage. The main backup repository will need the most space as it contains both backups and WAL segments for whatever retention you have specified. The database repository only needs significant space if asynchronous archiving is enabled and then it will act as an overflow for WAL segments and might need to be large depending on your database activity.
If you are new to backup then it will be difficult to estimate in advance how much space you'll need. The best thing to do is take some backups then record the size of different types of backups (full/incr/diff) and measure the amount of WAL generated per day. This will give you a general idea of how much space you'll need, though of course requirements will change over time as your database evolves.
<summary>Remote repository path where WAL segments, backups, logs, etc are stored.</summary>
<text>The remote repository is relative to the current installation of <backrest/>. On a database server the backup server will be remote and vice versa for the backup server where the database server will be remote. This option is only required if the remote repository has a different path than the local repository.</text>
<text>Each thread will perform compression and transfer to make the command run faster, but don't set <setting>thread-max</setting> so high that it impacts database performance.</text>
<text>This limits the amount of time (in seconds) that a thread might be stuck due to unforeseen issues executing the command. Has no affect when <setting>thread-max=1</setting>.</text>
<text>Checks that all WAL segments required to make the backup consistent are present in the WAL archive. It's a good idea to leave this as the default unless you are using another method for archiving.</text>
<text>This slightly paranoid option protects against corruption or premature expiration in the WAL segment archive by storing the WAL segments directly in the backup. PITR won't be possible without the WAL segment archive and this option also consumes more space.
Even though WAL segments will be restored with the backup, <postgres/> will ignore them if a <file>recovery.conf</file> file exists and instead use <setting>archive_command</setting> to fetch WAL segments. Specifying <setting>type=none</setting> when restoring will not create <file>recovery.conf</file> and force <postgres/> to use the WAL segments in pg_xlog. This will get the database cluster to a consistent state.</text>
<text>Defines the user that will be used for operations on the backup server. Preferably this is not the <id>postgres</id> user but rather some other user like <id>backrest</id>. If <postgres/> runs on the backup server the <id>postgres</id> user can be placed in the <id>backrest</id> group so it has read permissions on the repository without being able to damage the contents accidentally.</text>
<text>Enable hard-linking of files in differential and incremental backups to their full backups. This gives the appearance that each backup is a full backup. Be careful, though, because modifying files that are hard-linked can affect all the backups in the set.</text>
<text>Defines how often the manifest will be saved during a backup (in bytes). Saving the manifest is important because it stores the checksums and allows the resume function to work efficiently. The actual threshold used is 1% of the backup size or <setting>manifest-save-threshold</setting>, whichever is greater.</text>
<text>Defines whether the resume feature is enabled. Resume can greatly reduce the amount of time required to run a backup after a previous backup of the same type has failed. It adds complexity, however, so it may be desirable to disable in environments that do not require the feature.</text>
<text>Forces a checkpoint (by passing <id>y</id> to the <id>fast</id> parameter of <code>pg_start_backup()</code>) so the backup begins immediately. Otherwise the backup will start after the next regular checkpoint.
The setting is disabled by default because it assumes that <backrest/> is the only process doing exclusive online backups. It depends on an advisory lock that only <backrest/> sets so it may abort other processes that do exclusive online backups. Note that <cmd>base_backup</cmd> and <cmd>pg_dump</cmd> are safe to use with this setting because they do not call <code>pg_start_backup()</code> so are not exclusive.</text>
<text>The <setting>archive</setting> section defines parameters when doing async archiving. This means that the archive files will be stored locally, then a background process will pick them and move them to the backup.</text>
<text>WAL segments will be copied to the local repo, then a process will be forked to compress the segment and transfer it to the remote repo if configured. Control will be returned to <postgres/> as soon as the WAL segment is copied locally.</text>
</ol>If this occurs then the archive log stream will be interrupted and PITR will not be possible past that point. A new backup will be required to regain full restore capability.
The purpose of this feature is to prevent the log volume from filling up at which point Postgres will stop completely. Better to lose the backup than have <postgres/> go down.
To start normal archiving again you'll need to remove the stop file which will be located at <file>${repo-path}/lock/${stanza}-archive.stop</file> where <code>${repo-path}</code> is the path set in the <setting>general</setting> section, and <code>${stanza}</code> is the backup stanza.</text>
<text>Defines whether tablespaces will be be restored into their original (or remapped) paths or stored directly under the <path>pg_tblspc</path> path. Disabling this setting produces compact restores that are convenient for development, staging, etc. Currently these restores cannot be backed up as <backrest/> expects only links in the <path>pg_tblspc</path> path. If no tablespaces are present this this setting has no effect.</text>
<text>The <setting>expire</setting> section defines how long backups will be retained. Expiration only occurs when the number of complete backups exceeds the allowed retention. In other words, if full-retention is set to 2, then there must be 3 complete backups before the oldest will be expired. Make sure you always have enough space for retention + 1 backups.</text>
<text>When a full backup expires, all differential and incremental backups associated with the full backup will also expire. When not defined then all full backups will be kept.</text>
<text>When a differential backup expires, all incremental backups associated with the differential backup will also expire. When not defined all differential backups will be kept.</text>
<text>If set to full, then <backrest/> will keep archive logs for the number of full backups defined by <setting>retention-archive</setting>. If set to diff (differential), then <backrest/> will keep archive logs for the number of differential backups defined by <setting>retention-archive</setting>.
If not defined then archive logs will be kept indefinitely. In general it is not useful to keep archive logs that are older than the oldest backup but there may occasionally be reasons for doing so.</text>
<text>Number of backups worth of archive log to keep. If this is set less than your backup retention then be sure you set <setting>archive-copy=y</setting> or you won't be able to restore some older backups.
For example, if <setting>retention-archive=2</setting> and <setting>retention-full=4</setting>, then any backups older than the most recent two full backups will not have WAL segments in the archive to make them consistent. To solve this, set <setting>archive-copy=y</setting> and use <setting>type=none</setting> when restoring. This issue will be addressed in a future release but for now be careful with this setting.</text>
<text>A stanza defines the backup configuration for a specific <postgres/> database cluster. The stanza section must define the database cluster path and host/user if the database cluster is remote. Also, any global configuration sections can be overridden to define stanza-specific settings.</text>
<text>This user will also own the remote <backrest/> process and will initiate connections to <postgres/>. For this to work correctly the user should be the <postgres/> database cluster owner which is generally <id>postgres</id>, the default.</text>
<text>This should be the same as the <setting>data_directory</setting> setting in <file>postgresql.conf</file>. Even though this value can be read from <file>postgresql.conf</file> or the database cluster it is prudent to set it in case those resources are not available during a restore or cold backup scenario.
<text>The unix socket directory that was specified when <postgres/> was started. <backrest/> will automatically look in the standard location for your OS so there usually no need to specify this setting unless the socket directory was explicitly modified with the <setting>unix_socket_directory</setting> setting in <file>postgressql.conf</file>.</text>
<text>Commands are used to execute the various <backrest/> functions. Here the command options are listed exhaustively, that is, each option applicable to a command is listed with that command even if it applies to one or more other commands. This includes all the options that may also configured in <file>pg_backrest.conf</file>.</text>
<text>A stanza is the configuration for a <postgres/> database cluster that defines where it is located, how it will be backed up, archiving options, etc. Most db servers will only have one Postgres database cluster and therefore one stanza, whereas backup servers will have a stanza for every database cluster that needs to be backed up.
It is tempting to name the stanza after the primary cluster but a better name describes the databases contained in the cluster. Because the stanza name will be used for the primary and all replicas it is more appropriate to choose a name that describes the actual function of the cluster, such as app or dw, rather than the local cluster name, such as main or prod.</text>
<text>This option prevents <backrest/> from running <code>pg_start_backup()</code> and <code>pg_stop_backup()</code> on the database cluster. In order for this to work <postgres/> should be shut down and <backrest/> will generate an error if it is not.
The purpose of this option is to allow cold backups. The <path>pg_xlog</path> directory is copied as-is and <setting>archive-check</setting> is automatically disabled for the backup.</text>
<text>When used with <br-option>--no-start-stop</br-option> a backup will be run even if <backrest/> thinks that <postgres/> is running. <b>This option should be used with extreme care as it will likely result in a bad backup.</b>
There are some scenarios where a backup might still be desirable under these conditions. For example, if a server crashes and the database cluster volume can only be mounted read-only, it would be a good idea to take a backup even if <file>postmaster.pid</file> is present. In this case it would be better to revert to the prior backup and replay WAL, but possibly there is a very important transaction in a WAL segment that did not get archived.</text>
Run a <id>full</id> backup on the <id>db</id> stanza. <br-option>--type</br-option> can also be set to <id>incr</id> or <id>diff</id> for incremental or differential backups. However, if no <id>full</id> backup exists then a <id>full</id> backup will be forced even if <id>incr</id> or <id>diff</id> is requested.</text>
</command-example>
</command-example-list>
</command>
<!-- OPERATION - ARCHIVE-PUSH COMMAND -->
<commandid="archive-push"name="Archive Push">
<summary>Push a WAL segment to the archive.</summary>
<text>The WAL segment may be pushed immediately to the archive or stored locally depending on the value of <setting>archive-async</setting></text>
Accepts a WAL segment from <postgres/> and archives it in the repository defined by <setting>repo-path</setting>. <id>%p</id> is how <postgres/> specifies the location of the WAL segment to be archived.</text>
</command-example>
</command-example-list>
</command>
<!-- OPERATION - ARCHIVE-GET COMMAND -->
<commandid="archive-get"name="Archive Get">
<summary>Get a WAL segment from the archive.</summary>
<text>WAL segments are required for restoring a <postgres/> cluster or maintaining a replica.</text>
Retrieves a WAL segment from the repository. This command is used in <file>recovery.conf</file> to restore a backup, perform PITR, or as an alternative to streaming for keeping a replica up to date. <id>%f</id> is how <postgres/> specifies the WAL segment it needs and <id>%p</id> is the location where it should be copied.</text>
</command-example>
</command-example-list>
</command>
<!-- OPERATION - EXPIRE COMMAND -->
<commandid="expire"name="Expire">
<summary>Expire backups that exceed retention.</summary>
<text><backrest/> does backup rotation but is not concerned with when the backups were created. If two full backups are configured for retention, <backrest/> will keep two full backups no matter whether they occur two hours or two weeks apart.</text>
Expire (rotate) any backups that exceed the defined retention. Expiration is run automatically after every successful backup, so there is no need to run this command separately unless you have reduced retention, usually to free up some space.</text>
</command-example>
</command-example-list>
</command>
<!-- OPERATION - RESTORE COMMAND -->
<commandid="restore"name="Restore">
<summary>Restore a database cluster.</summary>
<text>This command is generally run manually, but there are instances where it might be automated.</text>
<option-list>
<!-- OPERATION - RESTORE COMMAND - SET OPTION -->
<optionid="set"name="Set">
<summary>Backup set to restore.</summary>
<text>The backup set to be restored. <id>latest</id> will restore the latest backup, otherwise provide the name of the backup to restore.</text>
<text>By default the <postgres/> data and tablespace directories are expected to be present but empty. This option performs a delta restore using checksums.</text>
<example>y</example>
</option>
<!-- OPERATION - RESTORE COMMAND - FORCE OPTION -->
<optionid="force"name="Force">
<summary>Force a restore.</summary>
<text>By itself this option forces the <postgres/> data and tablespace paths to be completely overwritten. In combination with <br-option>--delta</br-option> a timestamp/size delta will be performed instead of using checksums.</text>
<summary>Create a lock so restores on a stanza cannot run simultaneously.</summary>
<text>Locking during restores is enabled by default but can be disabled using --no-lock. Be <i>very</i> careful when disabling this option because simultaneous restores to a single path might result in a corrupt cluster.</text>
<li><id>name</id> - recover the restore point specified in <br-option>--target</br-option>.</li>
<li><id>xid</id> - recover to the transaction id specified in <br-option>--target</br-option>.</li>
<li><id>time</id> - recover to the time specified in <br-option>--target</br-option>.</li>
<li><id>preserve</id> - preserve the existing <file>recovery.conf</file> file.</li>
<li><id>none</id> - no <file>recovery.conf</file> file is written so <postgres/> will attempt to achieve consistency using WAL segments present in <path>pg_xlog</path>. Provide the required WAL segments or use the <setting>archive-copy</setting> setting to include them with the backup.</li>
<summary>Stop just before the recovery target is reached.</summary>
<text>Defines whether recovery to the target would be exclusive (the default is inclusive) and is only valid when <br-option>--type</br-option> is <id>time</id> or <id>xid</id>. For example, using <br-option>--target-exclusive</br-option> would exclude the contents of transaction <id>1007</id> when <br-option>--type=xid</br-option> and <br-option>--target=1007</br-option>. See the <setting>recovery_target_inclusive</setting> option in the <postgres/> docs for more information.</text>
<summary>Set an option in <file>recovery.conf</file>.</summary>
<text>See http://www.postgresql.org/docs/X.X/static/recovery-config.html for details on recovery.conf options (replace X.X with your <postgres/> version). This option can be used multiple times.
Note: The <setting>restore_command</setting> option will be automatically generated but can be overridden with this option. Be careful about specifying your own <setting>restore_command</setting> as <backrest/> is designed to handle this for you. Target Recovery options (recovery_target_name, recovery_target_time, etc.) are generated automatically by <backrest/> and should not be set with this option.
Since <backrest/> does not start <postgres/> after writing the <file>recovery.conf</file> file, it is always possible to edit/check <file>recovery.conf</file> before manually restarting.</text>
<text>Moves a tablespace to a new location during the restore. This is useful when tablespace locations are not the same on a replica, or an upgraded system has different mount points.
Since <postgres/> 9.2 tablespace locations are not stored in pg_tablespace so moving tablespaces can be done with impunity. However, moving a tablespace to the <setting>data_directory</setting> is not recommended and may cause problems. For more information on moving tablespaces http://www.databasesoup.com/2013/11/moving-tablespaces.html is a good resource.</text>
Restores the latest database cluster backup and then recovers to the <id>release</id> restore point.</text>
</command-example>
</command-example-list>
</command>
<!-- OPERATION - INFO COMMAND -->
<commandid="info"name="Info">
<summary>Retrieve information about backups.</summary>
<text>The <cmd>info</cmd> command operates on a single stanza or all stanzas. Text output is the default and gives a human-readable summary of backups for the stanza(s) requested. This format is subject to change with any release.
For machine-readable output use <setting>--output=json</setting>. The JSON output contains far more information than the text output, however <b>this feature is currently experimental so the format may change between versions</b>.</text>
<option-list>
<!-- OPERATION - INFO COMMAND - OUTPUT OPTION -->
<optionid="output"name="Output">
<summary>Output format.</summary>
<text>The following output types are supported:
<ul>
<li><id>text</id> - Human-readable summary of backup information.</li>
<li><id>json</id> - Exhaustive machine-readable backup information in JSON format.</li>
</ul></text>
<example>json</example>
</option>
</option-list>
<command-example-list>
<command-exampletitle="Information for a single stanza">
Get information about backups for all stanzas in the repository.</text>
</command-example>
</command-example-list>
</command>
<!-- OPERATION - HELP COMMAND -->
<commandid="help"name="Help">
<summary>Get help.</summary>
<text>Three levels of help are provided. If no command is specified then general help will be displayed. If a command is specified then a full description of the command will be displayed along with a list of valid options. If an option is specified in addition to a command then the a full description of the option as it applies to the command will be displayed.</text>
<command-example-list>
<command-exampletitle="Help for the backup command">
Get help for the force option of the backup command.</text>
</command-example>
</command-example-list>
</command>
<!-- OPERATION - START COMMAND -->
<commandid="start"name="Start">
<summary>Allow <backrest/> processes to run.</summary>
<text>If the <backrest/> processes were previously stopped using the <cmd>stop</cmd> command then they can be started again using the <cmd>start</cmd> command. Note that this will not immediately start up any <backrest/> processes but they are allowed to run.</text>
<command-example-list>
<command-exampletitle="Start processes for stanza main">
Allows <backrest/> processes to run for the <id>main</id> stanza.</text>
</command-example>
</command-example-list>
</command>
<!-- OPERATION - STOP COMMAND -->
<commandid="stop"name="Stop">
<summary>Stop <backrest/> processes from running.</summary>
<text>Does not allow any new <backrest/> processes to run. By default running processes will be allowed to complete successfully. Use the <setting>--force</setting> option to terminate running processes.
<backrest/> processes will return an error if they are run after the stop command completes.</text>
<option-list>
<!-- OPERATION - STOP COMMAND - FORCE OPTION -->
<optionid="force"name="Force">
<summary>Force all <backrest/> processes to stop.</summary>
<text>This option will send TERM signals to all running <backrest/> processes to effect a graceful but immediate shutdown. Note that this will also shutdown processes that were initiated on another system but have remotes running on the current system. For instance, if a backup was started on the backup server then running <cmd>stop --force</cmd> on the database server will shutdown the backup process on the backup server.</text>
<example>y</example>
</option>
</option-list>
<command-example-list>
<command-exampletitle="Stop processes for all stanzas">