mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-04-15 11:36:40 +02:00
Improvements to help to make it more dynamic depending on environment.
Changed PgBackRest to pgBackRest.
This commit is contained in:
parent
12932dc54c
commit
38f48be3cf
65
README.md
65
README.md
@ -1,8 +1,8 @@
|
||||
# PgBackRest - Simple Postgres Backup & Restore
|
||||
# pgBackRest - Simple Postgres Backup & Restore
|
||||
|
||||
PgBackRest aims to be a simple backup and restore system that can seamlessly scale up to the largest databases and workloads.
|
||||
pgBackRest aims to be a simple backup and restore system that can seamlessly scale up to the largest databases and workloads.
|
||||
|
||||
Primary PgBackRest features:
|
||||
Primary pgBackRest features:
|
||||
|
||||
- Local or remote backup
|
||||
- Multi-threaded backup/restore for performance
|
||||
@ -20,13 +20,13 @@ Primary PgBackRest features:
|
||||
- Restore remapping base/tablespaces
|
||||
- Support for PostgreSQL >= 8.3
|
||||
|
||||
Instead of relying on traditional backup tools like tar and rsync, PgBackRest implements all backup features internally and uses a custom protocol for communicating with remote systems. Removing reliance on tar and rsync allows for better solutions to database-specific backup issues. The custom remote protocol limits the types of connections that are required to perform a backup which increases security.
|
||||
Instead of relying on traditional backup tools like tar and rsync, pgBackRest implements all backup features internally and uses a custom protocol for communicating with remote systems. Removing reliance on tar and rsync allows for better solutions to database-specific backup issues. The custom remote protocol limits the types of connections that are required to perform a backup which increases security.
|
||||
|
||||
PgBackRest uses the gitflow model of development. This means that the master branch contains only the release history, i.e. each commit represents a single release and release tags are always from the master branch. The dev branch contains a single commit for each feature or fix and more accurately depicts the development history. Actual development is done on feature (dev_*) branches and squashed into dev after regression tests have passed. In this model dev is considered stable and can be released at any time. As such, the dev branch does not have any special version modifiers.
|
||||
pgBackRest uses the gitflow model of development. This means that the master branch contains only the release history, i.e. each commit represents a single release and release tags are always from the master branch. The dev branch contains a single commit for each feature or fix and more accurately depicts the development history. Actual development is done on feature (dev_*) branches and squashed into dev after regression tests have passed. In this model dev is considered stable and can be released at any time. As such, the dev branch does not have any special version modifiers.
|
||||
|
||||
## Install
|
||||
|
||||
PgBackRest is written entirely in Perl and uses some non-standard modules that must be installed from CPAN. All examples below are for PostgreSQL 9.3 but should be easily adaptable to any recent version.
|
||||
pgBackRest is written entirely in Perl and uses some non-standard modules that must be installed from CPAN. All examples below are for PostgreSQL 9.3 but should be easily adaptable to any recent version.
|
||||
|
||||
### Ubuntu 12.04
|
||||
|
||||
@ -59,13 +59,13 @@ apt-get install cpanminus
|
||||
cpanm threads (update this package when thread-max > 1)
|
||||
cpanm Thread::Queue (update this package when thread-max > 1)
|
||||
```
|
||||
* Install PgBackRest
|
||||
* Install pgBackRest
|
||||
|
||||
PgBackRest can be installed by downloading the most recent release:
|
||||
pgBackRest can be installed by downloading the most recent release:
|
||||
|
||||
https://github.com/pgmasters/backrest/releases
|
||||
|
||||
PgBackRest can be installed anywhere but it's best (though not required) to install it in the same location on all systems.
|
||||
pgBackRest can be installed anywhere but it's best (though not required) to install it in the same location on all systems.
|
||||
|
||||
* Install PostgreSQL development libraries and additional Perl modules for regression tests (optional):
|
||||
```
|
||||
@ -76,7 +76,7 @@ apt-get install libdbd-pg-perl
|
||||
|
||||
* Install Perl and required modules:
|
||||
```
|
||||
yum install perl-devel
|
||||
yum install perl
|
||||
yum install perl-Time-HiRes
|
||||
yum install perl-Compress-Raw-Zlib
|
||||
yum install perl-IO-String
|
||||
@ -95,7 +95,6 @@ cpanm Thread::Queue
|
||||
```
|
||||
* Install PostgreSQL development libraries and additional Perl modules for regression tests (optional):
|
||||
```
|
||||
yum install perl-DBI
|
||||
yum install perl-DBD-Pg
|
||||
```
|
||||
CAVEAT: You must run regression tests with --log-force since file sizes do no currently match up with the test logs.
|
||||
@ -159,7 +158,7 @@ These options are either global or used by all commands.
|
||||
|
||||
#### `config` option
|
||||
|
||||
By default PgBackRest expects the its configuration file to be located at `/etc/pg_backrest.conf`. Use this option to specify another location.
|
||||
By default pgBackRest expects the its configuration file to be located at `/etc/pg_backrest.conf`. Use this option to specify another location.
|
||||
```
|
||||
required: n
|
||||
default: /etc/pg_backrest.conf
|
||||
@ -178,14 +177,14 @@ example: stanza=main
|
||||
|
||||
#### `help` option
|
||||
|
||||
Displays the PgBackRest help.
|
||||
Displays the pgBackRest help.
|
||||
```
|
||||
required: n
|
||||
```
|
||||
|
||||
#### `version` option
|
||||
|
||||
Displays the PgBackRest version.
|
||||
Displays the pgBackRest version.
|
||||
```
|
||||
required: n
|
||||
```
|
||||
@ -194,7 +193,7 @@ required: n
|
||||
|
||||
#### `backup` command
|
||||
|
||||
Perform a database backup. PgBackRest does not have a built-in scheduler so it's best to run it from cron or some other scheduling mechanism.
|
||||
Perform a database backup. pgBackRest does not have a built-in scheduler so it's best to run it from cron or some other scheduling mechanism.
|
||||
|
||||
##### `type` option
|
||||
|
||||
@ -212,7 +211,7 @@ example: --type=full
|
||||
|
||||
##### `no-start-stop` option
|
||||
|
||||
This option prevents PgBackRest from running `pg_start_backup()` and `pg_stop_backup()` on the database. In order for this to work PostgreSQL should be shut down and PgBackRest will generate an error if it is not.
|
||||
This option prevents pgBackRest from running `pg_start_backup()` and `pg_stop_backup()` on the database. In order for this to work PostgreSQL should be shut down and pgBackRest will generate an error if it is not.
|
||||
|
||||
The purpose of this option is to allow cold backups. The `pg_xlog` directory is copied as-is and `archive-check` is automatically disabled for the backup.
|
||||
```
|
||||
@ -222,7 +221,7 @@ default: n
|
||||
|
||||
##### `force` option
|
||||
|
||||
When used with `--no-start-stop` a backup will be run even if PgBackRest thinks that PostgreSQL is running. **This option should be used with extreme care as it will likely result in a bad backup.**
|
||||
When used with `--no-start-stop` a backup will be run even if pgBackRest thinks that PostgreSQL is running. **This option should be used with extreme care as it will likely result in a bad backup.**
|
||||
|
||||
There are some scenarios where a backup might still be desirable under these conditions. For example, if a server crashes and the database volume can only be mounted read-only, it would be a good idea to take a backup even if `postmaster.pid` 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.
|
||||
```
|
||||
@ -261,7 +260,7 @@ Retrieves a WAL segment from the repository. This command is used in `recovery.
|
||||
|
||||
#### `expire` command
|
||||
|
||||
PgBackRest does backup rotation, but is not concerned with when the backups were created. So if two full backups are configured for retention, PgBackRest will keep two full backups no matter whether they occur, two hours apart or two weeks apart.
|
||||
pgBackRest does backup rotation, but is not concerned with when the backups were created. So if two full backups are configured for retention, pgBackRest will keep two full backups no matter whether they occur, two hours apart or two weeks apart.
|
||||
|
||||
##### Example
|
||||
|
||||
@ -352,7 +351,7 @@ example: --target-timeline=3
|
||||
|
||||
Recovery settings in recovery.conf options can be specified with this option. See http://www.postgresql.org/docs/X.X/static/recovery-config.html for details on recovery.conf options (replace X.X with your database version). This option can be used multiple times.
|
||||
|
||||
Note: `restore_command` will be automatically generated but can be overridden with this option. Be careful about specifying your own `restore_command` as PgBackRest is designed to handle this for you. Target Recovery options (recovery_target_name, recovery_target_time, etc.) are generated automatically by PgBackRest and should not be set with this option.
|
||||
Note: `restore_command` will be automatically generated but can be overridden with this option. Be careful about specifying your own `restore_command` as pgBackRest is designed to handle this for you. Target Recovery options (recovery_target_name, recovery_target_time, etc.) are generated automatically by pgBackRest and should not be set with this option.
|
||||
|
||||
Recovery settings can also be set in the `restore:recovery-setting` section of pg_backrest.conf. For example:
|
||||
```
|
||||
@ -360,7 +359,7 @@ Recovery settings can also be set in the `restore:recovery-setting` section of p
|
||||
primary_conn_info=db.mydomain.com
|
||||
standby_mode=on
|
||||
```
|
||||
Since PgBackRest does not start PostgreSQL after writing the `recovery.conf` file, it is always possible to edit/check `recovery.conf` before manually restarting.
|
||||
Since pgBackRest does not start PostgreSQL after writing the `recovery.conf` file, it is always possible to edit/check `recovery.conf` before manually restarting.
|
||||
```
|
||||
required: n
|
||||
example: --recovery-setting primary_conninfo=db.mydomain.com
|
||||
@ -412,7 +411,7 @@ Get information about backups in the `db` stanza.
|
||||
|
||||
## Configuration
|
||||
|
||||
PgBackRest 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 `/etc/pg_backrest.conf`.
|
||||
pgBackRest 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 `/etc/pg_backrest.conf`.
|
||||
|
||||
### Examples
|
||||
|
||||
@ -424,12 +423,12 @@ wal_level = archive
|
||||
archive_mode = on
|
||||
archive_command = '/path/to/backrest/bin/pg_backrest.pl --stanza=db archive-push %p'
|
||||
```
|
||||
Replace the path with the actual location where PgBackRest was installed. The stanza parameter should be changed to the actual stanza name for your database.
|
||||
Replace the path with the actual location where pgBackRest was installed. The stanza parameter should be changed to the actual stanza name for your database.
|
||||
|
||||
|
||||
#### Minimal Configuration
|
||||
|
||||
The absolute minimum required to run PgBackRest (if all defaults are accepted) is the database path.
|
||||
The absolute minimum required to run pgBackRest (if all defaults are accepted) is the database path.
|
||||
|
||||
`/etc/pg_backrest.conf`:
|
||||
```
|
||||
@ -445,7 +444,7 @@ This configuration is appropriate for a small installation where backups are bei
|
||||
- `cmd-psql` - Custom location and parameters for psql.
|
||||
- `cmd-psql-option` - Options for psql can be set per stanza.
|
||||
- `compress` - Disable compression (handy if the file system is already compressed).
|
||||
- `repo-path` - Path to the PgBackRest repository where backups and WAL archive are stored.
|
||||
- `repo-path` - Path to the pgBackRest repository where backups and WAL archive are stored.
|
||||
- `log-level-file` - Set the file log level to debug (Lots of extra info if something is not working as expected).
|
||||
- `hardlink` - Create hardlinks between backups (but never between full backups).
|
||||
- `thread-max` - Use 2 threads for backup/restore operations.
|
||||
@ -510,7 +509,7 @@ db-user=postgres
|
||||
|
||||
#### `command` section
|
||||
|
||||
The `command` section defines the location of external commands that are used by PgBackRest.
|
||||
The `command` section defines the location of external commands that are used by pgBackRest.
|
||||
|
||||
##### `cmd-psql` key
|
||||
|
||||
@ -744,7 +743,7 @@ example: archive-async=y
|
||||
|
||||
Limits the amount of archive log that will be written locally when `archive-async=y`. After the limit is reached, the following will happen:
|
||||
|
||||
- PgBackRest will notify Postgres that the archive was successfully backed up, then DROP IT.
|
||||
- pgBackRest will notify Postgres that the archive was successfully backed up, then DROP IT.
|
||||
- An error will be logged to the console and also to the Postgres log.
|
||||
- A stop file will be written in the lock directory and no more archive files will be backed up until it is removed.
|
||||
|
||||
@ -764,7 +763,7 @@ The `restore` section defines settings used for restoring backups.
|
||||
|
||||
##### `tablespace` key
|
||||
|
||||
Defines whether tablespaces will be be restored into their original (or remapped) locations or stored directly under the `pg_tblspc` path. Disabling this setting produces compact restores that are convenient for development, staging, etc. Currently these restores cannot be backed up as PgBackRest expects only links in the `pg_tblspc` path. If no tablespaces are present this this setting has no effect.
|
||||
Defines whether tablespaces will be be restored into their original (or remapped) locations or stored directly under the `pg_tblspc` path. Disabling this setting produces compact restores that are convenient for development, staging, etc. Currently these restores cannot be backed up as pgBackRest expects only links in the `pg_tblspc` path. If no tablespaces are present this this setting has no effect.
|
||||
```
|
||||
required: n
|
||||
default: y
|
||||
@ -793,7 +792,7 @@ example: retention-diff=3
|
||||
|
||||
##### `retention-archive-type` key
|
||||
|
||||
Type of backup to use for archive retention (full or differential). If set to full, then PgBackRest will keep archive logs for the number of full backups defined by `retention-archive`. If set to differential, then PgBackRest will keep archive logs for the number of differential backups defined by `retention-archive`.
|
||||
Type of backup to use for archive retention (full or differential). If set to full, then pgBackRest will keep archive logs for the number of full backups defined by `retention-archive`. If set to differential, then pgBackRest will keep archive logs for the number of differential backups defined by `retention-archive`.
|
||||
|
||||
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 be reasons for doing so.
|
||||
```
|
||||
@ -844,7 +843,7 @@ example: db-path=/data/db
|
||||
|
||||
### v0.80: DALLAS MILESTONE - UNDER DEVELOPMENT
|
||||
|
||||
*
|
||||
*
|
||||
|
||||
### v0.77: CentOS/RHEL 6 support and protocol improvements
|
||||
|
||||
@ -862,7 +861,7 @@ example: db-path=/data/db
|
||||
|
||||
### v0.75: New repository format, info command and experimental 9.5 support
|
||||
|
||||
* IMPORTANT NOTE: This flag day release breaks compatibility with older versions of PgBackRest. The manifest format, on-disk structure, and the binary names have all changed. You must create a new repository to hold backups for this version of PgBackRest and keep your older repository for a time in case you need to do a restore. The `pg_backrest.conf` file has not changed but you'll need to change any references to `pg_backrest.pl` in cron (or elsewhere) to `pg_backrest` (without the `.pl` extension).
|
||||
* IMPORTANT NOTE: This flag day release breaks compatibility with older versions of pgBackRest. The manifest format, on-disk structure, and the binary names have all changed. You must create a new repository to hold backups for this version of pgBackRest and keep your older repository for a time in case you need to do a restore. The `pg_backrest.conf` file has not changed but you'll need to change any references to `pg_backrest.pl` in cron (or elsewhere) to `pg_backrest` (without the `.pl` extension).
|
||||
|
||||
* Add info command.
|
||||
|
||||
@ -900,7 +899,7 @@ example: db-path=/data/db
|
||||
|
||||
* Fixed an issue where an absolute path was not written into recovery.conf when the restore was run with a relative path.
|
||||
|
||||
* Added `tablespace` setting to allow tablespaces to be restored into the `pg_tblspc` path. This produces compact restores that are convenient for development, staging, etc. Currently these restores cannot be backed up as PgBackRest expects only links in the `pg_tblspc` path.
|
||||
* Added `tablespace` setting to allow tablespaces to be restored into the `pg_tblspc` path. This produces compact restores that are convenient for development, staging, etc. Currently these restores cannot be backed up as pgBackRest expects only links in the `pg_tblspc` path.
|
||||
|
||||
### v0.61: Bug fix for uncompressed remote destination
|
||||
|
||||
@ -996,6 +995,6 @@ example: db-path=/data/db
|
||||
|
||||
## Recognition
|
||||
|
||||
Primary recognition goes to Stephen Frost for all his valuable advice and criticism during the development of PgBackRest.
|
||||
Primary recognition goes to Stephen Frost for all his valuable advice and criticism during the development of pgBackRest.
|
||||
|
||||
Crunchy Data Solutions (http://www.crunchydata.com) has contributed time and resources to PgBackRest and continues to support development. Resonate (http://www.resonate.com/) also contributed to the development of PgBackRest and allowed me to install early (but well tested) versions as their primary PostgreSQL backup solution.
|
||||
Crunchy Data Solutions (http://www.crunchydata.com) has contributed time and resources to pgBackRest and continues to support development. Resonate (http://www.resonate.com/) also contributed to the development of pgBackRest and allowed me to install early (but well tested) versions as their primary PostgreSQL backup solution.
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/perl
|
||||
####################################################################################################################################
|
||||
# pg_backrest.pl - Simple Postgres Backup and Restore
|
||||
# pgBackRest - Simple PostgreSQL Backup and Restore
|
||||
####################################################################################################################################
|
||||
|
||||
####################################################################################################################################
|
||||
@ -30,75 +30,6 @@ use BackRest::Restore;
|
||||
use BackRest::ThreadGroup;
|
||||
use BackRest::Utility;
|
||||
|
||||
####################################################################################################################################
|
||||
# Usage
|
||||
####################################################################################################################################
|
||||
|
||||
=head1 NAME
|
||||
|
||||
pg_backrest.pl - Simple Postgres Backup and Restore
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
pg_backrest.pl [options] [command]
|
||||
|
||||
Commands:
|
||||
archive-get retrieve an archive file from backup
|
||||
archive-push push an archive file to backup
|
||||
backup backup a cluster
|
||||
restore restore a cluster
|
||||
expire expire old backups (automatically run after backup)
|
||||
|
||||
General Options:
|
||||
--stanza stanza (cluster) to operate on
|
||||
--config alternate path for pg_backrest.conf
|
||||
(defaults to /etc/pg_backrest.conf)
|
||||
--version display version and exit
|
||||
--help display usage and exit
|
||||
|
||||
Backup Options:
|
||||
--type type of backup to perform (full, diff, incr)
|
||||
--no-start-stop do not call pg_start/stop_backup(). Postmaster should not
|
||||
be running.
|
||||
--force force backup when --no-start-stop passed and
|
||||
postmaster.pid exists. Use with extreme caution as this
|
||||
will probably produce an inconsistent backup!
|
||||
|
||||
Restore Options:
|
||||
--set backup set to restore (defaults to latest set).
|
||||
--delta perform a delta restore.
|
||||
--force force a restore and overwrite all existing files.
|
||||
with --delta forces size/timestamp deltas.
|
||||
|
||||
Recovery Options:
|
||||
--type type of recovery:
|
||||
default - recover to end of archive log stream
|
||||
name - restore point target
|
||||
time - timestamp target
|
||||
xid - transaction id target
|
||||
preserve - preserve the existing recovery.conf
|
||||
none - no recovery.conf generated
|
||||
--target recovery target if type is name, time, or xid.
|
||||
--target-exclusive stop just before the recovery target
|
||||
(default is inclusive).
|
||||
--target-resume do not pause after recovery (default is to pause).
|
||||
--target-timeline recover into specified timeline
|
||||
(default is current timeline).
|
||||
|
||||
Output Options:
|
||||
--log-level-console console log level (defaults to warn):
|
||||
off - No logging at all (not recommended)
|
||||
error - Log only errors
|
||||
warn - Log warnings and errors
|
||||
info - Log info, warnings, and errors
|
||||
debug - Log debug, info, warnings, and errors
|
||||
trace - Log trace (very verbose debugging), debug,
|
||||
info, warnings, and errors
|
||||
--log-level-file file log level (defaults to info). Same options as
|
||||
--log-level-console.
|
||||
|
||||
=cut
|
||||
|
||||
####################################################################################################################################
|
||||
# SAFE_EXIT - terminate all threads and SSH connections when the script is terminated
|
||||
####################################################################################################################################
|
||||
|
16
doc/doc.pl
16
doc/doc.pl
@ -25,7 +25,7 @@ use BackRest::Config;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
doc.pl - Generate PgBackRest documentation
|
||||
doc.pl - Generate pgBackRest documentation
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
@ -57,7 +57,7 @@ my $oRenderTag =
|
||||
'setting' => ['`', '`'],
|
||||
'code' => ['`', '`'],
|
||||
'code-block' => ['```', '```'],
|
||||
'backrest' => ['PgBackRest', ''],
|
||||
'backrest' => ['ERROR - TITLE NOT SET', ''],
|
||||
'postgres' => ['PostgreSQL', '']
|
||||
},
|
||||
|
||||
@ -634,6 +634,11 @@ sub doc_render
|
||||
|
||||
if (defined($$oDoc{param}{title}))
|
||||
{
|
||||
if ($iDepth == 1)
|
||||
{
|
||||
$$oRenderTag{'markdown'}{'backrest'}[0] = $$oDoc{param}{title};
|
||||
}
|
||||
|
||||
$strBuffer = ('#' x $iDepth) . ' ';
|
||||
|
||||
if (defined($$oDoc{param}{version}))
|
||||
@ -684,6 +689,13 @@ sub doc_render
|
||||
my $strOverride = $$oDoc{field}{override};
|
||||
my $strExample = $$oDoc{field}{example};
|
||||
|
||||
# !!! Temporary hack to make docs generate correctly. This should be replaced with a search if the bin path to
|
||||
# find the name of the current exe.
|
||||
if ($$oDoc{param}{id} eq 'config')
|
||||
{
|
||||
$strDefault = '/etc/pg_backrest.conf';
|
||||
}
|
||||
|
||||
if (defined($strExample))
|
||||
{
|
||||
if (index($strExample, '=') == -1)
|
||||
|
11
doc/doc.xml
11
doc/doc.xml
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE doc SYSTEM "doc.dtd">
|
||||
<doc title="PgBackRest" subtitle="Simple Postgres Backup & Restore">
|
||||
<doc title="pgBackRest" subtitle="Simple Postgres Backup & Restore">
|
||||
<intro>
|
||||
<text><backrest/> aims to be a simple backup and restore system that can seamlessly scale up to the largest databases and workloads.
|
||||
|
||||
@ -61,7 +61,7 @@
|
||||
cpanm threads (update this package when thread-max > 1)
|
||||
cpanm Thread::Queue (update this package when thread-max > 1)
|
||||
</code-block>
|
||||
* Install PgBackRest
|
||||
* Install <backrest/>
|
||||
|
||||
<backrest/> can be installed by downloading the most recent release:
|
||||
|
||||
@ -78,7 +78,7 @@
|
||||
<install-system title="CentOS 6">
|
||||
<text>* Install Perl and required modules:
|
||||
<code-block>
|
||||
yum install perl-devel
|
||||
yum install perl
|
||||
yum install perl-Time-HiRes
|
||||
yum install perl-Compress-Raw-Zlib
|
||||
yum install perl-IO-String
|
||||
@ -97,7 +97,6 @@
|
||||
</code-block>
|
||||
* Install <postgres/> development libraries and additional Perl modules for regression tests (optional):
|
||||
<code-block>
|
||||
yum install perl-DBI
|
||||
yum install perl-DBD-Pg
|
||||
</code-block>
|
||||
CAVEAT: You must run regression tests with --log-force since file sizes do no currently match up with the test logs.
|
||||
@ -698,7 +697,7 @@ Run a <id>full</id> backup on the <id>db</id> stanza. <param>--type</param> can
|
||||
<config-key id="archive-max-mb">
|
||||
<text>Limits the amount of archive log that will be written locally when <setting>archive-async=y</setting>. After the limit is reached, the following will happen:
|
||||
<ol>
|
||||
<li>PgBackRest will notify Postgres that the archive was successfully backed up, then DROP IT.</li>
|
||||
<li><backrest/> will notify Postgres that the archive was successfully backed up, then DROP IT.</li>
|
||||
<li>An error will be logged to the console and also to the Postgres log.</li>
|
||||
<li>A stop file will be written in the lock directory and no more archive files will be backed up until it is removed.</li>
|
||||
</ol>
|
||||
@ -747,7 +746,7 @@ Run a <id>full</id> backup on the <id>db</id> stanza. <param>--type</param> can
|
||||
|
||||
<!-- CONFIG - RETENTION SECTION - ARCHIVE-RETENTION-TYPE KEY -->
|
||||
<config-key id="retention-archive-type">
|
||||
<text>Type of backup to use for archive retention (full or differential). If set to full, then PgBackRest will keep archive logs for the number of full backups defined by <setting>retention-archive</setting>. If set to differential, then PgBackRest will keep archive logs for the number of differential backups defined by <setting>retention-archive</setting>.
|
||||
<text>Type of backup to use for archive retention (full or differential). 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 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 be reasons for doing so.</text>
|
||||
|
||||
|
@ -595,7 +595,7 @@ sub backup
|
||||
my $strTimestampDbStart;
|
||||
|
||||
($strArchiveStart, $strTimestampDbStart) =
|
||||
$oDb->backup_start('pg_backrest backup started ' . timestamp_string_get(undef, $lTimestampStart), $bStartFast);
|
||||
$oDb->backup_start(BACKREST_EXE . ' backup started ' . timestamp_string_get(undef, $lTimestampStart), $bStartFast);
|
||||
|
||||
$oBackupManifest->set(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_ARCHIVE_START, undef, $strArchiveStart);
|
||||
&log(INFO, "archive start: ${strArchiveStart}");
|
||||
|
@ -9,9 +9,8 @@ use Carp qw(confess);
|
||||
|
||||
use Cwd qw(abs_path);
|
||||
use Exporter qw(import);
|
||||
use File::Basename qw(dirname);
|
||||
use File::Basename qw(dirname basename);
|
||||
use Getopt::Long qw(GetOptions);
|
||||
use Pod::Usage;
|
||||
|
||||
use lib dirname($0) . '/../lib';
|
||||
use BackRest::Exception;
|
||||
@ -25,6 +24,12 @@ our @EXPORT = qw(configLoad optionGet optionTest optionRuleGet optionRequired op
|
||||
commandSet commandWrite optionRemoteType optionRemoteTypeTest protocolGet optionRemoteTest
|
||||
protocolDestroy);
|
||||
|
||||
####################################################################################################################################
|
||||
# BackRest executable name used for help messages and default
|
||||
####################################################################################################################################
|
||||
use constant BACKREST_EXE => basename($0);
|
||||
push @EXPORT, qw(BACKREST_EXE);
|
||||
|
||||
####################################################################################################################################
|
||||
# DB/BACKUP Constants
|
||||
####################################################################################################################################
|
||||
@ -237,7 +242,7 @@ use constant
|
||||
OPTION_DEFAULT_COMPRESS_LEVEL_NETWORK_MIN => 0,
|
||||
OPTION_DEFAULT_COMPRESS_LEVEL_NETWORK_MAX => 9,
|
||||
|
||||
OPTION_DEFAULT_CONFIG => '/etc/pg_backrest.conf',
|
||||
OPTION_DEFAULT_CONFIG => '/etc/' . BACKREST_EXE . '.conf',
|
||||
OPTION_DEFAULT_LOG_LEVEL_CONSOLE => lc(WARN),
|
||||
OPTION_DEFAULT_LOG_LEVEL_FILE => lc(INFO),
|
||||
OPTION_DEFAULT_THREAD_MAX => 1,
|
||||
@ -1097,13 +1102,75 @@ my %oOptionRule =
|
||||
}
|
||||
);
|
||||
|
||||
####################################################################################################################################
|
||||
# Help text - not using Pod::Usage since some elements are dynamic
|
||||
####################################################################################################################################
|
||||
use constant BACKREST_HELP =>
|
||||
"Usage:\n" .
|
||||
" " . BACKREST_EXE . " [options] [command]\n" .
|
||||
"\n" .
|
||||
" Commands:\n" .
|
||||
" archive-get retrieve an archive file from backup\n" .
|
||||
" archive-push push an archive file to backup\n" .
|
||||
" backup backup a cluster\n" .
|
||||
" restore restore a cluster\n" .
|
||||
" expire expire old backups (automatically run after backup)\n" .
|
||||
"\n" .
|
||||
" General Options:\n" .
|
||||
" --stanza stanza (cluster) to operate on\n" .
|
||||
" --config alternate path for configuration file\n" .
|
||||
" (defaults to " . OPTION_DEFAULT_CONFIG . ")\n" .
|
||||
" --version display version and exit\n" .
|
||||
" --help display usage and exit\n" .
|
||||
"\n" .
|
||||
" Backup Options:\n" .
|
||||
" --type type of backup to perform (full, diff, incr)\n" .
|
||||
" --no-start-stop do not call pg_start/stop_backup(). Postmaster should not\n" .
|
||||
" be running.\n" .
|
||||
" --force force backup when --no-start-stop passed and\n" .
|
||||
" postmaster.pid exists. Use with extreme caution as this\n" .
|
||||
" will probably produce an inconsistent backup!\n" .
|
||||
"\n" .
|
||||
" Restore Options:\n" .
|
||||
" --set backup set to restore (defaults to latest set).\n" .
|
||||
" --delta perform a delta restore.\n" .
|
||||
" --force force a restore and overwrite all existing files.\n" .
|
||||
" with --delta forces size/timestamp deltas.\n" .
|
||||
"\n" .
|
||||
" Recovery Options:\n" .
|
||||
" --type type of recovery:\n" .
|
||||
" default - recover to end of archive log stream\n" .
|
||||
" name - restore point target\n" .
|
||||
" time - timestamp target\n" .
|
||||
" xid - transaction id target\n" .
|
||||
" preserve - preserve the existing recovery.conf\n" .
|
||||
" none - no recovery.conf generated\n" .
|
||||
" --target recovery target if type is name, time, or xid.\n" .
|
||||
" --target-exclusive stop just before the recovery target\n" .
|
||||
" (default is inclusive).\n" .
|
||||
" --target-resume do not pause after recovery (default is to pause).\n" .
|
||||
" --target-timeline recover into specified timeline\n" .
|
||||
" (default is current timeline).\n" .
|
||||
"\n" .
|
||||
" Output Options:\n" .
|
||||
" --log-level-console console log level (defaults to warn):\n" .
|
||||
" off - No logging at all (not recommended)\n" .
|
||||
" error - Log only errors\n" .
|
||||
" warn - Log warnings and errors\n" .
|
||||
" info - Log info, warnings, and errors\n" .
|
||||
" debug - Log debug, info, warnings, and errors\n" .
|
||||
" trace - Log trace (very verbose debugging), debug,\n" .
|
||||
" info, warnings, and errors\n" .
|
||||
" --log-level-file file log level (defaults to info). Same options as\n" .
|
||||
" --log-level-console.";
|
||||
|
||||
####################################################################################################################################
|
||||
# Global variables
|
||||
####################################################################################################################################
|
||||
my %oOption; # Option hash
|
||||
my $strCommand; # Command (backup, archive-get, ...)
|
||||
my $strRemoteType; # Remote type (DB, BACKUP, NONE)
|
||||
my $oProtocol; # Global remote object that is created on first request (NOT THREADSAFE!)
|
||||
my %oOption; # Option hash
|
||||
my $strCommand; # Command (backup, archive-get, ...)
|
||||
my $strRemoteType; # Remote type (DB, BACKUP, NONE)
|
||||
my $oProtocol; # Global remote object that is created on first request (NOT THREADSAFE!)
|
||||
|
||||
####################################################################################################################################
|
||||
# configLoad
|
||||
@ -1158,14 +1225,14 @@ sub configLoad
|
||||
|
||||
if (!GetOptions(\%oOptionTest, %oOptionAllow))
|
||||
{
|
||||
syswrite(*STDOUT, "\npg_backrest " . BACKREST_VERSION . "\n\n");
|
||||
syswrite(*STDOUT, "\n" . BACKREST_EXE . ' ' . BACKREST_VERSION . "\n\n");
|
||||
pod2usage(2);
|
||||
};
|
||||
|
||||
# Display version and exit if requested
|
||||
if (defined($oOptionTest{&OPTION_VERSION}) || defined($oOptionTest{&OPTION_HELP}))
|
||||
{
|
||||
syswrite(*STDOUT, 'pg_backrest ' . BACKREST_VERSION . "\n");
|
||||
syswrite(*STDOUT, BACKREST_EXE . ' ' . BACKREST_VERSION . "\n");
|
||||
|
||||
if (!defined($oOptionTest{&OPTION_HELP}))
|
||||
{
|
||||
@ -1176,8 +1243,7 @@ sub configLoad
|
||||
# Display help and exit if requested
|
||||
if (defined($oOptionTest{&OPTION_HELP}))
|
||||
{
|
||||
syswrite(*STDOUT, "\n");
|
||||
pod2usage();
|
||||
syswrite(*STDOUT, "\n" . BACKREST_HELP . "\n");
|
||||
exit 0;
|
||||
}
|
||||
|
||||
@ -1350,7 +1416,7 @@ sub optionValid
|
||||
}
|
||||
}
|
||||
|
||||
# If the option value is undefined and not negated, see if it can be loaded from pg_backrest.conf
|
||||
# If the option value is undefined and not negated, see if it can be loaded from the config file
|
||||
if (!defined($strValue) && !$bNegate && $strOption ne OPTION_CONFIG &&
|
||||
$oOptionRule{$strOption}{&OPTION_RULE_SECTION} && $bDependResolved)
|
||||
{
|
||||
@ -1664,7 +1730,6 @@ sub optionRequired
|
||||
return !defined($bRequired) || $bRequired;
|
||||
}
|
||||
|
||||
|
||||
####################################################################################################################################
|
||||
# optionDefault
|
||||
#
|
||||
|
@ -513,7 +513,7 @@ sub recovery
|
||||
return;
|
||||
}
|
||||
|
||||
# Write the recovery options from pg_backrest.conf
|
||||
# Write recovery options read from the configuration file
|
||||
my $strRecovery = '';
|
||||
my $bRestoreCommandOverride = false;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user