1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-09-16 09:06:18 +02:00

Option rename cleanup based on review.

* Remove --reset tags from v1 options.
* Use constants for repo prefix.
* Specify CFGDEF_INDEX_PG in option structure rather than adding in code.
* Fix error message references to "backup host".

Contributed by Cynthia Shang.
This commit is contained in:
Cynthia Shang
2018-02-19 10:12:51 -05:00
committed by David Steele
parent f981283b8d
commit 4352407777
4 changed files with 34 additions and 44 deletions

View File

@@ -209,54 +209,54 @@ use constant CFGOPT_LOG_TIMESTAMP => 'log-time
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
# Determines how many repositories can be configured # Determines how many repositories can be configured
use constant CFGDEF_INDEX_REPO => 1; use constant CFGDEF_INDEX_REPO => 1;
push @EXPORT, qw(CFGDEF_INDEX_PG);
# Prefix that must be used by all repo options that allow multiple configurations # Prefix that must be used by all repo options that allow multiple configurations
use constant CFGDEF_PREFIX_REPO => 'repo'; use constant CFGDEF_PREFIX_REPO => 'repo';
push @EXPORT, qw(CFGDEF_PREFIX_REPO); push @EXPORT, qw(CFGDEF_PREFIX_REPO);
# Repository General # Repository General
use constant CFGOPT_REPO_CIPHER_TYPE => 'repo-cipher-type'; use constant CFGOPT_REPO_CIPHER_TYPE => CFGDEF_PREFIX_REPO . '-cipher-type';
push @EXPORT, qw(CFGOPT_REPO_CIPHER_TYPE); push @EXPORT, qw(CFGOPT_REPO_CIPHER_TYPE);
use constant CFGOPT_REPO_CIPHER_PASS => 'repo-cipher-pass'; use constant CFGOPT_REPO_CIPHER_PASS => CFGDEF_PREFIX_REPO . '-cipher-pass';
push @EXPORT, qw(CFGOPT_REPO_CIPHER_PASS); push @EXPORT, qw(CFGOPT_REPO_CIPHER_PASS);
use constant CFGOPT_REPO_HARDLINK => 'repo-hardlink'; use constant CFGOPT_REPO_HARDLINK => CFGDEF_PREFIX_REPO . '-hardlink';
push @EXPORT, qw(CFGOPT_REPO_HARDLINK); push @EXPORT, qw(CFGOPT_REPO_HARDLINK);
use constant CFGOPT_REPO_PATH => 'repo-path'; use constant CFGOPT_REPO_PATH => CFGDEF_PREFIX_REPO . '-path';
push @EXPORT, qw(CFGOPT_REPO_PATH); push @EXPORT, qw(CFGOPT_REPO_PATH);
use constant CFGOPT_REPO_TYPE => 'repo-type'; use constant CFGOPT_REPO_TYPE => CFGDEF_PREFIX_REPO . '-type';
push @EXPORT, qw(CFGOPT_REPO_TYPE); push @EXPORT, qw(CFGOPT_REPO_TYPE);
# Repository Host # Repository Host
use constant CFGOPT_REPO_HOST => 'repo-host'; use constant CFGOPT_REPO_HOST => CFGDEF_PREFIX_REPO . '-host';
push @EXPORT, qw(CFGOPT_REPO_HOST); push @EXPORT, qw(CFGOPT_REPO_HOST);
use constant CFGOPT_REPO_HOST_CMD => 'repo-host-cmd'; use constant CFGOPT_REPO_HOST_CMD => CFGOPT_REPO_HOST . '-cmd';
push @EXPORT, qw(CFGOPT_REPO_HOST_CMD); push @EXPORT, qw(CFGOPT_REPO_HOST_CMD);
use constant CFGOPT_REPO_HOST_CONFIG => 'repo-host-config'; use constant CFGOPT_REPO_HOST_CONFIG => CFGOPT_REPO_HOST . '-config';
push @EXPORT, qw(CFGOPT_REPO_HOST_CONFIG); push @EXPORT, qw(CFGOPT_REPO_HOST_CONFIG);
use constant CFGOPT_REPO_HOST_PORT => 'repo-host-port'; use constant CFGOPT_REPO_HOST_PORT => CFGOPT_REPO_HOST . '-port';
push @EXPORT, qw(CFGOPT_REPO_HOST_PORT); push @EXPORT, qw(CFGOPT_REPO_HOST_PORT);
use constant CFGOPT_REPO_HOST_USER => 'repo-host-user'; use constant CFGOPT_REPO_HOST_USER => CFGOPT_REPO_HOST . '-user';
push @EXPORT, qw(CFGOPT_REPO_HOST_USER); push @EXPORT, qw(CFGOPT_REPO_HOST_USER);
# Repository S3 # Repository S3
use constant CFGOPT_REPO_S3_KEY => 'repo-s3-key'; use constant CFGDEF_REPO_S3 => CFGDEF_PREFIX_REPO . '-s3';
use constant CFGOPT_REPO_S3_KEY => CFGDEF_REPO_S3 . '-key';
push @EXPORT, qw(CFGOPT_REPO_S3_KEY); push @EXPORT, qw(CFGOPT_REPO_S3_KEY);
use constant CFGOPT_REPO_S3_KEY_SECRET => 'repo-s3-key-secret'; use constant CFGOPT_REPO_S3_KEY_SECRET => CFGDEF_REPO_S3 . '-key-secret';
push @EXPORT, qw(CFGOPT_REPO_S3_KEY_SECRET); push @EXPORT, qw(CFGOPT_REPO_S3_KEY_SECRET);
use constant CFGOPT_REPO_S3_BUCKET => 'repo-s3-bucket'; use constant CFGOPT_REPO_S3_BUCKET => CFGDEF_REPO_S3 . '-bucket';
push @EXPORT, qw(CFGOPT_REPO_S3_BUCKET); push @EXPORT, qw(CFGOPT_REPO_S3_BUCKET);
use constant CFGOPT_REPO_S3_CA_FILE => 'repo-s3-ca-file'; use constant CFGOPT_REPO_S3_CA_FILE => CFGDEF_REPO_S3 . '-ca-file';
push @EXPORT, qw(CFGOPT_REPO_S3_CA_FILE); push @EXPORT, qw(CFGOPT_REPO_S3_CA_FILE);
use constant CFGOPT_REPO_S3_CA_PATH => 'repo-s3-ca-path'; use constant CFGOPT_REPO_S3_CA_PATH => CFGDEF_REPO_S3 . '-ca-path';
push @EXPORT, qw(CFGOPT_REPO_S3_CA_PATH); push @EXPORT, qw(CFGOPT_REPO_S3_CA_PATH);
use constant CFGOPT_REPO_S3_ENDPOINT => 'repo-s3-endpoint'; use constant CFGOPT_REPO_S3_ENDPOINT => CFGDEF_REPO_S3 . '-endpoint';
push @EXPORT, qw(CFGOPT_REPO_S3_ENDPOINT); push @EXPORT, qw(CFGOPT_REPO_S3_ENDPOINT);
use constant CFGOPT_REPO_S3_HOST => 'repo-s3-host'; use constant CFGOPT_REPO_S3_HOST => CFGDEF_REPO_S3 . '-host';
push @EXPORT, qw(CFGOPT_REPO_S3_HOST); push @EXPORT, qw(CFGOPT_REPO_S3_HOST);
use constant CFGOPT_REPO_S3_REGION => 'repo-s3-region'; use constant CFGOPT_REPO_S3_REGION => CFGDEF_REPO_S3 . '-region';
push @EXPORT, qw(CFGOPT_REPO_S3_REGION); push @EXPORT, qw(CFGOPT_REPO_S3_REGION);
use constant CFGOPT_REPO_S3_VERIFY_SSL => 'repo-s3-verify-ssl'; use constant CFGOPT_REPO_S3_VERIFY_SSL => CFGDEF_REPO_S3 . '-verify-ssl';
push @EXPORT, qw(CFGOPT_REPO_S3_VERIFY_SSL); push @EXPORT, qw(CFGOPT_REPO_S3_VERIFY_SSL);
# Archive options # Archive options
@@ -1196,7 +1196,7 @@ my %hConfigDefine =
&CFGDEF_INDEX_TOTAL => CFGDEF_INDEX_REPO, &CFGDEF_INDEX_TOTAL => CFGDEF_INDEX_REPO,
&CFGDEF_NAME_ALT => &CFGDEF_NAME_ALT =>
{ {
'hardlink' => {}, 'hardlink' => {&CFGDEF_INDEX => 1, &CFGDEF_RESET => false},
}, },
&CFGDEF_DEFAULT => false, &CFGDEF_DEFAULT => false,
&CFGDEF_COMMAND => &CFGDEF_COMMAND =>
@@ -1454,7 +1454,7 @@ my %hConfigDefine =
&CFGDEF_DEFAULT => true, &CFGDEF_DEFAULT => true,
&CFGDEF_NAME_ALT => &CFGDEF_NAME_ALT =>
{ {
'repo-s3-verify-ssl' => {&CFGDEF_INDEX => 1}, 'repo-s3-verify-ssl' => {&CFGDEF_INDEX => 1, &CFGDEF_RESET => false},
}, },
&CFGDEF_COMMAND => CFGOPT_REPO_TYPE, &CFGDEF_COMMAND => CFGOPT_REPO_TYPE,
&CFGDEF_DEPEND => CFGOPT_REPO_S3_BUCKET, &CFGDEF_DEPEND => CFGOPT_REPO_S3_BUCKET,
@@ -1879,6 +1879,7 @@ my %hConfigDefine =
&CFGDEF_SECTION => CFGDEF_SECTION_STANZA, &CFGDEF_SECTION => CFGDEF_SECTION_STANZA,
&CFGDEF_TYPE => CFGDEF_TYPE_STRING, &CFGDEF_TYPE => CFGDEF_TYPE_STRING,
&CFGDEF_PREFIX => CFGDEF_PREFIX_PG, &CFGDEF_PREFIX => CFGDEF_PREFIX_PG,
&CFGDEF_INDEX_TOTAL => CFGDEF_INDEX_PG,
&CFGDEF_REQUIRED => false, &CFGDEF_REQUIRED => false,
&CFGDEF_NAME_ALT => &CFGDEF_NAME_ALT =>
{ {
@@ -1916,6 +1917,7 @@ my %hConfigDefine =
&CFGDEF_SECTION => CFGDEF_SECTION_STANZA, &CFGDEF_SECTION => CFGDEF_SECTION_STANZA,
&CFGDEF_TYPE => CFGDEF_TYPE_STRING, &CFGDEF_TYPE => CFGDEF_TYPE_STRING,
&CFGDEF_PREFIX => CFGDEF_PREFIX_PG, &CFGDEF_PREFIX => CFGDEF_PREFIX_PG,
&CFGDEF_INDEX_TOTAL => CFGDEF_INDEX_PG,
&CFGDEF_REQUIRED => false, &CFGDEF_REQUIRED => false,
&CFGDEF_NAME_ALT => &CFGDEF_NAME_ALT =>
{ {
@@ -1982,6 +1984,7 @@ my %hConfigDefine =
&CFGDEF_SECTION => CFGDEF_SECTION_STANZA, &CFGDEF_SECTION => CFGDEF_SECTION_STANZA,
&CFGDEF_TYPE => CFGDEF_TYPE_STRING, &CFGDEF_TYPE => CFGDEF_TYPE_STRING,
&CFGDEF_PREFIX => CFGDEF_PREFIX_PG, &CFGDEF_PREFIX => CFGDEF_PREFIX_PG,
&CFGDEF_INDEX_TOTAL => CFGDEF_INDEX_PG,
&CFGDEF_REQUIRED => true, &CFGDEF_REQUIRED => true,
&CFGDEF_NAME_ALT => &CFGDEF_NAME_ALT =>
{ {
@@ -2020,6 +2023,7 @@ my %hConfigDefine =
&CFGDEF_SECTION => CFGDEF_SECTION_STANZA, &CFGDEF_SECTION => CFGDEF_SECTION_STANZA,
&CFGDEF_TYPE => CFGDEF_TYPE_INTEGER, &CFGDEF_TYPE => CFGDEF_TYPE_INTEGER,
&CFGDEF_PREFIX => CFGDEF_PREFIX_PG, &CFGDEF_PREFIX => CFGDEF_PREFIX_PG,
&CFGDEF_INDEX_TOTAL => CFGDEF_INDEX_PG,
&CFGDEF_DEFAULT => 5432, &CFGDEF_DEFAULT => 5432,
&CFGDEF_ALLOW_RANGE => [CFGDEF_DEFAULT_PROTOCOL_PORT_MIN, CFGDEF_DEFAULT_PROTOCOL_PORT_MAX], &CFGDEF_ALLOW_RANGE => [CFGDEF_DEFAULT_PROTOCOL_PORT_MIN, CFGDEF_DEFAULT_PROTOCOL_PORT_MAX],
&CFGDEF_NAME_ALT => &CFGDEF_NAME_ALT =>
@@ -2117,14 +2121,8 @@ foreach my $strKey (sort(keys(%hConfigDefine)))
$hConfigDefine{$strKey}{&CFGDEF_INTERNAL} = false; $hConfigDefine{$strKey}{&CFGDEF_INTERNAL} = false;
} }
# Set index total for pg-* # Set index total for any option where it has not been explicitly defined
if (defined($hConfigDefine{$strKey}{&CFGDEF_PREFIX}) && if (!defined($hConfigDefine{$strKey}{&CFGDEF_INDEX_TOTAL}))
$hConfigDefine{$strKey}{&CFGDEF_PREFIX} eq CFGDEF_PREFIX_PG)
{
$hConfigDefine{$strKey}{&CFGDEF_INDEX_TOTAL} = CFGDEF_INDEX_PG;
}
# Else default index total is 1
else
{ {
$hConfigDefine{$strKey}{&CFGDEF_INDEX_TOTAL} = 1; $hConfigDefine{$strKey}{&CFGDEF_INDEX_TOTAL} = 1;
} }

View File

@@ -192,7 +192,7 @@ sub main
if (!isRepoLocal()) if (!isRepoLocal())
{ {
confess &log(ERROR, confess &log(ERROR,
cfgCommandName(cfgCommandGet()) . ' command must be run on the backup host', ERROR_HOST_INVALID); cfgCommandName(cfgCommandGet()) . ' command must be run on the repository host', ERROR_HOST_INVALID);
} }
# Load module dynamically # Load module dynamically
@@ -225,7 +225,7 @@ sub main
if (!isRepoLocal()) if (!isRepoLocal())
{ {
confess &log(ERROR, confess &log(ERROR,
cfgCommandName(cfgCommandGet()) . ' command must be run on the backup host', ERROR_HOST_INVALID); cfgCommandName(cfgCommandGet()) . ' command must be run on the repository host', ERROR_HOST_INVALID);
} }
# Load module dynamically # Load module dynamically
@@ -242,7 +242,7 @@ sub main
{ {
if (!isDbLocal()) if (!isDbLocal())
{ {
confess &log(ERROR, 'restore command must be run on the db host', ERROR_HOST_INVALID); confess &log(ERROR, 'restore command must be run on the PostgreSQL host', ERROR_HOST_INVALID);
} }
# Load module dynamically # Load module dynamically
@@ -261,7 +261,7 @@ sub main
######################################################################################################################## ########################################################################################################################
if (!isRepoLocal()) if (!isRepoLocal())
{ {
confess &log(ERROR, 'backup and expire commands must be run on the backup host', ERROR_HOST_INVALID); confess &log(ERROR, 'backup and expire commands must be run on the repository host', ERROR_HOST_INVALID);
} }
######################################################################################################################## ########################################################################################################################

View File

@@ -1457,10 +1457,6 @@ static const struct option optionList[] =
.name = "no-hardlink", .name = "no-hardlink",
.val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | PARSE_NEGATE_FLAG | cfgOptRepoHardlink, .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | PARSE_NEGATE_FLAG | cfgOptRepoHardlink,
}, },
{
.name = "reset-hardlink",
.val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | PARSE_RESET_FLAG | cfgOptRepoHardlink,
},
// repo-host option and deprecations // repo-host option and deprecations
// ----------------------------------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------------------------------
@@ -1722,10 +1718,6 @@ static const struct option optionList[] =
.name = "no-repo-s3-verify-ssl", .name = "no-repo-s3-verify-ssl",
.val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | PARSE_NEGATE_FLAG | cfgOptRepoS3VerifySsl, .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | PARSE_NEGATE_FLAG | cfgOptRepoS3VerifySsl,
}, },
{
.name = "reset-repo-s3-verify-ssl",
.val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | PARSE_RESET_FLAG | cfgOptRepoS3VerifySsl,
},
// repo-type option and deprecations // repo-type option and deprecations
// ----------------------------------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------------------------------

View File

@@ -1572,7 +1572,7 @@ restore_command = '[BACKREST-BIN] --compress-level-network=0 --config=[TEST_PATH
restore, backup '[BACKUP-FULL-2]', expect exit 72 - restore errors on backup host (backup host) restore, backup '[BACKUP-FULL-2]', expect exit 72 - restore errors on backup host (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --set=[BACKUP-FULL-2] --log-level-console=warn --stanza=db restore > [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --set=[BACKUP-FULL-2] --log-level-console=warn --stanza=db restore
------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------
P00 ERROR: [072]: restore command must be run on the db host P00 ERROR: [072]: restore command must be run on the PostgreSQL host
restore, backup '[BACKUP-FULL-2]' - on backup host (backup host) restore, backup '[BACKUP-FULL-2]' - on backup host (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --set=[BACKUP-FULL-2] --log-level-console=detail --reset-pg1-host --pg1-path=[TEST_PATH]/backup/db --stanza=db restore > [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --set=[BACKUP-FULL-2] --log-level-console=detail --reset-pg1-host --pg1-path=[TEST_PATH]/backup/db --stanza=db restore
@@ -1608,7 +1608,7 @@ full backup - backup errors on db host (db-master host)
------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------
P00 WARN: option retention-full is not set, the repository may run out of space P00 WARN: option retention-full is not set, the repository may run out of space
HINT: to retain full backups indefinitely (without warning), set option 'retention-full' to the maximum. HINT: to retain full backups indefinitely (without warning), set option 'retention-full' to the maximum.
P00 ERROR: [072]: backup and expire commands must be run on the backup host P00 ERROR: [072]: backup and expire commands must be run on the repository host
restore delta, force, backup '[BACKUP-FULL-2]', expect exit 40 - fail on missing PG_VERSION (db-master host) restore delta, force, backup '[BACKUP-FULL-2]', expect exit 40 - fail on missing PG_VERSION (db-master host)
> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --delta --force --set=[BACKUP-FULL-2] --log-level-console=detail --stanza=db restore > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --delta --force --set=[BACKUP-FULL-2] --log-level-console=detail --stanza=db restore