2014-12-16 00:20:42 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# CONFIG MODULE
|
|
|
|
####################################################################################################################################
|
2016-04-14 15:30:54 +02:00
|
|
|
package pgBackRest::Config::Config;
|
2014-12-16 00:20:42 +02:00
|
|
|
|
|
|
|
use strict;
|
2015-03-03 07:57:20 +02:00
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
use Carp qw(confess);
|
2014-12-16 00:20:42 +02:00
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
use Cwd qw(abs_path);
|
|
|
|
use Exporter qw(import);
|
2015-08-29 20:20:46 +02:00
|
|
|
our @EXPORT = qw();
|
2015-07-02 16:05:13 +02:00
|
|
|
use File::Basename qw(dirname basename);
|
2015-06-14 00:25:49 +02:00
|
|
|
use Getopt::Long qw(GetOptions);
|
2016-07-29 20:02:11 +02:00
|
|
|
use Storable qw(dclone);
|
2014-12-16 00:20:42 +02:00
|
|
|
|
2016-04-14 15:30:54 +02:00
|
|
|
use pgBackRest::Common::Exception;
|
|
|
|
use pgBackRest::Common::Ini;
|
|
|
|
use pgBackRest::Common::Log;
|
2016-06-12 15:13:46 +02:00
|
|
|
use pgBackRest::Common::Wait;
|
2016-12-10 16:06:45 +02:00
|
|
|
use pgBackRest::FileCommon;
|
2016-04-14 15:30:54 +02:00
|
|
|
use pgBackRest::Protocol::Common;
|
|
|
|
use pgBackRest::Version;
|
2015-07-02 16:05:13 +02:00
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
####################################################################################################################################
|
2015-06-18 22:55:09 +02:00
|
|
|
# Command constants - basic commands that are allowed in backrest
|
2015-03-12 18:15:19 +02:00
|
|
|
####################################################################################################################################
|
2015-09-08 13:31:24 +02:00
|
|
|
my %oCommandHash;
|
|
|
|
|
2015-06-22 19:11:07 +02:00
|
|
|
use constant CMD_ARCHIVE_GET => 'archive-get';
|
2015-06-18 22:55:09 +02:00
|
|
|
push @EXPORT, qw(CMD_ARCHIVE_GET);
|
2015-09-08 13:31:24 +02:00
|
|
|
$oCommandHash{&CMD_ARCHIVE_GET} = true;
|
2015-06-22 19:11:07 +02:00
|
|
|
use constant CMD_ARCHIVE_PUSH => 'archive-push';
|
2015-06-18 22:55:09 +02:00
|
|
|
push @EXPORT, qw(CMD_ARCHIVE_PUSH);
|
2015-09-08 13:31:24 +02:00
|
|
|
$oCommandHash{&CMD_ARCHIVE_PUSH} = true;
|
2015-06-22 19:11:07 +02:00
|
|
|
use constant CMD_BACKUP => 'backup';
|
2015-06-18 22:55:09 +02:00
|
|
|
push @EXPORT, qw(CMD_BACKUP);
|
2015-09-08 13:31:24 +02:00
|
|
|
$oCommandHash{&CMD_BACKUP} = true;
|
2016-06-12 15:13:46 +02:00
|
|
|
use constant CMD_CHECK => 'check';
|
|
|
|
push @EXPORT, qw(CMD_CHECK);
|
|
|
|
$oCommandHash{&CMD_CHECK} = true;
|
2015-09-08 13:31:24 +02:00
|
|
|
use constant CMD_EXPIRE => 'expire';
|
|
|
|
push @EXPORT, qw(CMD_EXPIRE);
|
|
|
|
$oCommandHash{&CMD_EXPIRE} = true;
|
|
|
|
use constant CMD_HELP => 'help';
|
|
|
|
push @EXPORT, qw(CMD_HELP);
|
|
|
|
$oCommandHash{&CMD_HELP} = true;
|
2015-06-22 19:11:07 +02:00
|
|
|
use constant CMD_INFO => 'info';
|
2015-06-18 22:55:09 +02:00
|
|
|
push @EXPORT, qw(CMD_INFO);
|
2015-09-08 13:31:24 +02:00
|
|
|
$oCommandHash{&CMD_INFO} = true;
|
2016-09-06 15:35:02 +02:00
|
|
|
use constant CMD_LOCAL => 'local';
|
|
|
|
push @EXPORT, qw(CMD_LOCAL);
|
|
|
|
$oCommandHash{&CMD_LOCAL} = true;
|
2015-06-22 19:11:07 +02:00
|
|
|
use constant CMD_REMOTE => 'remote';
|
2015-06-18 22:55:09 +02:00
|
|
|
push @EXPORT, qw(CMD_REMOTE);
|
2015-09-08 13:31:24 +02:00
|
|
|
$oCommandHash{&CMD_REMOTE} = true;
|
2015-06-22 19:11:07 +02:00
|
|
|
use constant CMD_RESTORE => 'restore';
|
2015-06-18 22:55:09 +02:00
|
|
|
push @EXPORT, qw(CMD_RESTORE);
|
2015-09-08 13:31:24 +02:00
|
|
|
$oCommandHash{&CMD_RESTORE} = true;
|
2016-10-14 13:21:47 +02:00
|
|
|
use constant CMD_STANZA_CREATE => 'stanza-create';
|
|
|
|
push @EXPORT, qw(CMD_STANZA_CREATE);
|
|
|
|
$oCommandHash{&CMD_STANZA_CREATE} = true;
|
2017-04-03 16:42:55 +02:00
|
|
|
use constant CMD_STANZA_UPGRADE => 'stanza-upgrade';
|
|
|
|
push @EXPORT, qw(CMD_STANZA_UPGRADE);
|
|
|
|
$oCommandHash{&CMD_STANZA_UPGRADE} = true;
|
2015-10-08 17:43:56 +02:00
|
|
|
use constant CMD_START => 'start';
|
|
|
|
push @EXPORT, qw(CMD_START);
|
|
|
|
$oCommandHash{&CMD_START} = true;
|
|
|
|
use constant CMD_STOP => 'stop';
|
|
|
|
push @EXPORT, qw(CMD_STOP);
|
|
|
|
$oCommandHash{&CMD_STOP} = true;
|
2015-09-08 13:31:24 +02:00
|
|
|
use constant CMD_VERSION => 'version';
|
|
|
|
push @EXPORT, qw(CMD_VERSION);
|
|
|
|
$oCommandHash{&CMD_VERSION} = true;
|
2014-12-16 00:20:42 +02:00
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# BACKUP Type Constants
|
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
use constant BACKUP_TYPE_FULL => 'full';
|
|
|
|
push @EXPORT, qw(BACKUP_TYPE_FULL);
|
|
|
|
use constant BACKUP_TYPE_DIFF => 'diff';
|
|
|
|
push @EXPORT, qw(BACKUP_TYPE_DIFF);
|
|
|
|
use constant BACKUP_TYPE_INCR => 'incr';
|
|
|
|
push @EXPORT, qw(BACKUP_TYPE_INCR);
|
2015-01-31 20:48:09 +02:00
|
|
|
|
2015-06-14 00:25:49 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# INFO Output Constants
|
|
|
|
####################################################################################################################################
|
2015-06-17 17:26:07 +02:00
|
|
|
use constant INFO_OUTPUT_TEXT => 'text';
|
|
|
|
push @EXPORT, qw(INFO_OUTPUT_TEXT);
|
|
|
|
use constant INFO_OUTPUT_JSON => 'json';
|
|
|
|
push @EXPORT, qw(INFO_OUTPUT_JSON);
|
2015-06-14 00:25:49 +02:00
|
|
|
|
2015-04-19 23:29:52 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# SOURCE Constants
|
|
|
|
####################################################################################################################################
|
2016-01-14 03:35:12 +02:00
|
|
|
use constant SOURCE_CONFIG => 'config';
|
2016-02-15 03:42:11 +02:00
|
|
|
push @EXPORT, qw(SOURCE_CONFIG);
|
2016-01-14 03:35:12 +02:00
|
|
|
use constant SOURCE_PARAM => 'param';
|
2016-02-15 03:42:11 +02:00
|
|
|
push @EXPORT, qw(SOURCE_PARAM);
|
2016-01-14 03:35:12 +02:00
|
|
|
use constant SOURCE_DEFAULT => 'default';
|
2016-02-15 03:42:11 +02:00
|
|
|
push @EXPORT, qw(SOURCE_DEFAULT);
|
2015-04-19 23:29:52 +02:00
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# RECOVERY Type Constants
|
|
|
|
####################################################################################################################################
|
2016-01-14 03:35:12 +02:00
|
|
|
use constant RECOVERY_TYPE_NAME => 'name';
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(RECOVERY_TYPE_NAME);
|
2016-01-14 03:35:12 +02:00
|
|
|
use constant RECOVERY_TYPE_TIME => 'time';
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(RECOVERY_TYPE_TIME);
|
2016-01-14 03:35:12 +02:00
|
|
|
use constant RECOVERY_TYPE_XID => 'xid';
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(RECOVERY_TYPE_XID);
|
2016-01-14 03:35:12 +02:00
|
|
|
use constant RECOVERY_TYPE_PRESERVE => 'preserve';
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(RECOVERY_TYPE_PRESERVE);
|
2016-01-14 03:35:12 +02:00
|
|
|
use constant RECOVERY_TYPE_NONE => 'none';
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(RECOVERY_TYPE_NONE);
|
2016-01-14 03:35:12 +02:00
|
|
|
use constant RECOVERY_TYPE_IMMEDIATE => 'immediate';
|
|
|
|
push @EXPORT, qw(RECOVERY_TYPE_IMMEDIATE);
|
|
|
|
use constant RECOVERY_TYPE_DEFAULT => 'default';
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(RECOVERY_TYPE_DEFAULT);
|
2014-12-16 00:20:42 +02:00
|
|
|
|
2016-01-14 03:35:12 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# RECOVERY Action Constants
|
|
|
|
####################################################################################################################################
|
|
|
|
use constant RECOVERY_ACTION_PAUSE => 'pause';
|
|
|
|
push @EXPORT, qw(RECOVERY_ACTION_PAUSE);
|
|
|
|
use constant RECOVERY_ACTION_PROMOTE => 'promote';
|
|
|
|
push @EXPORT, qw(RECOVERY_ACTION_PROMOTE);
|
|
|
|
use constant RECOVERY_ACTION_SHUTDOWN => 'shutdown';
|
|
|
|
push @EXPORT, qw(RECOVERY_ACTION_SHUTDOWN);
|
|
|
|
|
2014-12-19 00:05:06 +02:00
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
# Option Rules
|
2014-12-19 00:05:06 +02:00
|
|
|
####################################################################################################################################
|
2016-08-24 18:39:27 +02:00
|
|
|
use constant OPTION_RULE_ALT_NAME => 'alt-name';
|
|
|
|
push @EXPORT, qw(OPTION_RULE_ALT_NAME);
|
2015-08-29 20:20:46 +02:00
|
|
|
use constant OPTION_RULE_ALLOW_LIST => 'allow-list';
|
|
|
|
push @EXPORT, qw(OPTION_RULE_ALLOW_LIST);
|
|
|
|
use constant OPTION_RULE_ALLOW_RANGE => 'allow-range';
|
|
|
|
push @EXPORT, qw(OPTION_RULE_ALLOW_RANGE);
|
|
|
|
use constant OPTION_RULE_DEFAULT => 'default';
|
|
|
|
push @EXPORT, qw(OPTION_RULE_DEFAULT);
|
|
|
|
use constant OPTION_RULE_DEPEND => 'depend';
|
|
|
|
push @EXPORT, qw(OPTION_RULE_DEPEND);
|
|
|
|
use constant OPTION_RULE_DEPEND_OPTION => 'depend-option';
|
|
|
|
push @EXPORT, qw(OPTION_RULE_DEPEND_OPTION);
|
|
|
|
use constant OPTION_RULE_DEPEND_LIST => 'depend-list';
|
|
|
|
push @EXPORT, qw(OPTION_RULE_DEPEND_LIST);
|
|
|
|
use constant OPTION_RULE_DEPEND_VALUE => 'depend-value';
|
|
|
|
push @EXPORT, qw(OPTION_RULE_DEPEND_VALUE);
|
2016-05-11 15:21:39 +02:00
|
|
|
use constant OPTION_RULE_HASH_VALUE => 'hash-value';
|
|
|
|
push @EXPORT, qw(OPTION_RULE_HASH_VALUE);
|
2015-08-29 20:20:46 +02:00
|
|
|
use constant OPTION_RULE_HINT => 'hint';
|
|
|
|
push @EXPORT, qw(OPTION_RULE_HINT);
|
|
|
|
use constant OPTION_RULE_NEGATE => 'negate';
|
|
|
|
push @EXPORT, qw(OPTION_RULE_NEGATE);
|
2016-08-24 18:39:27 +02:00
|
|
|
use constant OPTION_RULE_PREFIX => 'prefix';
|
|
|
|
push @EXPORT, qw(OPTION_RULE_PREFIX);
|
2015-08-29 20:20:46 +02:00
|
|
|
use constant OPTION_RULE_COMMAND => 'command';
|
|
|
|
push @EXPORT, qw(OPTION_RULE_COMMAND);
|
|
|
|
use constant OPTION_RULE_REQUIRED => 'required';
|
|
|
|
push @EXPORT, qw(OPTION_RULE_REQUIRED);
|
|
|
|
use constant OPTION_RULE_SECTION => 'section';
|
|
|
|
push @EXPORT, qw(OPTION_RULE_SECTION);
|
|
|
|
use constant OPTION_RULE_TYPE => 'type';
|
|
|
|
push @EXPORT, qw(OPTION_RULE_TYPE);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
2014-12-16 19:41:54 +02:00
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
# Option Types
|
2014-12-16 00:20:42 +02:00
|
|
|
####################################################################################################################################
|
2016-01-14 03:35:12 +02:00
|
|
|
use constant OPTION_TYPE_BOOLEAN => 'boolean';
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(OPTION_TYPE_BOOLEAN);
|
2016-01-14 03:35:12 +02:00
|
|
|
use constant OPTION_TYPE_FLOAT => 'float';
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(OPTION_TYPE_FLOAT);
|
2016-01-14 03:35:12 +02:00
|
|
|
use constant OPTION_TYPE_HASH => 'hash';
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(OPTION_TYPE_HASH);
|
2016-01-14 03:35:12 +02:00
|
|
|
use constant OPTION_TYPE_INTEGER => 'integer';
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(OPTION_TYPE_INTEGER);
|
2016-01-14 03:35:12 +02:00
|
|
|
use constant OPTION_TYPE_STRING => 'string';
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(OPTION_TYPE_STRING);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
2015-03-03 05:58:32 +02:00
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
# Configuration section constants
|
2015-03-03 05:58:32 +02:00
|
|
|
####################################################################################################################################
|
2016-04-14 15:30:54 +02:00
|
|
|
use constant CONFIG_SECTION_GLOBAL => 'global';
|
|
|
|
push @EXPORT, qw(CONFIG_SECTION_GLOBAL);
|
2015-08-29 20:20:46 +02:00
|
|
|
use constant CONFIG_SECTION_STANZA => 'stanza';
|
|
|
|
push @EXPORT, qw(CONFIG_SECTION_STANZA);
|
2015-03-03 05:58:32 +02:00
|
|
|
|
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
# Option constants
|
2015-03-03 05:58:32 +02:00
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
# Command-line only
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
use constant OPTION_CONFIG => 'config';
|
|
|
|
push @EXPORT, qw(OPTION_CONFIG);
|
|
|
|
use constant OPTION_DELTA => 'delta';
|
|
|
|
push @EXPORT, qw(OPTION_DELTA);
|
|
|
|
use constant OPTION_FORCE => 'force';
|
|
|
|
push @EXPORT, qw(OPTION_FORCE);
|
2016-02-20 02:32:02 +02:00
|
|
|
use constant OPTION_ONLINE => 'online';
|
|
|
|
push @EXPORT, qw(OPTION_ONLINE);
|
2015-08-29 20:20:46 +02:00
|
|
|
use constant OPTION_SET => 'set';
|
|
|
|
push @EXPORT, qw(OPTION_SET);
|
|
|
|
use constant OPTION_STANZA => 'stanza';
|
|
|
|
push @EXPORT, qw(OPTION_STANZA);
|
|
|
|
use constant OPTION_TARGET => 'target';
|
|
|
|
push @EXPORT, qw(OPTION_TARGET);
|
|
|
|
use constant OPTION_TARGET_EXCLUSIVE => 'target-exclusive';
|
|
|
|
push @EXPORT, qw(OPTION_TARGET_EXCLUSIVE);
|
2016-01-14 03:35:12 +02:00
|
|
|
use constant OPTION_TARGET_ACTION => 'target-action';
|
|
|
|
push @EXPORT, qw(OPTION_TARGET_ACTION);
|
2015-08-29 20:20:46 +02:00
|
|
|
use constant OPTION_TARGET_TIMELINE => 'target-timeline';
|
|
|
|
push @EXPORT, qw(OPTION_TARGET_TIMELINE);
|
|
|
|
use constant OPTION_TYPE => 'type';
|
|
|
|
push @EXPORT, qw(OPTION_TYPE);
|
|
|
|
use constant OPTION_OUTPUT => 'output';
|
|
|
|
push @EXPORT, qw(OPTION_OUTPUT);
|
|
|
|
|
|
|
|
# Command-line only help/version
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
use constant OPTION_HELP => 'help';
|
|
|
|
push @EXPORT, qw(OPTION_HELP);
|
|
|
|
use constant OPTION_VERSION => 'version';
|
|
|
|
push @EXPORT, qw(OPTION_VERSION);
|
|
|
|
|
2016-09-06 15:35:02 +02:00
|
|
|
# Command-line only local/remote
|
2015-10-08 17:43:56 +02:00
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
use constant OPTION_COMMAND => 'command';
|
|
|
|
push @EXPORT, qw(OPTION_COMMAND);
|
|
|
|
use constant OPTION_PROCESS => 'process';
|
|
|
|
push @EXPORT, qw(OPTION_PROCESS);
|
2016-09-06 15:35:02 +02:00
|
|
|
use constant OPTION_HOST_ID => 'host-id';
|
|
|
|
push @EXPORT, qw(OPTION_HOST_ID);
|
2015-10-08 17:43:56 +02:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# Command-line only test
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
use constant OPTION_TEST => 'test';
|
|
|
|
push @EXPORT, qw(OPTION_TEST);
|
|
|
|
use constant OPTION_TEST_DELAY => 'test-delay';
|
|
|
|
push @EXPORT, qw(OPTION_TEST_DELAY);
|
2015-10-08 17:43:56 +02:00
|
|
|
use constant OPTION_TEST_POINT => 'test-point';
|
|
|
|
push @EXPORT, qw(OPTION_TEST_POINT);
|
2015-08-29 20:20:46 +02:00
|
|
|
|
|
|
|
# GENERAL Section
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
2016-06-12 15:13:46 +02:00
|
|
|
use constant OPTION_ARCHIVE_TIMEOUT => 'archive-timeout';
|
|
|
|
push @EXPORT, qw(OPTION_ARCHIVE_TIMEOUT);
|
2015-08-29 20:20:46 +02:00
|
|
|
use constant OPTION_BUFFER_SIZE => 'buffer-size';
|
|
|
|
push @EXPORT, qw(OPTION_BUFFER_SIZE);
|
|
|
|
use constant OPTION_DB_TIMEOUT => 'db-timeout';
|
|
|
|
push @EXPORT, qw(OPTION_DB_TIMEOUT);
|
|
|
|
use constant OPTION_COMPRESS => 'compress';
|
|
|
|
push @EXPORT, qw(OPTION_COMPRESS);
|
|
|
|
use constant OPTION_COMPRESS_LEVEL => 'compress-level';
|
|
|
|
push @EXPORT, qw(OPTION_COMPRESS_LEVEL);
|
|
|
|
use constant OPTION_COMPRESS_LEVEL_NETWORK => 'compress-level-network';
|
|
|
|
push @EXPORT, qw(OPTION_COMPRESS_LEVEL_NETWORK);
|
|
|
|
use constant OPTION_NEUTRAL_UMASK => 'neutral-umask';
|
|
|
|
push @EXPORT, qw(OPTION_NEUTRAL_UMASK);
|
2016-12-10 16:06:45 +02:00
|
|
|
use constant OPTION_REPO_SYNC => 'repo-sync';
|
|
|
|
push @EXPORT, qw(OPTION_REPO_SYNC);
|
2016-06-23 00:01:18 +02:00
|
|
|
use constant OPTION_PROTOCOL_TIMEOUT => 'protocol-timeout';
|
|
|
|
push @EXPORT, qw(OPTION_PROTOCOL_TIMEOUT);
|
2016-09-06 15:35:02 +02:00
|
|
|
use constant OPTION_PROCESS_MAX => 'process-max';
|
|
|
|
push @EXPORT, qw(OPTION_PROCESS_MAX);
|
2016-12-03 17:23:26 +02:00
|
|
|
use constant OPTION_REPO_LINK => 'repo-link';
|
|
|
|
push @EXPORT, qw(OPTION_REPO_LINK);
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2016-10-05 14:55:54 +02:00
|
|
|
# Commands
|
|
|
|
use constant OPTION_CMD_SSH => 'cmd-ssh';
|
|
|
|
push @EXPORT, qw(OPTION_CMD_SSH);
|
|
|
|
|
2016-04-14 15:30:54 +02:00
|
|
|
# Paths
|
|
|
|
use constant OPTION_LOCK_PATH => 'lock-path';
|
|
|
|
push @EXPORT, qw(OPTION_LOCK_PATH);
|
|
|
|
use constant OPTION_LOG_PATH => 'log-path';
|
|
|
|
push @EXPORT, qw(OPTION_LOG_PATH);
|
|
|
|
use constant OPTION_REPO_PATH => 'repo-path';
|
|
|
|
push @EXPORT, qw(OPTION_REPO_PATH);
|
|
|
|
use constant OPTION_SPOOL_PATH => 'spool-path';
|
|
|
|
push @EXPORT, qw(OPTION_SPOOL_PATH);
|
|
|
|
|
|
|
|
# Log level
|
2015-08-29 20:20:46 +02:00
|
|
|
use constant OPTION_LOG_LEVEL_CONSOLE => 'log-level-console';
|
|
|
|
push @EXPORT, qw(OPTION_LOG_LEVEL_CONSOLE);
|
|
|
|
use constant OPTION_LOG_LEVEL_FILE => 'log-level-file';
|
|
|
|
push @EXPORT, qw(OPTION_LOG_LEVEL_FILE);
|
2016-10-05 15:09:30 +02:00
|
|
|
use constant OPTION_LOG_LEVEL_STDERR => 'log-level-stderr';
|
|
|
|
push @EXPORT, qw(OPTION_LOG_LEVEL_STDERR);
|
2017-02-05 17:59:49 +02:00
|
|
|
use constant OPTION_LOG_TIMESTAMP => 'log-timestamp';
|
|
|
|
push @EXPORT, qw(OPTION_LOG_TIMESTAMP);
|
2015-08-29 20:20:46 +02:00
|
|
|
|
|
|
|
# ARCHIVE Section
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
use constant OPTION_ARCHIVE_ASYNC => 'archive-async';
|
|
|
|
push @EXPORT, qw(OPTION_ARCHIVE_ASYNC);
|
2017-01-27 18:02:27 +02:00
|
|
|
# Deprecated and to be removed
|
2015-08-29 20:20:46 +02:00
|
|
|
use constant OPTION_ARCHIVE_MAX_MB => 'archive-max-mb';
|
|
|
|
push @EXPORT, qw(OPTION_ARCHIVE_MAX_MB);
|
2017-01-27 18:02:27 +02:00
|
|
|
use constant OPTION_ARCHIVE_QUEUE_MAX => 'archive-queue-max';
|
|
|
|
push @EXPORT, qw(OPTION_ARCHIVE_QUEUE_MAX);
|
2015-08-29 20:20:46 +02:00
|
|
|
|
|
|
|
# BACKUP Section
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
use constant OPTION_BACKUP_ARCHIVE_CHECK => 'archive-check';
|
|
|
|
push @EXPORT, qw(OPTION_BACKUP_ARCHIVE_CHECK);
|
|
|
|
use constant OPTION_BACKUP_ARCHIVE_COPY => 'archive-copy';
|
|
|
|
push @EXPORT, qw(OPTION_BACKUP_ARCHIVE_COPY);
|
2016-08-24 18:39:27 +02:00
|
|
|
use constant OPTION_BACKUP_CMD => 'backup-cmd';
|
|
|
|
push @EXPORT, qw(OPTION_BACKUP_CMD);
|
|
|
|
use constant OPTION_BACKUP_CONFIG => 'backup-config';
|
|
|
|
push @EXPORT, qw(OPTION_BACKUP_CONFIG);
|
2015-08-29 20:20:46 +02:00
|
|
|
use constant OPTION_BACKUP_HOST => 'backup-host';
|
|
|
|
push @EXPORT, qw(OPTION_BACKUP_HOST);
|
2016-08-25 17:25:46 +02:00
|
|
|
use constant OPTION_BACKUP_STANDBY => 'backup-standby';
|
|
|
|
push @EXPORT, qw(OPTION_BACKUP_STANDBY);
|
2015-08-29 20:20:46 +02:00
|
|
|
use constant OPTION_BACKUP_USER => 'backup-user';
|
|
|
|
push @EXPORT, qw(OPTION_BACKUP_USER);
|
2016-12-13 01:54:07 +02:00
|
|
|
use constant OPTION_CHECKSUM_PAGE => 'checksum-page';
|
|
|
|
push @EXPORT, qw(OPTION_CHECKSUM_PAGE);
|
2015-08-29 20:20:46 +02:00
|
|
|
use constant OPTION_HARDLINK => 'hardlink';
|
|
|
|
push @EXPORT, qw(OPTION_HARDLINK);
|
|
|
|
use constant OPTION_MANIFEST_SAVE_THRESHOLD => 'manifest-save-threshold';
|
|
|
|
push @EXPORT, qw(OPTION_MANIFEST_SAVE_THRESHOLD);
|
|
|
|
use constant OPTION_RESUME => 'resume';
|
|
|
|
push @EXPORT, qw(OPTION_RESUME);
|
|
|
|
use constant OPTION_START_FAST => 'start-fast';
|
|
|
|
push @EXPORT, qw(OPTION_START_FAST);
|
|
|
|
use constant OPTION_STOP_AUTO => 'stop-auto';
|
|
|
|
push @EXPORT, qw(OPTION_STOP_AUTO);
|
|
|
|
|
|
|
|
# EXPIRE Section
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
use constant OPTION_RETENTION_ARCHIVE => 'retention-archive';
|
|
|
|
push @EXPORT, qw(OPTION_RETENTION_ARCHIVE);
|
|
|
|
use constant OPTION_RETENTION_ARCHIVE_TYPE => 'retention-archive-type';
|
|
|
|
push @EXPORT, qw(OPTION_RETENTION_ARCHIVE_TYPE);
|
|
|
|
use constant OPTION_RETENTION_DIFF => 'retention-' . BACKUP_TYPE_DIFF;
|
|
|
|
push @EXPORT, qw(OPTION_RETENTION_DIFF);
|
|
|
|
use constant OPTION_RETENTION_FULL => 'retention-' . BACKUP_TYPE_FULL;
|
|
|
|
push @EXPORT, qw(OPTION_RETENTION_FULL);
|
|
|
|
|
|
|
|
# RESTORE Section
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
2016-05-11 15:21:39 +02:00
|
|
|
use constant OPTION_DB_INCLUDE => 'db-include';
|
|
|
|
push @EXPORT, qw(OPTION_DB_INCLUDE);
|
2016-04-15 04:50:02 +02:00
|
|
|
use constant OPTION_LINK_ALL => 'link-all';
|
|
|
|
push @EXPORT, qw(OPTION_LINK_ALL);
|
|
|
|
use constant OPTION_LINK_MAP => 'link-map';
|
|
|
|
push @EXPORT, qw(OPTION_LINK_MAP);
|
|
|
|
use constant OPTION_TABLESPACE_MAP_ALL => 'tablespace-map-all';
|
|
|
|
push @EXPORT, qw(OPTION_TABLESPACE_MAP_ALL);
|
|
|
|
use constant OPTION_TABLESPACE_MAP => 'tablespace-map';
|
|
|
|
push @EXPORT, qw(OPTION_TABLESPACE_MAP);
|
2015-09-08 13:31:24 +02:00
|
|
|
use constant OPTION_RESTORE_RECOVERY_OPTION => 'recovery-option';
|
|
|
|
push @EXPORT, qw(OPTION_RESTORE_RECOVERY_OPTION);
|
2015-08-29 20:20:46 +02:00
|
|
|
|
|
|
|
# STANZA Section
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
2016-08-24 18:39:27 +02:00
|
|
|
use constant OPTION_PREFIX_DB => 'db';
|
|
|
|
push @EXPORT, qw(OPTION_PREFIX_DB);
|
|
|
|
|
|
|
|
use constant OPTION_DB_CMD => OPTION_PREFIX_DB . '-cmd';
|
|
|
|
push @EXPORT, qw(OPTION_DB_CMD);
|
|
|
|
use constant OPTION_DB_CONFIG => OPTION_PREFIX_DB . '-config';
|
|
|
|
push @EXPORT, qw(OPTION_DB_CONFIG);
|
|
|
|
use constant OPTION_DB_HOST => OPTION_PREFIX_DB . '-host';
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(OPTION_DB_HOST);
|
2016-08-24 18:39:27 +02:00
|
|
|
use constant OPTION_DB_PATH => OPTION_PREFIX_DB . '-path';
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(OPTION_DB_PATH);
|
2016-08-24 18:39:27 +02:00
|
|
|
use constant OPTION_DB_PORT => OPTION_PREFIX_DB . '-port';
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(OPTION_DB_PORT);
|
2016-08-24 18:39:27 +02:00
|
|
|
use constant OPTION_DB_SOCKET_PATH => OPTION_PREFIX_DB . '-socket-path';
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(OPTION_DB_SOCKET_PATH);
|
2016-08-24 18:39:27 +02:00
|
|
|
use constant OPTION_DB_USER => OPTION_PREFIX_DB . '-user';
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(OPTION_DB_USER);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
2014-12-16 00:20:42 +02:00
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
# Option Defaults
|
2014-12-16 00:20:42 +02:00
|
|
|
####################################################################################################################################
|
2016-08-24 18:39:27 +02:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# Command-line only
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
use constant OPTION_DEFAULT_BACKUP_TYPE => BACKUP_TYPE_INCR;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_BACKUP_TYPE);
|
|
|
|
use constant OPTION_DEFAULT_INFO_OUTPUT => INFO_OUTPUT_TEXT;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_INFO_OUTPUT);
|
|
|
|
use constant OPTION_DEFAULT_RESTORE_DELTA => false;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_RESTORE_DELTA);
|
|
|
|
use constant OPTION_DEFAULT_RESTORE_FORCE => false;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_RESTORE_FORCE);
|
|
|
|
use constant OPTION_DEFAULT_RESTORE_SET => 'latest';
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_RESTORE_SET);
|
|
|
|
use constant OPTION_DEFAULT_RESTORE_TARGET_EXCLUSIVE => false;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_RESTORE_TARGET_EXCLUSIVE);
|
2016-01-14 03:35:12 +02:00
|
|
|
use constant OPTION_DEFAULT_RESTORE_TARGET_ACTION => RECOVERY_ACTION_PAUSE;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_RESTORE_TARGET_ACTION);
|
2015-08-29 20:20:46 +02:00
|
|
|
use constant OPTION_DEFAULT_RESTORE_TYPE => RECOVERY_TYPE_DEFAULT;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_RESTORE_TYPE);
|
2016-12-20 23:52:20 +02:00
|
|
|
use constant OPTION_DEFAULT_STANZA_CREATE_FORCE => false;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_STANZA_CREATE_FORCE);
|
2015-08-29 20:20:46 +02:00
|
|
|
|
|
|
|
# Command-line only test
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
use constant OPTION_DEFAULT_TEST => false;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_TEST);
|
|
|
|
use constant OPTION_DEFAULT_TEST_DELAY => 5;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_TEST_DELAY);
|
|
|
|
|
|
|
|
# GENERAL Section
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
2016-06-12 15:13:46 +02:00
|
|
|
use constant OPTION_DEFAULT_ARCHIVE_TIMEOUT => 60;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_ARCHIVE_TIMEOUT);
|
|
|
|
use constant OPTION_DEFAULT_ARCHIVE_TIMEOUT_MIN => WAIT_TIME_MINIMUM;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_ARCHIVE_TIMEOUT_MIN);
|
|
|
|
use constant OPTION_DEFAULT_ARCHIVE_TIMEOUT_MAX => 86400;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_ARCHIVE_TIMEOUT_MAX);
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
use constant OPTION_DEFAULT_BUFFER_SIZE => 4194304;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_BUFFER_SIZE);
|
|
|
|
use constant OPTION_DEFAULT_BUFFER_SIZE_MIN => 16384;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_BUFFER_SIZE_MIN);
|
|
|
|
use constant OPTION_DEFAULT_BUFFER_SIZE_MAX => 8388608;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_BUFFER_SIZE_MAX);
|
|
|
|
|
|
|
|
use constant OPTION_DEFAULT_COMPRESS => true;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_COMPRESS);
|
|
|
|
|
|
|
|
use constant OPTION_DEFAULT_COMPRESS_LEVEL => 6;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_COMPRESS_LEVEL);
|
|
|
|
use constant OPTION_DEFAULT_COMPRESS_LEVEL_MIN => 0;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_COMPRESS_LEVEL_MIN);
|
|
|
|
use constant OPTION_DEFAULT_COMPRESS_LEVEL_MAX => 9;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_COMPRESS_LEVEL_MAX);
|
|
|
|
|
|
|
|
use constant OPTION_DEFAULT_COMPRESS_LEVEL_NETWORK => 3;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_COMPRESS_LEVEL_NETWORK);
|
|
|
|
use constant OPTION_DEFAULT_COMPRESS_LEVEL_NETWORK_MIN => 0;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_COMPRESS_LEVEL_NETWORK_MIN);
|
|
|
|
use constant OPTION_DEFAULT_COMPRESS_LEVEL_NETWORK_MAX => 9;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_COMPRESS_LEVEL_NETWORK_MAX);
|
|
|
|
|
|
|
|
use constant OPTION_DEFAULT_DB_TIMEOUT => 1800;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_DB_TIMEOUT);
|
2016-06-12 15:13:46 +02:00
|
|
|
use constant OPTION_DEFAULT_DB_TIMEOUT_MIN => WAIT_TIME_MINIMUM;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_DB_TIMEOUT_MIN);
|
|
|
|
use constant OPTION_DEFAULT_DB_TIMEOUT_MAX => 86400 * 7;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_DB_TIMEOUT_MAX);
|
|
|
|
|
2016-12-10 16:06:45 +02:00
|
|
|
use constant OPTION_DEFAULT_REPO_SYNC => true;
|
|
|
|
|
2016-06-23 00:01:18 +02:00
|
|
|
use constant OPTION_DEFAULT_PROTOCOL_TIMEOUT => OPTION_DEFAULT_DB_TIMEOUT + 30;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_PROTOCOL_TIMEOUT);
|
|
|
|
use constant OPTION_DEFAULT_PROTOCOL_TIMEOUT_MIN => OPTION_DEFAULT_DB_TIMEOUT_MIN;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_PROTOCOL_TIMEOUT_MIN);
|
|
|
|
use constant OPTION_DEFAULT_PROTOCOL_TIMEOUT_MAX => OPTION_DEFAULT_DB_TIMEOUT_MAX;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_PROTOCOL_TIMEOUT_MAX);
|
|
|
|
|
2016-10-05 14:55:54 +02:00
|
|
|
use constant OPTION_DEFAULT_CMD_SSH => 'ssh';
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_CMD_SSH);
|
2016-06-24 14:12:58 +02:00
|
|
|
use constant OPTION_DEFAULT_CONFIG => '/etc/' . BACKREST_CONF;
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_CONFIG);
|
2016-04-14 15:30:54 +02:00
|
|
|
use constant OPTION_DEFAULT_LOCK_PATH => '/tmp/' . BACKREST_EXE;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_LOCK_PATH);
|
|
|
|
use constant OPTION_DEFAULT_LOG_PATH => '/var/log/' . BACKREST_EXE;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_LOG_PATH);
|
2015-08-29 20:20:46 +02:00
|
|
|
use constant OPTION_DEFAULT_NEUTRAL_UMASK => true;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_NEUTRAL_UMASK);
|
2016-12-03 17:23:26 +02:00
|
|
|
use constant OPTION_DEFAULT_REPO_LINK => true;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_REPO_LINK);
|
2016-04-14 15:30:54 +02:00
|
|
|
use constant OPTION_DEFAULT_REPO_PATH => '/var/lib/' . BACKREST_EXE;
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_REPO_PATH);
|
2016-04-14 15:30:54 +02:00
|
|
|
use constant OPTION_DEFAULT_SPOOL_PATH => '/var/spool/' . BACKREST_EXE;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_SPOOL_PATH);
|
2016-09-06 15:35:02 +02:00
|
|
|
use constant OPTION_DEFAULT_PROCESS_MAX => 1;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_PROCESS_MAX);
|
|
|
|
use constant OPTION_DEFAULT_PROCESS_MAX_MIN => 1;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_PROCESS_MAX_MIN);
|
|
|
|
use constant OPTION_DEFAULT_PROCESS_MAX_MAX => 96;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_PROCESS_MAX_MAX);
|
2015-08-29 20:20:46 +02:00
|
|
|
|
|
|
|
# LOG Section
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
use constant OPTION_DEFAULT_LOG_LEVEL_CONSOLE => lc(WARN);
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_LOG_LEVEL_CONSOLE);
|
|
|
|
use constant OPTION_DEFAULT_LOG_LEVEL_FILE => lc(INFO);
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_LOG_LEVEL_FILE);
|
2016-10-05 15:09:30 +02:00
|
|
|
use constant OPTION_DEFAULT_LOG_LEVEL_STDERR => lc(WARN);
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_LOG_LEVEL_STDERR);
|
2017-02-05 17:59:49 +02:00
|
|
|
use constant OPTION_DEFAULT_LOG_TIMESTAMP => true;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_LOG_TIMESTAMP);
|
2015-08-29 20:20:46 +02:00
|
|
|
|
|
|
|
# ARCHIVE SECTION
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
use constant OPTION_DEFAULT_ARCHIVE_ASYNC => false;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_ARCHIVE_ASYNC);
|
|
|
|
|
|
|
|
# BACKUP Section
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
use constant OPTION_DEFAULT_BACKUP_ARCHIVE_CHECK => true;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_BACKUP_ARCHIVE_CHECK);
|
|
|
|
use constant OPTION_DEFAULT_BACKUP_ARCHIVE_COPY => false;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_BACKUP_ARCHIVE_COPY);
|
|
|
|
use constant OPTION_DEFAULT_BACKUP_FORCE => false;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_BACKUP_FORCE);
|
|
|
|
use constant OPTION_DEFAULT_BACKUP_HARDLINK => false;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_BACKUP_HARDLINK);
|
2016-02-20 02:32:02 +02:00
|
|
|
use constant OPTION_DEFAULT_BACKUP_ONLINE => true;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_BACKUP_ONLINE);
|
2015-08-29 20:20:46 +02:00
|
|
|
use constant OPTION_DEFAULT_BACKUP_MANIFEST_SAVE_THRESHOLD => 1073741824;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_BACKUP_MANIFEST_SAVE_THRESHOLD);
|
|
|
|
use constant OPTION_DEFAULT_BACKUP_RESUME => true;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_BACKUP_RESUME);
|
2016-08-25 17:25:46 +02:00
|
|
|
use constant OPTION_DEFAULT_BACKUP_STANDBY => false;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_BACKUP_STANDBY);
|
2015-08-29 20:20:46 +02:00
|
|
|
use constant OPTION_DEFAULT_BACKUP_STOP_AUTO => false;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_BACKUP_STOP_AUTO);
|
|
|
|
use constant OPTION_DEFAULT_BACKUP_START_FAST => false;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_BACKUP_START_FAST);
|
2015-11-22 21:02:14 +02:00
|
|
|
use constant OPTION_DEFAULT_BACKUP_USER => 'backrest';
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_BACKUP_USER);
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
# START/STOP Section
|
2015-10-08 17:43:56 +02:00
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
use constant OPTION_DEFAULT_STOP_FORCE => false;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_STOP_FORCE);
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# EXPIRE Section
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
use constant OPTION_DEFAULT_RETENTION_ARCHIVE_TYPE => BACKUP_TYPE_FULL;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_RETENTION_ARCHIVE_TYPE);
|
|
|
|
use constant OPTION_DEFAULT_RETENTION_MIN => 1;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_RETENTION_MIN);
|
|
|
|
use constant OPTION_DEFAULT_RETENTION_MAX => 999999999;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_RETENTION_MAX);
|
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
# RESTORE Section
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
use constant OPTION_DEFAULT_LINK_ALL => false;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_LINK_ALL);
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# STANZA Section
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
use constant OPTION_DEFAULT_DB_PORT => 5432;
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_DB_PORT);
|
|
|
|
use constant OPTION_DEFAULT_DB_USER => 'postgres';
|
|
|
|
push @EXPORT, qw(OPTION_DEFAULT_DB_USER);
|
2014-12-16 00:20:42 +02:00
|
|
|
|
|
|
|
####################################################################################################################################
|
2015-03-12 18:15:19 +02:00
|
|
|
# Option Rule Hash
|
2016-06-12 15:13:46 +02:00
|
|
|
#
|
2016-09-07 14:07:37 +02:00
|
|
|
# Contains the rules for options: which commands the option can/cannot be specified, for which commands it is required, default
|
|
|
|
# settings, types, ranges, whether the option is negatable, whether it has dependencies, etc. The initial section is the global
|
|
|
|
# section meaning the rules defined there apply to all commands listed for the option.
|
|
|
|
#
|
|
|
|
# OPTION_RULE_COMMAND: List of commands the option can or cannot be specified.
|
|
|
|
# true - the option is valid and can be specified
|
|
|
|
# &OPTION_RULE_COMMAND =>
|
|
|
|
# {
|
|
|
|
# &CMD_CHECK => true,
|
|
|
|
# false - used in conjuntion with OPTION_RULE_DEFAULT so the user cannot override this option. If the option is provided for the
|
|
|
|
# command by the user, it will be ignored and the default will be used.
|
2016-12-03 17:28:08 +02:00
|
|
|
# NOTE: If the option (A) has a dependency on another option (B) then the CMD_ must also be specified in the other option (B),
|
|
|
|
# else it will still error on the option (A).
|
2016-09-07 14:07:37 +02:00
|
|
|
#
|
|
|
|
# OPTION_RULE_REQUIRED:
|
|
|
|
# In global section:
|
|
|
|
# true - if the option does not have a default, then setting OPTION_RULE_REQUIRED in the global section means all commands
|
|
|
|
# listed in OPTION_RULE_COMMAND require the user to set it.
|
|
|
|
# false - no commands listed require it as an option but it can be set. This can be overridden for individual commands by
|
|
|
|
# setting OPTION_RULE_REQUIRED in the OPTION_RULE_COMMAND section.
|
|
|
|
# In OPTION_RULE_COMMAND section:
|
|
|
|
# true - the option must be set somehow for the command, either by default (OPTION_RULE_DEFAULT) or by the user.
|
|
|
|
# &CMD_CHECK =>
|
|
|
|
# {
|
|
|
|
# &OPTION_RULE_REQUIRED => true
|
|
|
|
# },
|
|
|
|
# false - mainly used for overriding the OPTION_RULE_REQUIRED in the global section.
|
|
|
|
#
|
|
|
|
# OPTION_RULE_DEFAULT:
|
|
|
|
# Sets a default for the option for all commands if listed in the global section, or for specific commands if listed in the
|
|
|
|
# OPTION_RULE_COMMAND section.
|
|
|
|
#
|
|
|
|
# OPTION_RULE_NEGATE:
|
2017-01-31 17:38:45 +02:00
|
|
|
# The option can be negated with "no" e.g. --no-compress.
|
2016-09-07 14:07:37 +02:00
|
|
|
#
|
|
|
|
# OPTION_RULE_DEPEND:
|
2016-12-03 17:28:08 +02:00
|
|
|
# Specify the dependencies this option has on another option. All commands listed for this option must also be listed in the
|
|
|
|
# dependent option(s).
|
2016-09-07 14:07:37 +02:00
|
|
|
# OPTION_RULE_DEPEND_LIST further defines the allowable settings for the depended option.
|
|
|
|
#
|
|
|
|
# OPTION_RULE_ALLOW_LIST:
|
|
|
|
# Lists the allowable settings for the option.
|
2014-12-16 00:20:42 +02:00
|
|
|
####################################################################################################################################
|
2015-03-12 18:15:19 +02:00
|
|
|
my %oOptionRule =
|
|
|
|
(
|
2015-08-29 20:20:46 +02:00
|
|
|
# Command-line only
|
2015-03-12 18:15:19 +02:00
|
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
&OPTION_CONFIG =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_CONFIG,
|
2015-09-08 13:31:24 +02:00
|
|
|
&OPTION_RULE_NEGATE => true,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_ARCHIVE_GET => true,
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
|
|
|
&CMD_BACKUP => true,
|
2016-06-12 15:13:46 +02:00
|
|
|
&CMD_CHECK => true,
|
2015-11-22 21:02:14 +02:00
|
|
|
&CMD_EXPIRE => true,
|
2015-09-08 13:31:24 +02:00
|
|
|
&CMD_INFO => true,
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL => true,
|
2015-09-08 13:31:24 +02:00
|
|
|
&CMD_REMOTE => true,
|
2015-11-20 17:28:58 +02:00
|
|
|
&CMD_RESTORE => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2015-11-20 17:28:58 +02:00
|
|
|
&CMD_START => true,
|
|
|
|
&CMD_STOP => true
|
2015-09-08 13:31:24 +02:00
|
|
|
}
|
2015-03-12 18:15:19 +02:00
|
|
|
},
|
2014-12-16 00:20:42 +02:00
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_DELTA =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_RESTORE =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_RESTORE_DELTA,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-12-16 00:20:42 +02:00
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_FORCE =>
|
2014-12-24 01:52:38 +02:00
|
|
|
{
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-01-28 07:28:21 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_BACKUP =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_BACKUP_FORCE,
|
|
|
|
&OPTION_RULE_DEPEND =>
|
|
|
|
{
|
2016-02-20 02:32:02 +02:00
|
|
|
&OPTION_RULE_DEPEND_OPTION => OPTION_ONLINE,
|
|
|
|
&OPTION_RULE_DEPEND_VALUE => false
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
2015-10-08 17:43:56 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
&CMD_RESTORE =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_RESTORE_FORCE,
|
|
|
|
},
|
|
|
|
|
2016-12-20 23:52:20 +02:00
|
|
|
&CMD_STANZA_CREATE =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_STANZA_CREATE_FORCE,
|
|
|
|
},
|
|
|
|
|
2015-10-08 17:43:56 +02:00
|
|
|
&CMD_STOP =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_STOP_FORCE
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
2015-01-28 07:28:21 +02:00
|
|
|
}
|
2015-03-12 18:15:19 +02:00
|
|
|
},
|
2014-12-24 01:52:38 +02:00
|
|
|
|
2016-02-20 02:32:02 +02:00
|
|
|
&OPTION_ONLINE =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
|
2016-02-20 02:32:02 +02:00
|
|
|
&OPTION_RULE_NEGATE => true,
|
2016-07-02 15:02:55 +02:00
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_BACKUP_ONLINE,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2014-12-24 01:52:38 +02:00
|
|
|
{
|
2016-07-02 15:02:55 +02:00
|
|
|
&CMD_BACKUP => true,
|
|
|
|
&CMD_CHECK => true,
|
2016-12-20 23:52:20 +02:00
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2014-12-24 01:52:38 +02:00
|
|
|
}
|
2015-03-12 18:15:19 +02:00
|
|
|
},
|
2014-12-24 01:52:38 +02:00
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_SET =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_RESTORE =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-04-19 23:29:52 +02:00
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_RESTORE_SET,
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-12-16 00:20:42 +02:00
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_STANZA =>
|
|
|
|
{
|
2015-06-14 00:25:49 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-06-14 00:25:49 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_ARCHIVE_GET =>
|
2015-06-14 00:25:49 +02:00
|
|
|
{
|
|
|
|
&OPTION_RULE_REQUIRED => true
|
|
|
|
},
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_ARCHIVE_PUSH =>
|
2015-06-14 00:25:49 +02:00
|
|
|
{
|
|
|
|
&OPTION_RULE_REQUIRED => true
|
|
|
|
},
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_BACKUP =>
|
2015-06-14 00:25:49 +02:00
|
|
|
{
|
|
|
|
&OPTION_RULE_REQUIRED => true
|
|
|
|
},
|
2016-06-12 15:13:46 +02:00
|
|
|
&CMD_CHECK =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_REQUIRED => true
|
|
|
|
},
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_EXPIRE =>
|
2015-06-14 00:25:49 +02:00
|
|
|
{
|
|
|
|
&OPTION_RULE_REQUIRED => true
|
|
|
|
},
|
2015-09-08 13:31:24 +02:00
|
|
|
&CMD_INFO =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_REQUIRED => false
|
|
|
|
},
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_REQUIRED => true
|
|
|
|
},
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_REMOTE =>
|
2015-06-18 21:39:30 +02:00
|
|
|
{
|
|
|
|
&OPTION_RULE_REQUIRED => false
|
|
|
|
},
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_RESTORE =>
|
2015-06-14 00:25:49 +02:00
|
|
|
{
|
|
|
|
&OPTION_RULE_REQUIRED => true
|
2015-10-08 17:43:56 +02:00
|
|
|
},
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_STANZA_CREATE =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_REQUIRED => true
|
|
|
|
},
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_REQUIRED => true
|
|
|
|
},
|
2015-10-08 17:43:56 +02:00
|
|
|
&CMD_START =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_REQUIRED => false
|
|
|
|
},
|
|
|
|
&CMD_STOP =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_REQUIRED => false
|
2015-06-14 00:25:49 +02:00
|
|
|
}
|
|
|
|
}
|
2015-03-12 18:15:19 +02:00
|
|
|
},
|
2014-12-16 00:20:42 +02:00
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_TARGET =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_RESTORE =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
&OPTION_RULE_DEPEND =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_DEPEND_OPTION => OPTION_TYPE,
|
|
|
|
&OPTION_RULE_DEPEND_LIST =>
|
|
|
|
{
|
|
|
|
&RECOVERY_TYPE_NAME => true,
|
|
|
|
&RECOVERY_TYPE_TIME => true,
|
|
|
|
&RECOVERY_TYPE_XID => true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2015-01-23 03:11:33 +02:00
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_TARGET_EXCLUSIVE =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_RESTORE =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_RESTORE_TARGET_EXCLUSIVE,
|
|
|
|
&OPTION_RULE_DEPEND =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_DEPEND_OPTION => OPTION_TYPE,
|
|
|
|
&OPTION_RULE_DEPEND_LIST =>
|
|
|
|
{
|
|
|
|
&RECOVERY_TYPE_TIME => true,
|
|
|
|
&RECOVERY_TYPE_XID => true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2015-01-23 03:11:33 +02:00
|
|
|
|
2016-01-14 03:35:12 +02:00
|
|
|
&OPTION_TARGET_ACTION =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-01-14 03:35:12 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_RESTORE =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-01-14 03:35:12 +02:00
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_RESTORE_TARGET_ACTION,
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_RULE_DEPEND =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_DEPEND_OPTION => OPTION_TYPE,
|
|
|
|
&OPTION_RULE_DEPEND_LIST =>
|
|
|
|
{
|
|
|
|
&RECOVERY_TYPE_NAME => true,
|
|
|
|
&RECOVERY_TYPE_TIME => true,
|
|
|
|
&RECOVERY_TYPE_XID => true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2015-01-23 03:11:33 +02:00
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_TARGET_TIMELINE =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_RESTORE =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
&OPTION_RULE_REQUIRED => false,
|
|
|
|
&OPTION_RULE_DEPEND =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_DEPEND_OPTION => OPTION_TYPE,
|
|
|
|
&OPTION_RULE_DEPEND_LIST =>
|
|
|
|
{
|
|
|
|
&RECOVERY_TYPE_DEFAULT => true,
|
|
|
|
&RECOVERY_TYPE_NAME => true,
|
|
|
|
&RECOVERY_TYPE_TIME => true,
|
2015-03-16 20:45:53 +02:00
|
|
|
&RECOVERY_TYPE_XID => true
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-12-16 00:20:42 +02:00
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_TYPE =>
|
2014-12-16 00:20:42 +02:00
|
|
|
{
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_BACKUP =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_BACKUP_TYPE,
|
|
|
|
&OPTION_RULE_ALLOW_LIST =>
|
|
|
|
{
|
|
|
|
&BACKUP_TYPE_FULL => true,
|
|
|
|
&BACKUP_TYPE_DIFF => true,
|
|
|
|
&BACKUP_TYPE_INCR => true,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_ALLOW_LIST =>
|
|
|
|
{
|
|
|
|
&DB => true,
|
|
|
|
&BACKUP => true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2016-08-24 18:39:27 +02:00
|
|
|
&CMD_REMOTE =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_ALLOW_LIST =>
|
|
|
|
{
|
|
|
|
&DB => true,
|
|
|
|
&BACKUP => true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_RESTORE =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_RESTORE_TYPE,
|
|
|
|
&OPTION_RULE_ALLOW_LIST =>
|
|
|
|
{
|
2016-01-14 03:35:12 +02:00
|
|
|
&RECOVERY_TYPE_NAME => true,
|
|
|
|
&RECOVERY_TYPE_TIME => true,
|
|
|
|
&RECOVERY_TYPE_XID => true,
|
|
|
|
&RECOVERY_TYPE_PRESERVE => true,
|
|
|
|
&RECOVERY_TYPE_NONE => true,
|
|
|
|
&RECOVERY_TYPE_IMMEDIATE => true,
|
|
|
|
&RECOVERY_TYPE_DEFAULT => true
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-12-16 00:20:42 +02:00
|
|
|
|
2015-06-14 00:25:49 +02:00
|
|
|
&OPTION_OUTPUT =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-06-14 00:25:49 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_INFO =>
|
2015-06-14 00:25:49 +02:00
|
|
|
{
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_INFO_OUTPUT,
|
|
|
|
&OPTION_RULE_ALLOW_LIST =>
|
|
|
|
{
|
|
|
|
&INFO_OUTPUT_TEXT => true,
|
|
|
|
&INFO_OUTPUT_JSON => true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-09-06 15:35:02 +02:00
|
|
|
# Command-line only local/remote
|
2015-10-08 17:43:56 +02:00
|
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
&OPTION_COMMAND =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL => true,
|
|
|
|
&CMD_REMOTE => true,
|
2015-10-08 17:43:56 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-09-06 15:35:02 +02:00
|
|
|
&OPTION_HOST_ID =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_INTEGER,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_LOCAL => true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2015-10-08 17:43:56 +02:00
|
|
|
&OPTION_PROCESS =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_INTEGER,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_REQUIRED => true,
|
|
|
|
},
|
|
|
|
&CMD_REMOTE =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_REQUIRED => false,
|
|
|
|
},
|
|
|
|
},
|
2015-10-08 17:43:56 +02:00
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# Command-line only test
|
2015-03-12 18:15:19 +02:00
|
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_TEST =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
|
2015-10-08 17:43:56 +02:00
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_TEST,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
|
|
|
&CMD_BACKUP => true
|
|
|
|
}
|
2015-03-12 18:15:19 +02:00
|
|
|
},
|
2014-12-16 00:20:42 +02:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_TEST_DELAY =>
|
2014-12-16 00:20:42 +02:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_FLOAT,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_TEST_DELAY,
|
|
|
|
&OPTION_RULE_DEPEND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_DEPEND_OPTION => OPTION_TEST,
|
|
|
|
&OPTION_RULE_DEPEND_VALUE => true
|
2015-10-08 17:43:56 +02:00
|
|
|
},
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
|
|
|
&CMD_BACKUP => true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
&OPTION_TEST_POINT =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_HASH,
|
|
|
|
&OPTION_RULE_REQUIRED => false,
|
|
|
|
&OPTION_RULE_DEPEND =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_DEPEND_OPTION => OPTION_TEST,
|
|
|
|
&OPTION_RULE_DEPEND_VALUE => true
|
|
|
|
},
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
|
|
|
&CMD_BACKUP => true
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# GENERAL Section
|
|
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
2016-06-12 15:13:46 +02:00
|
|
|
&OPTION_ARCHIVE_TIMEOUT =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_FLOAT,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_ARCHIVE_TIMEOUT,
|
|
|
|
&OPTION_RULE_ALLOW_RANGE => [OPTION_DEFAULT_ARCHIVE_TIMEOUT_MIN, OPTION_DEFAULT_ARCHIVE_TIMEOUT_MAX],
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
2017-01-27 18:02:27 +02:00
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
2016-06-12 15:13:46 +02:00
|
|
|
&CMD_BACKUP => true,
|
|
|
|
&CMD_CHECK => true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_BUFFER_SIZE =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-08-05 18:32:12 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_INTEGER,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_BUFFER_SIZE,
|
2015-09-08 13:31:24 +02:00
|
|
|
&OPTION_RULE_ALLOW_RANGE => [OPTION_DEFAULT_BUFFER_SIZE_MIN, OPTION_DEFAULT_BUFFER_SIZE_MAX],
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_ARCHIVE_GET => true,
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
|
|
|
&CMD_BACKUP => true,
|
2016-06-12 15:13:46 +02:00
|
|
|
&CMD_CHECK => true,
|
2015-09-08 13:31:24 +02:00
|
|
|
&CMD_EXPIRE => false,
|
|
|
|
&CMD_INFO => true,
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL => true,
|
2015-09-08 13:31:24 +02:00
|
|
|
&CMD_REMOTE => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_RESTORE => true,
|
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2015-09-08 13:31:24 +02:00
|
|
|
}
|
2015-03-12 18:15:19 +02:00
|
|
|
},
|
2014-12-16 00:20:42 +02:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_DB_TIMEOUT =>
|
2014-12-16 00:20:42 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2016-06-12 15:13:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_FLOAT,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_DB_TIMEOUT,
|
2016-06-12 15:13:46 +02:00
|
|
|
&OPTION_RULE_ALLOW_RANGE => [OPTION_DEFAULT_DB_TIMEOUT_MIN, OPTION_DEFAULT_DB_TIMEOUT_MAX],
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2014-12-16 00:20:42 +02:00
|
|
|
{
|
2016-06-23 00:01:18 +02:00
|
|
|
&CMD_ARCHIVE_GET => false,
|
|
|
|
&CMD_ARCHIVE_PUSH => false,
|
2015-08-05 18:32:12 +02:00
|
|
|
&CMD_BACKUP => true,
|
2016-06-12 15:13:46 +02:00
|
|
|
&CMD_CHECK => true,
|
2015-10-08 17:43:56 +02:00
|
|
|
&CMD_EXPIRE => false,
|
2016-06-23 00:01:18 +02:00
|
|
|
&CMD_INFO => false,
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL => true,
|
2015-10-08 17:43:56 +02:00
|
|
|
&CMD_REMOTE => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_RESTORE => false,
|
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2014-12-16 00:20:42 +02:00
|
|
|
}
|
2015-03-12 18:15:19 +02:00
|
|
|
},
|
2014-12-16 00:20:42 +02:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_COMPRESS =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_COMPRESS,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
&CMD_ARCHIVE_GET => true,
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
|
|
|
&CMD_BACKUP => true,
|
2015-09-08 13:31:24 +02:00
|
|
|
&CMD_EXPIRE => false,
|
2016-12-20 23:52:20 +02:00
|
|
|
&CMD_RESTORE => true,
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_COMPRESS_LEVEL =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_INTEGER,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_COMPRESS_LEVEL,
|
|
|
|
&OPTION_RULE_ALLOW_RANGE => [OPTION_DEFAULT_COMPRESS_LEVEL_MIN, OPTION_DEFAULT_COMPRESS_LEVEL_MAX],
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_ARCHIVE_GET => true,
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
2015-08-29 20:20:46 +02:00
|
|
|
&CMD_BACKUP => true,
|
2016-06-12 15:13:46 +02:00
|
|
|
&CMD_CHECK => true,
|
2015-09-08 13:31:24 +02:00
|
|
|
&CMD_EXPIRE => false,
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_INFO => true,
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL => true,
|
2015-08-29 20:20:46 +02:00
|
|
|
&CMD_REMOTE => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_RESTORE => true,
|
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
2015-03-12 18:15:19 +02:00
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_COMPRESS_LEVEL_NETWORK =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_INTEGER,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_COMPRESS_LEVEL_NETWORK,
|
|
|
|
&OPTION_RULE_ALLOW_RANGE => [OPTION_DEFAULT_COMPRESS_LEVEL_NETWORK_MIN, OPTION_DEFAULT_COMPRESS_LEVEL_NETWORK_MAX],
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_ARCHIVE_GET => true,
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
2015-08-29 20:20:46 +02:00
|
|
|
&CMD_BACKUP => true,
|
2016-06-12 15:13:46 +02:00
|
|
|
&CMD_CHECK => true,
|
2015-09-08 13:31:24 +02:00
|
|
|
&CMD_EXPIRE => false,
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_INFO => true,
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL => true,
|
2015-08-29 20:20:46 +02:00
|
|
|
&CMD_REMOTE => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_RESTORE => true,
|
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-07-23 19:11:38 +02:00
|
|
|
&OPTION_NEUTRAL_UMASK =>
|
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-07-23 19:11:38 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_NEUTRAL_UMASK,
|
2015-09-08 13:31:24 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_ARCHIVE_GET => true,
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
|
|
|
&CMD_BACKUP => true,
|
2016-06-12 15:13:46 +02:00
|
|
|
&CMD_CHECK => true,
|
2015-09-08 13:31:24 +02:00
|
|
|
&CMD_INFO => false,
|
|
|
|
&CMD_EXPIRE => false,
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL => true,
|
2015-09-08 13:31:24 +02:00
|
|
|
&CMD_REMOTE => true,
|
2015-10-08 17:43:56 +02:00
|
|
|
&CMD_RESTORE => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2015-10-08 17:43:56 +02:00
|
|
|
&CMD_START => false,
|
|
|
|
&CMD_STOP => false
|
2015-09-08 13:31:24 +02:00
|
|
|
}
|
2015-07-23 19:11:38 +02:00
|
|
|
},
|
|
|
|
|
2016-10-05 14:55:54 +02:00
|
|
|
&OPTION_CMD_SSH =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_CMD_SSH,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_ARCHIVE_GET => true,
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
|
|
|
&CMD_BACKUP => true,
|
|
|
|
&CMD_CHECK => true,
|
|
|
|
&CMD_INFO => true,
|
|
|
|
&CMD_LOCAL => true,
|
|
|
|
&CMD_RESTORE => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2016-10-05 14:55:54 +02:00
|
|
|
&CMD_START => true,
|
|
|
|
&CMD_STOP => true,
|
|
|
|
&CMD_EXPIRE => true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_LOCK_PATH =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_LOCK_PATH,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_ARCHIVE_GET => true,
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
|
|
|
&CMD_BACKUP => true,
|
2016-12-20 23:52:20 +02:00
|
|
|
&CMD_EXPIRE => true,
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_INFO => true,
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL => true,
|
2015-10-08 17:43:56 +02:00
|
|
|
&CMD_REMOTE => true,
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_RESTORE => true,
|
2016-12-20 23:52:20 +02:00
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2015-10-08 17:43:56 +02:00
|
|
|
&CMD_START => true,
|
|
|
|
&CMD_STOP => true,
|
2015-03-12 18:15:19 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_LOG_PATH =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_LOG_PATH,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_ARCHIVE_GET => true,
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
2015-09-08 13:31:24 +02:00
|
|
|
&CMD_BACKUP => true,
|
2016-06-12 15:13:46 +02:00
|
|
|
&CMD_CHECK => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_EXPIRE => true,
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_INFO => true,
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL => true,
|
2016-04-14 15:30:54 +02:00
|
|
|
&CMD_REMOTE => true,
|
|
|
|
&CMD_RESTORE => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2016-04-14 15:30:54 +02:00
|
|
|
&CMD_START => true,
|
|
|
|
&CMD_STOP => true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2016-12-10 16:06:45 +02:00
|
|
|
&OPTION_REPO_SYNC =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_REPO_SYNC,
|
|
|
|
&OPTION_RULE_NEGATE => true,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
|
|
|
&CMD_BACKUP => true,
|
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2016-12-10 16:06:45 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2016-06-23 00:01:18 +02:00
|
|
|
&OPTION_PROTOCOL_TIMEOUT =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_FLOAT,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_PROTOCOL_TIMEOUT,
|
|
|
|
&OPTION_RULE_ALLOW_RANGE => [OPTION_DEFAULT_PROTOCOL_TIMEOUT_MIN, OPTION_DEFAULT_PROTOCOL_TIMEOUT_MAX],
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_ARCHIVE_GET => true,
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
|
|
|
&CMD_BACKUP => true,
|
|
|
|
&CMD_CHECK => true,
|
|
|
|
&CMD_EXPIRE => false,
|
|
|
|
&CMD_INFO => true,
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL => true,
|
2016-06-23 00:01:18 +02:00
|
|
|
&CMD_REMOTE => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_RESTORE => true,
|
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2016-06-23 00:01:18 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-12-03 17:23:26 +02:00
|
|
|
&OPTION_REPO_LINK =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_REPO_LINK,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_BACKUP => true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_REPO_PATH =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_REPO_PATH,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_ARCHIVE_GET => true,
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
|
|
|
&CMD_BACKUP => true,
|
2016-06-12 15:13:46 +02:00
|
|
|
&CMD_CHECK => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_EXPIRE => true,
|
2016-04-14 15:30:54 +02:00
|
|
|
&CMD_INFO => true,
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL => true,
|
2016-04-14 15:30:54 +02:00
|
|
|
&CMD_REMOTE => true,
|
|
|
|
&CMD_RESTORE => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2016-04-14 15:30:54 +02:00
|
|
|
&CMD_START => true,
|
|
|
|
&CMD_STOP => true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
&OPTION_SPOOL_PATH =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_SPOOL_PATH,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_ARCHIVE_PUSH => true
|
|
|
|
},
|
|
|
|
&OPTION_RULE_DEPEND =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_DEPEND_OPTION => OPTION_ARCHIVE_ASYNC,
|
|
|
|
&OPTION_RULE_DEPEND_VALUE => true
|
2015-03-12 18:15:19 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2016-09-06 15:35:02 +02:00
|
|
|
&OPTION_PROCESS_MAX =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-09-06 15:35:02 +02:00
|
|
|
&OPTION_RULE_ALT_NAME => 'thread-max',
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_INTEGER,
|
2016-09-06 15:35:02 +02:00
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_PROCESS_MAX,
|
|
|
|
&OPTION_RULE_ALLOW_RANGE => [OPTION_DEFAULT_PROCESS_MAX_MIN, OPTION_DEFAULT_PROCESS_MAX_MAX],
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
2017-01-27 18:02:27 +02:00
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
2015-08-29 20:20:46 +02:00
|
|
|
&CMD_BACKUP => true,
|
|
|
|
&CMD_RESTORE => true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
# LOG Section
|
|
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
&OPTION_LOG_LEVEL_CONSOLE =>
|
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_LOG_LEVEL_CONSOLE,
|
|
|
|
&OPTION_RULE_ALLOW_LIST =>
|
|
|
|
{
|
|
|
|
lc(OFF) => true,
|
|
|
|
lc(ERROR) => true,
|
|
|
|
lc(WARN) => true,
|
|
|
|
lc(INFO) => true,
|
2016-04-15 04:50:02 +02:00
|
|
|
lc(DETAIL) => true,
|
2015-08-29 20:20:46 +02:00
|
|
|
lc(DEBUG) => true,
|
|
|
|
lc(TRACE) => true
|
2016-04-15 04:50:02 +02:00
|
|
|
},
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_ARCHIVE_GET => true,
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
|
|
|
&CMD_BACKUP => true,
|
2016-06-12 15:13:46 +02:00
|
|
|
&CMD_CHECK => true,
|
2015-08-29 20:20:46 +02:00
|
|
|
&CMD_EXPIRE => true,
|
|
|
|
&CMD_INFO => true,
|
2015-11-20 17:28:58 +02:00
|
|
|
&CMD_RESTORE => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2015-11-20 17:28:58 +02:00
|
|
|
&CMD_START => true,
|
|
|
|
&CMD_STOP => true
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
&OPTION_LOG_LEVEL_FILE =>
|
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_LOG_LEVEL_FILE,
|
|
|
|
&OPTION_RULE_ALLOW_LIST =>
|
|
|
|
{
|
|
|
|
lc(OFF) => true,
|
|
|
|
lc(ERROR) => true,
|
|
|
|
lc(WARN) => true,
|
|
|
|
lc(INFO) => true,
|
|
|
|
lc(DEBUG) => true,
|
2016-04-15 04:50:02 +02:00
|
|
|
lc(DETAIL) => true,
|
2015-08-29 20:20:46 +02:00
|
|
|
lc(TRACE) => true
|
|
|
|
},
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_ARCHIVE_GET => true,
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
|
|
|
&CMD_BACKUP => true,
|
2016-06-12 15:13:46 +02:00
|
|
|
&CMD_CHECK => true,
|
2015-08-29 20:20:46 +02:00
|
|
|
&CMD_EXPIRE => true,
|
|
|
|
&CMD_INFO => true,
|
2015-11-20 17:28:58 +02:00
|
|
|
&CMD_RESTORE => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2015-11-20 17:28:58 +02:00
|
|
|
&CMD_START => true,
|
|
|
|
&CMD_STOP => true
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-10-05 15:09:30 +02:00
|
|
|
&OPTION_LOG_LEVEL_STDERR =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_LOG_LEVEL_STDERR,
|
|
|
|
&OPTION_RULE_ALLOW_LIST =>
|
|
|
|
{
|
|
|
|
lc(OFF) => true,
|
|
|
|
lc(ERROR) => true,
|
|
|
|
lc(WARN) => true,
|
|
|
|
lc(INFO) => true,
|
|
|
|
lc(DETAIL) => true,
|
|
|
|
lc(DEBUG) => true,
|
|
|
|
lc(TRACE) => true
|
|
|
|
},
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_ARCHIVE_GET => true,
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
|
|
|
&CMD_BACKUP => true,
|
|
|
|
&CMD_CHECK => true,
|
|
|
|
&CMD_EXPIRE => true,
|
|
|
|
&CMD_INFO => true,
|
|
|
|
&CMD_RESTORE => true,
|
|
|
|
&CMD_START => true,
|
|
|
|
&CMD_STOP => true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-02-05 17:59:49 +02:00
|
|
|
&OPTION_LOG_TIMESTAMP =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_LOG_TIMESTAMP,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_ARCHIVE_GET => true,
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
|
|
|
&CMD_BACKUP => true,
|
|
|
|
&CMD_CHECK => true,
|
|
|
|
&CMD_EXPIRE => true,
|
|
|
|
&CMD_INFO => true,
|
|
|
|
&CMD_RESTORE => true,
|
|
|
|
&CMD_STANZA_CREATE => true,
|
|
|
|
&CMD_START => true,
|
|
|
|
&CMD_STOP => true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# ARCHIVE Section
|
|
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
&OPTION_ARCHIVE_ASYNC =>
|
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_ARCHIVE_ASYNC,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_ARCHIVE_PUSH => true
|
|
|
|
}
|
2015-03-12 18:15:19 +02:00
|
|
|
},
|
|
|
|
|
2017-01-27 18:02:27 +02:00
|
|
|
# Deprecated and to be removed
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_ARCHIVE_MAX_MB =>
|
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_INTEGER,
|
|
|
|
&OPTION_RULE_REQUIRED => false,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_ARCHIVE_PUSH => true
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-01-27 18:02:27 +02:00
|
|
|
&OPTION_ARCHIVE_QUEUE_MAX =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_INTEGER,
|
|
|
|
&OPTION_RULE_REQUIRED => false,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# BACKUP Section
|
|
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
2015-03-23 22:01:15 +02:00
|
|
|
&OPTION_BACKUP_ARCHIVE_CHECK =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
|
2015-03-23 22:01:15 +02:00
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_BACKUP_ARCHIVE_CHECK,
|
2016-07-02 15:02:55 +02:00
|
|
|
&OPTION_RULE_DEPEND =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_DEPEND_OPTION => OPTION_ONLINE,
|
|
|
|
&OPTION_RULE_DEPEND_VALUE => true,
|
|
|
|
},
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-07-02 15:02:55 +02:00
|
|
|
&CMD_BACKUP => true,
|
|
|
|
&CMD_CHECK => true,
|
|
|
|
},
|
2015-03-12 18:15:19 +02:00
|
|
|
},
|
|
|
|
|
2015-03-23 22:01:15 +02:00
|
|
|
&OPTION_BACKUP_ARCHIVE_COPY =>
|
2015-03-16 20:45:53 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-03-16 20:45:53 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
|
2015-03-23 22:01:15 +02:00
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_BACKUP_ARCHIVE_COPY,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-16 20:45:53 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_BACKUP =>
|
2015-03-16 20:45:53 +02:00
|
|
|
{
|
|
|
|
&OPTION_RULE_DEPEND =>
|
|
|
|
{
|
2015-03-23 22:01:15 +02:00
|
|
|
&OPTION_RULE_DEPEND_OPTION => OPTION_BACKUP_ARCHIVE_CHECK,
|
2015-03-16 20:45:53 +02:00
|
|
|
&OPTION_RULE_DEPEND_VALUE => true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-08-24 18:39:27 +02:00
|
|
|
&OPTION_BACKUP_CMD =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
|
|
|
&OPTION_RULE_DEFAULT => BACKREST_BIN,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_ARCHIVE_GET => true,
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
|
|
|
&CMD_BACKUP => true,
|
|
|
|
&CMD_CHECK => true,
|
|
|
|
&CMD_INFO => true,
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL => true,
|
2016-08-24 18:39:27 +02:00
|
|
|
&CMD_RESTORE => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2016-08-24 18:39:27 +02:00
|
|
|
&CMD_START => true,
|
|
|
|
&CMD_STOP => true,
|
|
|
|
},
|
|
|
|
&OPTION_RULE_DEPEND =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_DEPEND_OPTION => OPTION_BACKUP_HOST
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
&OPTION_BACKUP_CONFIG =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_CONFIG,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_ARCHIVE_GET => true,
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
|
|
|
&CMD_BACKUP => true,
|
|
|
|
&CMD_CHECK => true,
|
|
|
|
&CMD_INFO => true,
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL => true,
|
2016-08-24 18:39:27 +02:00
|
|
|
&CMD_RESTORE => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2016-08-24 18:39:27 +02:00
|
|
|
&CMD_START => true,
|
|
|
|
&CMD_STOP => true,
|
|
|
|
},
|
|
|
|
&OPTION_RULE_DEPEND =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_DEPEND_OPTION => OPTION_BACKUP_HOST
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_BACKUP_HOST =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
|
|
|
&OPTION_RULE_REQUIRED => false,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_ARCHIVE_GET => true,
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
2016-06-18 15:55:00 +02:00
|
|
|
&CMD_BACKUP => true,
|
2016-06-12 15:13:46 +02:00
|
|
|
&CMD_CHECK => true,
|
2016-06-18 15:55:00 +02:00
|
|
|
&CMD_EXPIRE => true,
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_INFO => true,
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL => true,
|
2016-06-18 15:55:00 +02:00
|
|
|
&CMD_RESTORE => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2016-06-18 15:55:00 +02:00
|
|
|
&CMD_START => true,
|
|
|
|
&CMD_STOP => true,
|
2015-08-29 20:20:46 +02:00
|
|
|
},
|
2015-03-12 18:15:19 +02:00
|
|
|
},
|
|
|
|
|
2016-08-25 17:25:46 +02:00
|
|
|
&OPTION_BACKUP_STANDBY =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_BACKUP_STANDBY,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_BACKUP => true,
|
|
|
|
&CMD_CHECK => true,
|
2016-12-20 23:52:20 +02:00
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2016-08-25 17:25:46 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_BACKUP_USER =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
2015-11-22 21:02:14 +02:00
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_BACKUP_USER,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_ARCHIVE_GET => true,
|
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
2016-06-12 15:13:46 +02:00
|
|
|
&CMD_CHECK => true,
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_INFO => true,
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL => true,
|
2016-08-24 18:39:27 +02:00
|
|
|
&CMD_RESTORE => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_STANZA_CREATE => true,
|
2016-08-24 18:39:27 +02:00
|
|
|
&CMD_START => true,
|
|
|
|
&CMD_STOP => true,
|
2015-08-29 20:20:46 +02:00
|
|
|
},
|
|
|
|
&OPTION_RULE_REQUIRED => false,
|
|
|
|
&OPTION_RULE_DEPEND =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_DEPEND_OPTION => OPTION_BACKUP_HOST
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-12-13 01:54:07 +02:00
|
|
|
&OPTION_CHECKSUM_PAGE =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
|
|
|
|
&OPTION_RULE_REQUIRED => false,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_BACKUP => true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_HARDLINK =>
|
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_BACKUP_HARDLINK,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_BACKUP => true
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_MANIFEST_SAVE_THRESHOLD =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_INTEGER,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_BACKUP_MANIFEST_SAVE_THRESHOLD,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-06-18 21:39:30 +02:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
&CMD_BACKUP => true
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RESUME =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_BACKUP_RESUME,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-06-18 21:39:30 +02:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
&CMD_BACKUP => true
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_START_FAST =>
|
2015-05-09 00:34:27 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-05-09 00:34:27 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_BACKUP_START_FAST,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-05-09 00:34:27 +02:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
&CMD_BACKUP => true
|
2015-05-09 00:34:27 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_STOP_AUTO =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_BACKUP_STOP_AUTO,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
&CMD_BACKUP => true
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# EXPIRE Section
|
|
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_RETENTION_ARCHIVE =>
|
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_INTEGER,
|
|
|
|
&OPTION_RULE_REQUIRED => false,
|
|
|
|
&OPTION_RULE_ALLOW_RANGE => [OPTION_DEFAULT_RETENTION_MIN, OPTION_DEFAULT_RETENTION_MAX],
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_BACKUP => true,
|
|
|
|
&CMD_EXPIRE => true
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
&OPTION_RETENTION_ARCHIVE_TYPE =>
|
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_RETENTION_ARCHIVE_TYPE,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_BACKUP => true,
|
|
|
|
&CMD_EXPIRE => true
|
2015-03-12 18:15:19 +02:00
|
|
|
},
|
|
|
|
&OPTION_RULE_ALLOW_LIST =>
|
|
|
|
{
|
|
|
|
&BACKUP_TYPE_FULL => 1,
|
|
|
|
&BACKUP_TYPE_DIFF => 1,
|
|
|
|
&BACKUP_TYPE_INCR => 1
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
&OPTION_RETENTION_DIFF =>
|
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_INTEGER,
|
|
|
|
&OPTION_RULE_REQUIRED => false,
|
|
|
|
&OPTION_RULE_ALLOW_RANGE => [OPTION_DEFAULT_RETENTION_MIN, OPTION_DEFAULT_RETENTION_MAX],
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_BACKUP => true,
|
|
|
|
&CMD_EXPIRE => true
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
&OPTION_RETENTION_FULL =>
|
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_INTEGER,
|
|
|
|
&OPTION_RULE_REQUIRED => false,
|
|
|
|
&OPTION_RULE_ALLOW_RANGE => [OPTION_DEFAULT_RETENTION_MIN, OPTION_DEFAULT_RETENTION_MAX],
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_BACKUP => true,
|
|
|
|
&CMD_EXPIRE => true
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
2015-05-07 02:24:34 +02:00
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# RESTORE Section
|
|
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
2016-05-11 15:21:39 +02:00
|
|
|
&OPTION_DB_INCLUDE =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_HASH,
|
|
|
|
&OPTION_RULE_HASH_VALUE => false,
|
|
|
|
&OPTION_RULE_REQUIRED => false,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_RESTORE => true
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
&OPTION_LINK_ALL =>
|
2015-05-07 02:24:34 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
|
2016-04-15 04:50:02 +02:00
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_LINK_ALL,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-05-07 02:24:34 +02:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
&CMD_RESTORE => true
|
2015-05-07 02:24:34 +02:00
|
|
|
}
|
2015-05-07 18:29:30 +02:00
|
|
|
},
|
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
&OPTION_LINK_MAP =>
|
2015-05-07 18:29:30 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_HASH,
|
|
|
|
&OPTION_RULE_REQUIRED => false,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-05-07 18:29:30 +02:00
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
&CMD_RESTORE => true
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
&OPTION_TABLESPACE_MAP_ALL =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
|
|
|
&OPTION_RULE_REQUIRED => false,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_RESTORE => true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
&OPTION_TABLESPACE_MAP =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_HASH,
|
|
|
|
&OPTION_RULE_REQUIRED => false,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_RESTORE => true
|
2015-08-29 20:20:46 +02:00
|
|
|
},
|
2015-03-12 18:15:19 +02:00
|
|
|
},
|
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
&OPTION_RESTORE_RECOVERY_OPTION =>
|
2015-08-08 23:11:20 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_HASH,
|
|
|
|
&OPTION_RULE_REQUIRED => false,
|
2015-08-08 23:11:20 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
&CMD_RESTORE => true
|
2015-08-29 20:20:46 +02:00
|
|
|
},
|
|
|
|
&OPTION_RULE_DEPEND =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_DEPEND_OPTION => OPTION_TYPE,
|
|
|
|
&OPTION_RULE_DEPEND_LIST =>
|
|
|
|
{
|
|
|
|
&RECOVERY_TYPE_DEFAULT => true,
|
|
|
|
&RECOVERY_TYPE_NAME => true,
|
|
|
|
&RECOVERY_TYPE_TIME => true,
|
|
|
|
&RECOVERY_TYPE_XID => true
|
|
|
|
}
|
2015-08-08 23:11:20 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# STANZA Section
|
|
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
2016-08-24 18:39:27 +02:00
|
|
|
&OPTION_DB_CMD =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
|
|
|
&OPTION_RULE_PREFIX => OPTION_PREFIX_DB,
|
|
|
|
&OPTION_RULE_DEFAULT => BACKREST_BIN,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_BACKUP => true,
|
|
|
|
&CMD_CHECK => true,
|
|
|
|
&CMD_EXPIRE => true,
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2016-08-24 18:39:27 +02:00
|
|
|
&CMD_START => true,
|
|
|
|
&CMD_STOP => true,
|
|
|
|
},
|
|
|
|
&OPTION_RULE_DEPEND =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_DEPEND_OPTION => OPTION_DB_HOST
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
&OPTION_DB_CONFIG =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
|
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
|
|
|
&OPTION_RULE_PREFIX => OPTION_PREFIX_DB,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_CONFIG,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_BACKUP => true,
|
|
|
|
&CMD_CHECK => true,
|
|
|
|
&CMD_EXPIRE => true,
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2016-08-24 18:39:27 +02:00
|
|
|
&CMD_START => true,
|
|
|
|
&CMD_STOP => true,
|
|
|
|
},
|
|
|
|
&OPTION_RULE_DEPEND =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_DEPEND_OPTION => OPTION_DB_HOST
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_DB_HOST =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_STANZA,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
2016-08-24 18:39:27 +02:00
|
|
|
&OPTION_RULE_PREFIX => OPTION_PREFIX_DB,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_REQUIRED => false,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2017-01-27 18:02:27 +02:00
|
|
|
&CMD_ARCHIVE_PUSH => true,
|
2016-06-18 15:55:00 +02:00
|
|
|
&CMD_BACKUP => true,
|
|
|
|
&CMD_CHECK => true,
|
|
|
|
&CMD_EXPIRE => true,
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2016-06-18 15:55:00 +02:00
|
|
|
&CMD_START => true,
|
|
|
|
&CMD_STOP => true,
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_DB_PATH =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_STANZA,
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
2016-08-24 18:39:27 +02:00
|
|
|
&OPTION_RULE_PREFIX => OPTION_PREFIX_DB,
|
|
|
|
&OPTION_RULE_REQUIRED => true,
|
2016-05-14 16:36:35 +02:00
|
|
|
&OPTION_RULE_HINT => "does this stanza exist?",
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
&CMD_ARCHIVE_GET =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_REQUIRED => false
|
|
|
|
},
|
|
|
|
&CMD_ARCHIVE_PUSH =>
|
|
|
|
{
|
|
|
|
&OPTION_RULE_REQUIRED => false
|
|
|
|
},
|
2016-06-12 15:13:46 +02:00
|
|
|
&CMD_BACKUP => true,
|
2016-07-19 21:26:41 +02:00
|
|
|
&CMD_CHECK => true,
|
2016-06-18 15:55:00 +02:00
|
|
|
&CMD_RESTORE => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2015-08-29 20:20:46 +02:00
|
|
|
},
|
2015-03-12 18:15:19 +02:00
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_DB_PORT =>
|
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_STANZA,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_INTEGER,
|
2016-08-24 18:39:27 +02:00
|
|
|
&OPTION_RULE_PREFIX => OPTION_PREFIX_DB,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_DB_PORT,
|
2015-08-09 00:22:38 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
|
|
|
{
|
|
|
|
&CMD_BACKUP => true,
|
2016-06-12 15:13:46 +02:00
|
|
|
&CMD_CHECK => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_REMOTE => true,
|
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2015-08-09 00:22:38 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_DB_SOCKET_PATH =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_STANZA,
|
2016-08-24 18:39:27 +02:00
|
|
|
&OPTION_RULE_PREFIX => OPTION_PREFIX_DB,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_RULE_REQUIRED => false,
|
2015-06-18 22:55:09 +02:00
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
&CMD_BACKUP => true,
|
2016-06-12 15:13:46 +02:00
|
|
|
&CMD_CHECK => true,
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL => true,
|
|
|
|
&CMD_REMOTE => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_DB_USER =>
|
2014-12-16 00:20:42 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
&OPTION_RULE_SECTION => CONFIG_SECTION_STANZA,
|
2016-08-24 18:39:27 +02:00
|
|
|
&OPTION_RULE_PREFIX => OPTION_PREFIX_DB,
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_TYPE => OPTION_TYPE_STRING,
|
|
|
|
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_DB_USER,
|
|
|
|
&OPTION_RULE_COMMAND =>
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-06-12 15:13:46 +02:00
|
|
|
&CMD_BACKUP => true,
|
|
|
|
&CMD_CHECK => true,
|
2016-09-06 15:35:02 +02:00
|
|
|
&CMD_LOCAL => true,
|
2016-10-14 13:21:47 +02:00
|
|
|
&CMD_STANZA_CREATE => true,
|
2017-04-03 16:42:55 +02:00
|
|
|
&CMD_STANZA_UPGRADE => true,
|
2015-08-29 20:20:46 +02:00
|
|
|
},
|
|
|
|
&OPTION_RULE_REQUIRED => false,
|
2015-03-12 18:15:19 +02:00
|
|
|
&OPTION_RULE_DEPEND =>
|
2014-12-16 00:20:42 +02:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
&OPTION_RULE_DEPEND_OPTION => OPTION_DB_HOST
|
2016-08-24 18:39:27 +02:00
|
|
|
},
|
|
|
|
},
|
2015-03-12 18:15:19 +02:00
|
|
|
);
|
2014-12-16 00:20:42 +02:00
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
####################################################################################################################################
|
2016-08-24 18:39:27 +02:00
|
|
|
# Module variables
|
2015-03-12 18:15:19 +02:00
|
|
|
####################################################################################################################################
|
2015-07-02 16:05:13 +02:00
|
|
|
my %oOption; # Option hash
|
|
|
|
my $strCommand; # Command (backup, archive-get, ...)
|
2016-12-04 01:01:17 +02:00
|
|
|
my $bInitLog = false; # Has logging been initialized yet?
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# configLogging
|
|
|
|
#
|
|
|
|
# Configure logging based on options.
|
|
|
|
####################################################################################################################################
|
|
|
|
sub configLogging
|
|
|
|
{
|
|
|
|
my $bLogInitForce = shift;
|
|
|
|
|
2016-12-05 00:51:00 +02:00
|
|
|
if ($bInitLog || (defined($bLogInitForce) && $bLogInitForce))
|
2016-12-04 01:01:17 +02:00
|
|
|
{
|
|
|
|
logLevelSet(
|
|
|
|
optionValid(OPTION_LOG_LEVEL_FILE) ? optionGet(OPTION_LOG_LEVEL_FILE) : OFF,
|
|
|
|
optionValid(OPTION_LOG_LEVEL_CONSOLE) ? optionGet(OPTION_LOG_LEVEL_CONSOLE) : OFF,
|
2017-02-05 17:59:49 +02:00
|
|
|
optionValid(OPTION_LOG_LEVEL_STDERR) ? optionGet(OPTION_LOG_LEVEL_STDERR) : OFF,
|
|
|
|
optionValid(OPTION_LOG_TIMESTAMP) ? optionGet(OPTION_LOG_TIMESTAMP) : undef);
|
2016-12-04 01:01:17 +02:00
|
|
|
|
|
|
|
$bInitLog = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(configLogging);
|
2014-12-16 00:20:42 +02:00
|
|
|
|
2015-01-31 22:37:59 +02:00
|
|
|
####################################################################################################################################
|
2015-03-12 18:15:19 +02:00
|
|
|
# configLoad
|
|
|
|
#
|
2016-09-07 14:07:37 +02:00
|
|
|
# Load configuration. Additional conditions that cannot be codified by the OptionRule hash are also tested here.
|
2015-01-31 22:37:59 +02:00
|
|
|
####################################################################################################################################
|
2015-03-12 18:15:19 +02:00
|
|
|
sub configLoad
|
2015-01-31 22:37:59 +02:00
|
|
|
{
|
2016-09-07 14:07:37 +02:00
|
|
|
my $bInitLogging = shift;
|
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
# Clear option in case it was loaded before
|
|
|
|
%oOption = ();
|
|
|
|
|
2016-08-24 18:39:27 +02:00
|
|
|
# Build options for all possible db configurations
|
|
|
|
foreach my $strKey (sort(keys(%oOptionRule)))
|
|
|
|
{
|
|
|
|
if (defined($oOptionRule{$strKey}{&OPTION_RULE_PREFIX}) && $oOptionRule{$strKey}{&OPTION_RULE_PREFIX} eq OPTION_PREFIX_DB)
|
|
|
|
{
|
|
|
|
my $strPrefix = $oOptionRule{$strKey}{&OPTION_RULE_PREFIX};
|
|
|
|
|
|
|
|
# For now only allow one replica
|
|
|
|
for (my $iIndex = 2; $iIndex <= 2; $iIndex++)
|
|
|
|
{
|
|
|
|
my $strKeyNew = "${strPrefix}${iIndex}" . substr($strKey, length($strPrefix));
|
|
|
|
|
|
|
|
$oOptionRule{$strKeyNew} = dclone($oOptionRule{$strKey});
|
|
|
|
$oOptionRule{$strKeyNew}{&OPTION_RULE_REQUIRED} = false;
|
|
|
|
|
|
|
|
if (defined($oOptionRule{$strKeyNew}{&OPTION_RULE_DEPEND}) &&
|
|
|
|
defined($oOptionRule{$strKeyNew}{&OPTION_RULE_DEPEND}{&OPTION_RULE_DEPEND_OPTION}))
|
|
|
|
{
|
|
|
|
$oOptionRule{$strKeyNew}{&OPTION_RULE_DEPEND}{&OPTION_RULE_DEPEND_OPTION} =
|
|
|
|
"${strPrefix}${iIndex}" .
|
|
|
|
substr($oOptionRule{$strKeyNew}{&OPTION_RULE_DEPEND}{&OPTION_RULE_DEPEND_OPTION}, length($strPrefix));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Create an alternate name for the base db option
|
|
|
|
$oOptionRule{$strKey}{&OPTION_RULE_ALT_NAME} = "${strPrefix}1" . substr($strKey, length($strPrefix));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
# Build hash with all valid command-line options
|
|
|
|
my %oOptionAllow;
|
2015-01-31 22:37:59 +02:00
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
foreach my $strKey (keys(%oOptionRule))
|
2015-01-31 22:37:59 +02:00
|
|
|
{
|
2016-08-24 18:39:27 +02:00
|
|
|
foreach my $bAltName ((false, true))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-08-24 18:39:27 +02:00
|
|
|
my $strOptionName = $strKey;
|
|
|
|
|
|
|
|
if ($bAltName)
|
|
|
|
{
|
|
|
|
if (!defined($oOptionRule{$strKey}{&OPTION_RULE_ALT_NAME}))
|
|
|
|
{
|
|
|
|
next;
|
|
|
|
}
|
2015-03-12 18:15:19 +02:00
|
|
|
|
2016-08-24 18:39:27 +02:00
|
|
|
$strOptionName = $oOptionRule{$strKey}{&OPTION_RULE_ALT_NAME};
|
|
|
|
}
|
|
|
|
|
|
|
|
my $strOption = $strOptionName;
|
|
|
|
|
|
|
|
if (!defined($oOptionRule{$strKey}{&OPTION_RULE_TYPE}))
|
|
|
|
{
|
|
|
|
confess &log(ASSERT, "Option ${strKey} does not have a defined type", ERROR_ASSERT);
|
|
|
|
}
|
|
|
|
elsif ($oOptionRule{$strKey}{&OPTION_RULE_TYPE} eq OPTION_TYPE_HASH)
|
|
|
|
{
|
|
|
|
$strOption .= '=s@';
|
|
|
|
}
|
|
|
|
elsif ($oOptionRule{$strKey}{&OPTION_RULE_TYPE} ne OPTION_TYPE_BOOLEAN)
|
|
|
|
{
|
|
|
|
$strOption .= '=s';
|
|
|
|
}
|
2015-03-12 18:15:19 +02:00
|
|
|
|
|
|
|
$oOptionAllow{$strOption} = $strOption;
|
2016-08-24 18:39:27 +02:00
|
|
|
|
|
|
|
# Check if the option can be negated
|
|
|
|
if ((defined($oOptionRule{$strKey}{&OPTION_RULE_NEGATE}) &&
|
|
|
|
$oOptionRule{$strKey}{&OPTION_RULE_NEGATE}) ||
|
|
|
|
($oOptionRule{$strKey}{&OPTION_RULE_TYPE} eq OPTION_TYPE_BOOLEAN &&
|
|
|
|
defined($oOptionRule{$strKey}{&OPTION_RULE_SECTION})))
|
|
|
|
{
|
|
|
|
$strOption = 'no-' . $strOptionName;
|
|
|
|
$oOptionAllow{$strOption} = $strOption;
|
|
|
|
$oOptionRule{$strKey}{&OPTION_RULE_NEGATE} = true;
|
|
|
|
}
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
2015-01-31 22:37:59 +02:00
|
|
|
}
|
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
# Get command-line options
|
|
|
|
my %oOptionTest;
|
2015-01-31 22:37:59 +02:00
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
# If nothing was passed on the command line then display help
|
|
|
|
if (@ARGV == 0)
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-09-08 13:31:24 +02:00
|
|
|
commandSet(CMD_HELP);
|
|
|
|
}
|
|
|
|
# Else process command line options
|
|
|
|
else
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-09-08 13:31:24 +02:00
|
|
|
# Parse command line options
|
|
|
|
if (!GetOptions(\%oOptionTest, %oOptionAllow))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-09-08 13:31:24 +02:00
|
|
|
commandSet(CMD_HELP);
|
|
|
|
return false;
|
|
|
|
}
|
2016-08-24 18:39:27 +02:00
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
# Validate and store options
|
2016-08-24 18:39:27 +02:00
|
|
|
my $bHelp = false;
|
2015-09-08 13:31:24 +02:00
|
|
|
|
2016-08-24 18:39:27 +02:00
|
|
|
if (defined($ARGV[0]) && $ARGV[0] eq CMD_HELP && defined($ARGV[1]))
|
|
|
|
{
|
|
|
|
$bHelp = true;
|
|
|
|
$ARGV[0] = $ARGV[1];
|
|
|
|
}
|
2015-09-08 13:31:24 +02:00
|
|
|
|
2016-08-24 18:39:27 +02:00
|
|
|
optionValidate(\%oOptionTest, $bHelp);
|
2015-09-08 13:31:24 +02:00
|
|
|
|
2016-08-24 18:39:27 +02:00
|
|
|
if ($bHelp)
|
|
|
|
{
|
|
|
|
commandSet(CMD_HELP);
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-07 14:07:37 +02:00
|
|
|
# If this is not the remote and logging is allowed (to not overwrite log levels for tests) then set the log level so that
|
2016-12-04 01:01:17 +02:00
|
|
|
# INFO/WARN messages can be displayed (the user may still disable them). This should be run before any WARN logging is
|
|
|
|
# generated.
|
|
|
|
if (!defined($bInitLogging) || $bInitLogging)
|
2016-09-07 14:07:37 +02:00
|
|
|
{
|
2016-12-04 01:01:17 +02:00
|
|
|
configLogging(true);
|
2016-09-07 14:07:37 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 21:44:53 +02:00
|
|
|
# Log the command begin
|
|
|
|
commandBegin();
|
|
|
|
|
|
|
|
# Return and display version and help in main
|
|
|
|
if (commandTest(CMD_HELP) || commandTest(CMD_VERSION))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-07-23 19:11:38 +02:00
|
|
|
# Neutralize the umask to make the repository file/path modes more consistent
|
2016-06-18 15:55:00 +02:00
|
|
|
if (optionTest(OPTION_NEUTRAL_UMASK) && optionGet(OPTION_NEUTRAL_UMASK))
|
2015-07-23 19:11:38 +02:00
|
|
|
{
|
|
|
|
umask(0000);
|
|
|
|
}
|
|
|
|
|
2016-06-23 00:01:18 +02:00
|
|
|
# Protocol timeout should be greater than db timeout
|
|
|
|
if (optionTest(OPTION_DB_TIMEOUT) && optionTest(OPTION_PROTOCOL_TIMEOUT) &&
|
|
|
|
optionGet(OPTION_PROTOCOL_TIMEOUT) <= optionGet(OPTION_DB_TIMEOUT))
|
|
|
|
{
|
2016-08-25 17:27:00 +02:00
|
|
|
# If protocol-timeout is default then increase it to be greater than db-timeout
|
|
|
|
if (optionSource(OPTION_PROTOCOL_TIMEOUT) eq SOURCE_DEFAULT)
|
|
|
|
{
|
|
|
|
optionSet(OPTION_PROTOCOL_TIMEOUT, optionGet(OPTION_DB_TIMEOUT) + 30);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
confess &log(ERROR,
|
|
|
|
"'" . optionGet(OPTION_PROTOCOL_TIMEOUT) . "' is not valid for '" . OPTION_PROTOCOL_TIMEOUT . "' option\n" .
|
|
|
|
"HINT: 'protocol-timeout' option should be greater than 'db-timeout' option.",
|
|
|
|
ERROR_OPTION_INVALID_VALUE);
|
|
|
|
}
|
2016-06-23 00:01:18 +02:00
|
|
|
}
|
|
|
|
|
2016-08-24 18:39:27 +02:00
|
|
|
# Make sure that backup and db are not both remote
|
|
|
|
if (optionTest(OPTION_DB_HOST) && optionTest(OPTION_BACKUP_HOST))
|
2015-04-01 21:58:33 +02:00
|
|
|
{
|
2016-08-24 18:39:27 +02:00
|
|
|
confess &log(ERROR, 'db and backup cannot both be configured as remote', ERROR_CONFIG);
|
2015-04-01 21:58:33 +02:00
|
|
|
}
|
|
|
|
|
2016-09-07 14:07:37 +02:00
|
|
|
# Warn when retention-full is not set
|
|
|
|
if (optionValid(OPTION_RETENTION_FULL) && !optionTest(OPTION_RETENTION_FULL))
|
|
|
|
{
|
|
|
|
&log(WARN,
|
|
|
|
"option retention-full is not set, the repository may run out of space\n" .
|
|
|
|
"HINT: to retain full backups indefinitely (without warning), set option 'retention-full' to the maximum.");
|
|
|
|
}
|
|
|
|
|
|
|
|
# If archive retention is valid for the command, then set archive settings
|
|
|
|
if (optionValid(OPTION_RETENTION_ARCHIVE))
|
|
|
|
{
|
|
|
|
my $strArchiveRetentionType = optionGet(OPTION_RETENTION_ARCHIVE_TYPE, false);
|
|
|
|
my $iArchiveRetention = optionGet(OPTION_RETENTION_ARCHIVE, false);
|
|
|
|
my $iFullRetention = optionGet(OPTION_RETENTION_FULL, false);
|
|
|
|
my $iDifferentialRetention = optionGet(OPTION_RETENTION_DIFF, false);
|
|
|
|
|
|
|
|
my $strMsgArchiveOff = "WAL segments will not be expired: option '" . &OPTION_RETENTION_ARCHIVE_TYPE .
|
|
|
|
"=${strArchiveRetentionType}' but ";
|
|
|
|
|
|
|
|
# If the archive retention is not explicitly set then determine what it should be set to so the user does not have to.
|
|
|
|
if (!defined($iArchiveRetention))
|
|
|
|
{
|
|
|
|
# If retention-archive-type is default, then if retention-full is set, set the retention-archive to this value,
|
|
|
|
# else ignore archiving
|
|
|
|
if ($strArchiveRetentionType eq BACKUP_TYPE_FULL)
|
|
|
|
{
|
|
|
|
if (defined($iFullRetention))
|
|
|
|
{
|
|
|
|
optionSet(OPTION_RETENTION_ARCHIVE, $iFullRetention);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif ($strArchiveRetentionType eq BACKUP_TYPE_DIFF)
|
|
|
|
{
|
|
|
|
# if retention-diff is set then user must have set it
|
|
|
|
if (defined($iDifferentialRetention))
|
|
|
|
{
|
|
|
|
optionSet(OPTION_RETENTION_ARCHIVE, $iDifferentialRetention);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
&log(WARN,
|
|
|
|
$strMsgArchiveOff . "neither option '" . &OPTION_RETENTION_ARCHIVE .
|
|
|
|
"' nor option '" . &OPTION_RETENTION_DIFF . "' is set");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif ($strArchiveRetentionType eq BACKUP_TYPE_INCR)
|
|
|
|
{
|
|
|
|
&log(WARN, $strMsgArchiveOff . "option '" . &OPTION_RETENTION_ARCHIVE . "' is not set");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
# If retention-archive is set then check retention-archive-type and issue a warning if the corresponding setting is
|
|
|
|
# UNDEF since UNDEF means backups will not be expired but they should be in the practice of setting this
|
|
|
|
# value even though expiring the archive itself is OK and will be performed.
|
|
|
|
if ($strArchiveRetentionType eq BACKUP_TYPE_DIFF && !defined($iDifferentialRetention))
|
|
|
|
{
|
|
|
|
&log(WARN,
|
|
|
|
"option '" . &OPTION_RETENTION_DIFF . "' is not set for '" . &OPTION_RETENTION_ARCHIVE_TYPE . "=" .
|
|
|
|
&BACKUP_TYPE_DIFF . "' \n" .
|
|
|
|
"HINT: to retain differential backups indefinitely (without warning), set option '" .
|
|
|
|
&OPTION_RETENTION_DIFF . "' to the maximum.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-27 18:02:27 +02:00
|
|
|
# Warn if ARCHIVE_MAX_MB is present
|
|
|
|
if (optionValid(OPTION_ARCHIVE_MAX_MB) && optionTest(OPTION_ARCHIVE_MAX_MB))
|
|
|
|
{
|
|
|
|
&log(WARN, "'" . OPTION_ARCHIVE_MAX_MB . "' is no longer not longer valid, use '" . OPTION_ARCHIVE_QUEUE_MAX . "' instead");
|
|
|
|
}
|
|
|
|
|
2016-08-24 18:39:27 +02:00
|
|
|
return true;
|
|
|
|
}
|
2015-09-08 13:31:24 +02:00
|
|
|
|
2016-08-24 18:39:27 +02:00
|
|
|
push @EXPORT, qw(configLoad);
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# optionValueGet
|
|
|
|
#
|
|
|
|
# Find the value of an option using both the regular and alt values. Error if both are defined.
|
|
|
|
####################################################################################################################################
|
|
|
|
sub optionValueGet
|
|
|
|
{
|
|
|
|
my $strOption = shift;
|
|
|
|
my $hOption = shift;
|
|
|
|
|
|
|
|
my $strValue = $$hOption{$strOption};
|
|
|
|
|
|
|
|
# Some options have an alternate name so check for that as well
|
|
|
|
if (defined($oOptionRule{$strOption}{&OPTION_RULE_ALT_NAME}))
|
2016-07-30 14:49:26 +02:00
|
|
|
{
|
2016-08-24 18:39:27 +02:00
|
|
|
my $strAltValue = $$hOption{$oOptionRule{$strOption}{&OPTION_RULE_ALT_NAME}};
|
|
|
|
|
|
|
|
if (defined($strAltValue))
|
|
|
|
{
|
|
|
|
if (!defined($strValue))
|
|
|
|
{
|
|
|
|
$strValue = $strAltValue;
|
2016-12-04 16:25:40 +02:00
|
|
|
|
|
|
|
delete($hOption->{$oOptionRule{$strOption}{&OPTION_RULE_ALT_NAME}});
|
|
|
|
$hOption->{$strOption} = $strValue;
|
2016-08-24 18:39:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
confess &log(
|
|
|
|
ERROR, "'${strOption}' and '" . $oOptionRule{$strOption}{&OPTION_RULE_ALT_NAME} .
|
|
|
|
' cannot both be defined', ERROR_OPTION_INVALID_VALUE);
|
|
|
|
}
|
|
|
|
}
|
2016-07-30 14:49:26 +02:00
|
|
|
}
|
|
|
|
|
2016-08-24 18:39:27 +02:00
|
|
|
return $strValue;
|
2015-01-31 22:37:59 +02:00
|
|
|
}
|
2015-01-31 20:48:09 +02:00
|
|
|
|
|
|
|
####################################################################################################################################
|
2016-06-18 15:55:00 +02:00
|
|
|
# optionValidate
|
2015-01-31 20:48:09 +02:00
|
|
|
#
|
2015-06-18 22:55:09 +02:00
|
|
|
# Make sure the command-line options are valid based on the command.
|
2015-01-31 20:48:09 +02:00
|
|
|
####################################################################################################################################
|
2016-06-18 15:55:00 +02:00
|
|
|
sub optionValidate
|
2015-01-31 20:48:09 +02:00
|
|
|
{
|
2015-03-12 18:15:19 +02:00
|
|
|
my $oOptionTest = shift;
|
2015-09-08 13:31:24 +02:00
|
|
|
my $bHelp = shift;
|
2015-03-12 18:15:19 +02:00
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
# Check that the command is present and valid
|
|
|
|
$strCommand = $ARGV[0];
|
2015-03-12 18:15:19 +02:00
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
if (!defined($strCommand))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
confess &log(ERROR, "command must be specified", ERROR_COMMAND_REQUIRED);
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
if (!defined($oCommandHash{$strCommand}))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
confess &log(ERROR, "invalid command ${strCommand}", ERROR_COMMAND_INVALID);
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
2015-01-31 20:48:09 +02:00
|
|
|
|
2016-02-06 23:49:12 +02:00
|
|
|
# Hash to store contents of the config file. The file will be loaded once the config dependency is resolved unless all options
|
2015-03-12 18:15:19 +02:00
|
|
|
# are set on the command line or --no-config is specified.
|
|
|
|
my $oConfig;
|
|
|
|
my $bConfigExists = true;
|
|
|
|
|
|
|
|
# Keep track of unresolved dependencies
|
|
|
|
my $bDependUnresolved = true;
|
|
|
|
my %oOptionResolved;
|
|
|
|
|
|
|
|
# Loop through all possible options
|
|
|
|
while ($bDependUnresolved)
|
|
|
|
{
|
|
|
|
# Assume that all dependencies will be resolved in this loop
|
|
|
|
$bDependUnresolved = false;
|
|
|
|
|
|
|
|
foreach my $strOption (sort(keys(%oOptionRule)))
|
2015-01-31 20:48:09 +02:00
|
|
|
{
|
2015-03-12 18:15:19 +02:00
|
|
|
# Skip the option if it has been resolved in a prior loop
|
|
|
|
if (defined($oOptionResolved{$strOption}))
|
2015-01-31 20:48:09 +02:00
|
|
|
{
|
2015-03-12 18:15:19 +02:00
|
|
|
next;
|
2015-01-31 20:48:09 +02:00
|
|
|
}
|
2015-01-31 22:37:59 +02:00
|
|
|
|
2016-06-18 15:55:00 +02:00
|
|
|
# The command rules must be explicitly set
|
|
|
|
if (!defined($oOptionRule{$strOption}{&OPTION_RULE_COMMAND}))
|
|
|
|
{
|
|
|
|
confess &log(ASSERT, OPTION_RULE_COMMAND . " rules must be set for '${strOption}' option");
|
|
|
|
}
|
|
|
|
|
|
|
|
# Determine if an option is valid for a command
|
|
|
|
if (!defined($oOptionRule{$strOption}{&OPTION_RULE_COMMAND}{$strCommand}))
|
|
|
|
{
|
|
|
|
$oOption{$strOption}{valid} = false;
|
|
|
|
$oOptionResolved{$strOption} = true;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
$oOption{$strOption}{valid} = true;
|
|
|
|
|
2016-08-24 18:39:27 +02:00
|
|
|
# Store the option value
|
|
|
|
my $strValue = optionValueGet($strOption, $oOptionTest);
|
2015-03-03 03:36:12 +02:00
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
# Check to see if an option can be negated. Make sure that it is not set and negated at the same time.
|
|
|
|
my $bNegate = false;
|
2015-03-03 03:36:12 +02:00
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
if (defined($oOptionRule{$strOption}{&OPTION_RULE_NEGATE}) && $oOptionRule{$strOption}{&OPTION_RULE_NEGATE})
|
|
|
|
{
|
|
|
|
$bNegate = defined($$oOptionTest{'no-' . $strOption});
|
2015-03-03 05:58:32 +02:00
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
if ($bNegate && defined($strValue))
|
|
|
|
{
|
|
|
|
confess &log(ERROR, "option '${strOption}' cannot be both set and negated", ERROR_OPTION_NEGATE);
|
|
|
|
}
|
2015-04-08 00:36:59 +02:00
|
|
|
|
2015-04-08 01:21:48 +02:00
|
|
|
if ($bNegate && $oOptionRule{$strOption}{&OPTION_RULE_TYPE} eq OPTION_TYPE_BOOLEAN)
|
2015-04-08 00:36:59 +02:00
|
|
|
{
|
|
|
|
$strValue = false;
|
|
|
|
}
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
2015-03-03 05:58:32 +02:00
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
# If the command has rules store them for later evaluation
|
|
|
|
my $oCommandRule = optionCommandRule($strOption, $strCommand);
|
2015-04-01 21:58:33 +02:00
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
# Check dependency for the command then for the option
|
2015-04-01 21:58:33 +02:00
|
|
|
my $bDependResolved = true;
|
2015-06-18 22:55:09 +02:00
|
|
|
my $oDepend = defined($oCommandRule) ? $$oCommandRule{&OPTION_RULE_DEPEND} :
|
|
|
|
$oOptionRule{$strOption}{&OPTION_RULE_DEPEND};
|
2015-04-01 21:58:33 +02:00
|
|
|
my $strDependOption;
|
|
|
|
my $strDependValue;
|
|
|
|
my $strDependType;
|
|
|
|
|
|
|
|
if (defined($oDepend))
|
|
|
|
{
|
|
|
|
# Check if the depend option has a value
|
|
|
|
$strDependOption = $$oDepend{&OPTION_RULE_DEPEND_OPTION};
|
2015-04-19 23:29:52 +02:00
|
|
|
$strDependValue = $oOption{$strDependOption}{value};
|
2015-04-01 21:58:33 +02:00
|
|
|
|
|
|
|
# Make sure the depend option has been resolved, otherwise skip this option for now
|
|
|
|
if (!defined($oOptionResolved{$strDependOption}))
|
|
|
|
{
|
|
|
|
$bDependUnresolved = true;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!defined($strDependValue))
|
|
|
|
{
|
|
|
|
$bDependResolved = false;
|
|
|
|
$strDependType = 'source';
|
|
|
|
}
|
|
|
|
|
|
|
|
# If a depend value exists, make sure the option value matches
|
|
|
|
if ($bDependResolved && defined($$oDepend{&OPTION_RULE_DEPEND_VALUE}) &&
|
|
|
|
$$oDepend{&OPTION_RULE_DEPEND_VALUE} ne $strDependValue)
|
|
|
|
{
|
|
|
|
$bDependResolved = false;
|
|
|
|
$strDependType = 'value';
|
|
|
|
}
|
|
|
|
|
|
|
|
# If a depend list exists, make sure the value is in the list
|
|
|
|
if ($bDependResolved && defined($$oDepend{&OPTION_RULE_DEPEND_LIST}) &&
|
|
|
|
!defined($$oDepend{&OPTION_RULE_DEPEND_LIST}{$strDependValue}))
|
|
|
|
{
|
|
|
|
$bDependResolved = false;
|
|
|
|
$strDependType = 'list';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-02 16:05:13 +02:00
|
|
|
# If the option value is undefined and not negated, see if it can be loaded from the config file
|
2015-03-12 18:15:19 +02:00
|
|
|
if (!defined($strValue) && !$bNegate && $strOption ne OPTION_CONFIG &&
|
2015-04-01 21:58:33 +02:00
|
|
|
$oOptionRule{$strOption}{&OPTION_RULE_SECTION} && $bDependResolved)
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
# If the config option has not been resolved yet then continue processing
|
|
|
|
if (!defined($oOptionResolved{&OPTION_CONFIG}) || !defined($oOptionResolved{&OPTION_STANZA}))
|
|
|
|
{
|
|
|
|
$bDependUnresolved = true;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
# If the config option is defined try to get the option from the config file
|
2015-04-19 23:29:52 +02:00
|
|
|
if ($bConfigExists && defined($oOption{&OPTION_CONFIG}{value}))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
# Attempt to load the config file if it has not been loaded
|
|
|
|
if (!defined($oConfig))
|
|
|
|
{
|
2015-04-19 23:29:52 +02:00
|
|
|
my $strConfigFile = $oOption{&OPTION_CONFIG}{value};
|
2015-03-12 18:15:19 +02:00
|
|
|
$bConfigExists = -e $strConfigFile;
|
|
|
|
|
|
|
|
if ($bConfigExists)
|
|
|
|
{
|
|
|
|
if (!-f $strConfigFile)
|
|
|
|
{
|
|
|
|
confess &log(ERROR, "'${strConfigFile}' is not a file", ERROR_FILE_INVALID);
|
|
|
|
}
|
|
|
|
|
2017-04-10 19:24:45 +02:00
|
|
|
$oConfig = iniParse(fileStringRead($strConfigFile), {bRelaxed => true});
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get the section that the value should be in
|
2016-04-14 15:30:54 +02:00
|
|
|
my $strSection = $oOptionRule{$strOption}{&OPTION_RULE_SECTION};
|
2015-03-12 18:15:19 +02:00
|
|
|
|
2016-08-24 18:39:27 +02:00
|
|
|
# Always check for the option in the sanza section first
|
2016-04-14 15:30:54 +02:00
|
|
|
if (optionTest(OPTION_STANZA))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-08-24 18:39:27 +02:00
|
|
|
$strValue = optionValueGet($strOption, $$oConfig{optionGet(OPTION_STANZA)});
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
2016-04-14 15:30:54 +02:00
|
|
|
# Only continue searching when strSection != CONFIG_SECTION_STANZA. Some options (e.g. db-path) can only be
|
|
|
|
# configured in the stanza section.
|
|
|
|
if (!defined($strValue) && $strSection ne CONFIG_SECTION_STANZA)
|
|
|
|
{
|
|
|
|
# Check command sections for a value. This allows options (e.g. compress-level) to be set on a per-command
|
|
|
|
# basis.
|
|
|
|
if (defined($oOptionRule{$strOption}{&OPTION_RULE_COMMAND}{$strCommand}) &&
|
|
|
|
$oOptionRule{$strOption}{&OPTION_RULE_COMMAND}{$strCommand} != false)
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
# Check the stanza command section
|
|
|
|
if (optionTest(OPTION_STANZA))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-08-24 18:39:27 +02:00
|
|
|
$strValue = optionValueGet($strOption, $$oConfig{optionGet(OPTION_STANZA) . ":${strCommand}"});
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
2016-04-14 15:30:54 +02:00
|
|
|
# Check the global command section
|
2015-03-12 18:15:19 +02:00
|
|
|
if (!defined($strValue))
|
|
|
|
{
|
2016-08-24 18:39:27 +02:00
|
|
|
$strValue = optionValueGet($strOption, $$oConfig{&CONFIG_SECTION_GLOBAL . ":${strCommand}"});
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
}
|
2016-04-14 15:30:54 +02:00
|
|
|
|
|
|
|
# Finally check the global section
|
|
|
|
if (!defined($strValue))
|
|
|
|
{
|
2016-08-24 18:39:27 +02:00
|
|
|
$strValue = optionValueGet($strOption, $$oConfig{&CONFIG_SECTION_GLOBAL});
|
2016-04-14 15:30:54 +02:00
|
|
|
}
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Fix up data types
|
|
|
|
if (defined($strValue))
|
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
# The empty string is undefined
|
2015-03-12 18:15:19 +02:00
|
|
|
if ($strValue eq '')
|
|
|
|
{
|
|
|
|
$strValue = undef;
|
|
|
|
}
|
2016-04-14 15:30:54 +02:00
|
|
|
# Convert Y or N to boolean
|
2015-03-12 18:15:19 +02:00
|
|
|
elsif ($oOptionRule{$strOption}{&OPTION_RULE_TYPE} eq OPTION_TYPE_BOOLEAN)
|
|
|
|
{
|
|
|
|
if ($strValue eq 'y')
|
|
|
|
{
|
|
|
|
$strValue = true;
|
|
|
|
}
|
|
|
|
elsif ($strValue eq 'n')
|
|
|
|
{
|
|
|
|
$strValue = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
confess &log(ERROR, "'${strValue}' is not valid for '${strOption}' option",
|
|
|
|
ERROR_OPTION_INVALID_VALUE);
|
|
|
|
}
|
|
|
|
}
|
2016-04-14 15:30:54 +02:00
|
|
|
# Convert a list of key/value pairs to a hash
|
|
|
|
elsif ($oOptionRule{$strOption}{&OPTION_RULE_TYPE} eq OPTION_TYPE_HASH)
|
|
|
|
{
|
|
|
|
my @oValue = ();
|
|
|
|
|
|
|
|
# If there is only one key/value
|
|
|
|
if (ref(\$strValue) eq 'SCALAR')
|
|
|
|
{
|
|
|
|
push(@oValue, $strValue);
|
|
|
|
}
|
|
|
|
# Else if there is an array of values
|
|
|
|
else
|
|
|
|
{
|
|
|
|
@oValue = @{$strValue};
|
|
|
|
}
|
|
|
|
|
|
|
|
# Reset the value hash
|
|
|
|
$strValue = {};
|
|
|
|
|
|
|
|
# Iterate and parse each key/value pair
|
|
|
|
foreach my $strHash (@oValue)
|
|
|
|
{
|
|
|
|
my $iEqualIdx = index($strHash, '=');
|
|
|
|
|
|
|
|
if ($iEqualIdx < 1 || $iEqualIdx == length($strHash) - 1)
|
|
|
|
{
|
|
|
|
confess &log(ERROR, "'${strHash}' is not valid for '${strOption}' option",
|
|
|
|
ERROR_OPTION_INVALID_VALUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
my $strHashKey = substr($strHash, 0, $iEqualIdx);
|
|
|
|
my $strHashValue = substr($strHash, length($strHashKey) + 1);
|
|
|
|
|
|
|
|
$$strValue{$strHashKey} = $strHashValue;
|
|
|
|
}
|
|
|
|
}
|
2016-08-16 02:15:17 +02:00
|
|
|
# In all other cases the value should be scalar
|
|
|
|
elsif (ref(\$strValue) ne 'SCALAR')
|
|
|
|
{
|
|
|
|
confess &log(
|
|
|
|
ERROR, "option '${strOption}' cannot be specified multiple times", ERROR_OPTION_MULTIPLE_VALUE);
|
|
|
|
}
|
2015-04-19 23:29:52 +02:00
|
|
|
|
|
|
|
$oOption{$strOption}{source} = SOURCE_CONFIG;
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-03-03 05:58:32 +02:00
|
|
|
|
2015-04-01 21:58:33 +02:00
|
|
|
if (defined($oDepend) && !$bDependResolved && defined($strValue))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-02-20 02:32:02 +02:00
|
|
|
my $strError = "option '${strOption}' not valid without option ";
|
2015-03-12 18:15:19 +02:00
|
|
|
|
2015-04-01 21:58:33 +02:00
|
|
|
if ($strDependType eq 'source')
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-02-20 02:32:02 +02:00
|
|
|
confess &log(ERROR, "${strError}'${strDependOption}'", ERROR_OPTION_INVALID);
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# If a depend value exists, make sure the option value matches
|
2015-04-01 21:58:33 +02:00
|
|
|
if ($strDependType eq 'value')
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-04-01 21:58:33 +02:00
|
|
|
if ($oOptionRule{$strDependOption}{&OPTION_RULE_TYPE} eq OPTION_TYPE_BOOLEAN)
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-02-20 02:32:02 +02:00
|
|
|
$strError .= "'" . ($$oDepend{&OPTION_RULE_DEPEND_VALUE} ? '' : 'no-') . "${strDependOption}'";
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
2015-04-01 21:58:33 +02:00
|
|
|
else
|
|
|
|
{
|
2016-02-20 02:32:02 +02:00
|
|
|
$strError .= "'${strDependOption}' = '$$oDepend{&OPTION_RULE_DEPEND_VALUE}'";
|
2015-04-01 21:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
confess &log(ERROR, $strError, ERROR_OPTION_INVALID);
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
2016-02-20 02:32:02 +02:00
|
|
|
$strError .= "'${strDependOption}'";
|
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
# If a depend list exists, make sure the value is in the list
|
2015-04-01 21:58:33 +02:00
|
|
|
if ($strDependType eq 'list')
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-04-01 21:58:33 +02:00
|
|
|
my @oyValue;
|
2015-03-12 18:15:19 +02:00
|
|
|
|
2015-06-21 18:06:13 +02:00
|
|
|
foreach my $strValue (sort(keys(%{$$oDepend{&OPTION_RULE_DEPEND_LIST}})))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-04-01 21:58:33 +02:00
|
|
|
push(@oyValue, "'${strValue}'");
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
2015-04-01 21:58:33 +02:00
|
|
|
|
|
|
|
$strError .= @oyValue == 1 ? " = $oyValue[0]" : " in (" . join(", ", @oyValue) . ")";
|
|
|
|
confess &log(ERROR, $strError, ERROR_OPTION_INVALID);
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
}
|
2015-03-03 05:58:32 +02:00
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
# Is the option defined?
|
|
|
|
if (defined($strValue))
|
|
|
|
{
|
|
|
|
# Check that floats and integers are valid
|
|
|
|
if ($oOptionRule{$strOption}{&OPTION_RULE_TYPE} eq OPTION_TYPE_INTEGER ||
|
|
|
|
$oOptionRule{$strOption}{&OPTION_RULE_TYPE} eq OPTION_TYPE_FLOAT)
|
|
|
|
{
|
|
|
|
# Test that the string is a valid float or integer by adding 1 to it. It's pretty hokey but it works and it
|
|
|
|
# beats requiring Scalar::Util::Numeric to do it properly.
|
2016-09-06 15:44:50 +02:00
|
|
|
my $bError = false;
|
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
eval
|
|
|
|
{
|
|
|
|
my $strTest = $strValue + 1;
|
2016-09-06 15:44:50 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
or do
|
|
|
|
{
|
|
|
|
$bError = true;
|
2015-03-12 18:15:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
# Check that integers are really integers
|
|
|
|
if (!$bError && $oOptionRule{$strOption}{&OPTION_RULE_TYPE} eq OPTION_TYPE_INTEGER &&
|
|
|
|
(int($strValue) . 'S') ne ($strValue . 'S'))
|
|
|
|
{
|
|
|
|
$bError = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Error if the value did not pass tests
|
|
|
|
!$bError
|
|
|
|
or confess &log(ERROR, "'${strValue}' is not valid for '${strOption}' option", ERROR_OPTION_INVALID_VALUE);
|
|
|
|
}
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
# Process an allow list for the command then for the option
|
|
|
|
my $oAllow = defined($oCommandRule) ? $$oCommandRule{&OPTION_RULE_ALLOW_LIST} :
|
|
|
|
$oOptionRule{$strOption}{&OPTION_RULE_ALLOW_LIST};
|
2015-03-12 18:15:19 +02:00
|
|
|
|
|
|
|
if (defined($oAllow) && !defined($$oAllow{$strValue}))
|
|
|
|
{
|
|
|
|
confess &log(ERROR, "'${strValue}' is not valid for '${strOption}' option", ERROR_OPTION_INVALID_VALUE);
|
|
|
|
}
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
# Process an allow range for the command then for the option
|
|
|
|
$oAllow = defined($oCommandRule) ? $$oCommandRule{&OPTION_RULE_ALLOW_RANGE} :
|
2015-03-12 18:15:19 +02:00
|
|
|
$oOptionRule{$strOption}{&OPTION_RULE_ALLOW_RANGE};
|
|
|
|
|
|
|
|
if (defined($oAllow) && ($strValue < $$oAllow[0] || $strValue > $$oAllow[1]))
|
|
|
|
{
|
|
|
|
confess &log(ERROR, "'${strValue}' is not valid for '${strOption}' option", ERROR_OPTION_INVALID_RANGE);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Set option value
|
|
|
|
if ($oOptionRule{$strOption}{&OPTION_RULE_TYPE} eq OPTION_TYPE_HASH && ref($strValue) eq 'ARRAY')
|
|
|
|
{
|
|
|
|
foreach my $strItem (@{$strValue})
|
|
|
|
{
|
2016-05-11 15:21:39 +02:00
|
|
|
my $strKey;
|
|
|
|
my $strValue;
|
|
|
|
|
|
|
|
# If the keys are expected to have values
|
|
|
|
if (!defined($oOptionRule{$strOption}{&OPTION_RULE_HASH_VALUE}) ||
|
|
|
|
$oOptionRule{$strOption}{&OPTION_RULE_HASH_VALUE})
|
|
|
|
{
|
|
|
|
# Check for = and make sure there is a least one character on each side
|
|
|
|
my $iEqualPos = index($strItem, '=');
|
|
|
|
|
|
|
|
if ($iEqualPos < 1 || length($strItem) <= $iEqualPos + 1)
|
|
|
|
{
|
|
|
|
confess &log(ERROR, "'${strItem}' not valid key/value for '${strOption}' option",
|
|
|
|
ERROR_OPTION_INVALID_PAIR);
|
|
|
|
}
|
2015-03-12 18:15:19 +02:00
|
|
|
|
2016-05-11 15:21:39 +02:00
|
|
|
$strKey = substr($strItem, 0, $iEqualPos);
|
|
|
|
$strValue = substr($strItem, $iEqualPos + 1);
|
|
|
|
}
|
|
|
|
# Else no values are expected so set value to true
|
|
|
|
else
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2016-05-11 15:21:39 +02:00
|
|
|
$strKey = $strItem;
|
|
|
|
$strValue = true;
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Check that the key has not already been set
|
2015-04-19 23:29:52 +02:00
|
|
|
if (defined($oOption{$strOption}{$strKey}{value}))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
confess &log(ERROR, "'${$strItem}' already defined for '${strOption}' option",
|
|
|
|
ERROR_OPTION_DUPLICATE_KEY);
|
|
|
|
}
|
|
|
|
|
2016-05-11 15:21:39 +02:00
|
|
|
# Set key/value
|
|
|
|
$oOption{$strOption}{value}{$strKey} = $strValue;
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-04-19 23:29:52 +02:00
|
|
|
$oOption{$strOption}{value} = $strValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
# If not config sourced then it must be a param
|
|
|
|
if (!defined($oOption{$strOption}{source}))
|
|
|
|
{
|
|
|
|
$oOption{$strOption}{source} = SOURCE_PARAM;
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
}
|
2015-03-16 20:01:01 +02:00
|
|
|
# Else try to set a default
|
|
|
|
elsif ($bDependResolved &&
|
2015-06-18 22:55:09 +02:00
|
|
|
(!defined($oOptionRule{$strOption}{&OPTION_RULE_COMMAND}) ||
|
|
|
|
defined($oOptionRule{$strOption}{&OPTION_RULE_COMMAND}{$strCommand})))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-04-19 23:29:52 +02:00
|
|
|
# Source is default for this option
|
|
|
|
$oOption{$strOption}{source} = SOURCE_DEFAULT;
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
# Check for default in command then option
|
|
|
|
my $strDefault = optionDefault($strOption, $strCommand);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
|
|
|
# If default is defined
|
|
|
|
if (defined($strDefault))
|
|
|
|
{
|
|
|
|
# Only set default if dependency is resolved
|
2015-04-19 23:29:52 +02:00
|
|
|
$oOption{$strOption}{value} = $strDefault if !$bNegate;
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
2015-03-16 20:01:01 +02:00
|
|
|
# Else check required
|
2015-09-08 13:31:24 +02:00
|
|
|
elsif (optionRequired($strOption, $strCommand) && !$bHelp)
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
confess &log(ERROR, "${strCommand} command requires option: ${strOption}" .
|
2015-05-29 02:52:42 +02:00
|
|
|
(defined($oOptionRule{$strOption}{&OPTION_RULE_HINT}) ?
|
|
|
|
"\nHINT: " . $oOptionRule{$strOption}{&OPTION_RULE_HINT} : ''),
|
|
|
|
ERROR_OPTION_REQUIRED);
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
}
|
2015-03-03 05:58:32 +02:00
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
$oOptionResolved{$strOption} = true;
|
|
|
|
}
|
|
|
|
}
|
2016-12-04 16:25:40 +02:00
|
|
|
|
|
|
|
# Make sure all options specified on the command line are valid
|
|
|
|
foreach my $strOption (sort(keys(%{$oOptionTest})))
|
|
|
|
{
|
|
|
|
# Strip "no-" off the option
|
|
|
|
$strOption = $strOption =~ /^no\-/ ? substr($strOption, 3) : $strOption;
|
|
|
|
|
|
|
|
if (!$oOption{$strOption}{valid})
|
|
|
|
{
|
|
|
|
confess &log(ERROR, "option '${strOption}' not valid for command '${strCommand}'", ERROR_OPTION_COMMAND);
|
|
|
|
}
|
|
|
|
}
|
2017-03-23 01:03:28 +02:00
|
|
|
|
|
|
|
# If a config file was loaded then determine if all options are valid in the config file
|
|
|
|
if (defined($oConfig))
|
|
|
|
{
|
|
|
|
configFileValidate($oConfig);
|
|
|
|
}
|
2015-03-03 05:58:32 +02:00
|
|
|
}
|
|
|
|
|
2017-03-23 01:03:28 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# configFileValidate
|
|
|
|
#
|
2017-04-10 19:53:19 +02:00
|
|
|
# Determine if the configuration file contains any invalid options or placements.
|
2017-03-23 01:03:28 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
sub configFileValidate
|
|
|
|
{
|
|
|
|
my $oConfig = shift;
|
|
|
|
|
|
|
|
my $bFileValid = true;
|
|
|
|
|
|
|
|
foreach my $strSectionKey (keys(%$oConfig))
|
|
|
|
{
|
|
|
|
my ($strSection, $strCommand) = ($strSectionKey =~ m/([^:]*):*(\w*-*\w*)/);
|
|
|
|
|
|
|
|
foreach my $strOption (keys(%{$$oConfig{$strSectionKey}}))
|
|
|
|
{
|
|
|
|
my $strValue = $$oConfig{$strSectionKey}{$strOption};
|
|
|
|
|
|
|
|
# Is the option listed as an alternate name for another option? If so, replace it with the recognized option.
|
|
|
|
my $strOptionAltName = optionAltName($strOption);
|
|
|
|
|
|
|
|
if (defined($strOptionAltName))
|
|
|
|
{
|
|
|
|
$strOption = $strOptionAltName;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Is the option a valid pgbackrest option?
|
|
|
|
if (!(exists($oOptionRule{$strOption}) || defined($strOptionAltName)))
|
|
|
|
{
|
|
|
|
&log(WARN, optionGet(OPTION_CONFIG) . " file contains invalid option '${strOption}'");
|
|
|
|
$bFileValid = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
# Is the option valid for the command section in which it is located?
|
|
|
|
if (defined($strCommand) && $strCommand ne '')
|
|
|
|
{
|
|
|
|
if (!defined($oOptionRule{$strOption}{&OPTION_RULE_COMMAND}{$strCommand}))
|
|
|
|
{
|
|
|
|
&log(WARN, optionGet(OPTION_CONFIG) . " valid option '${strOption}' is not valid for command " .
|
2017-04-10 19:53:19 +02:00
|
|
|
"'${strCommand}'");
|
2017-03-23 01:03:28 +02:00
|
|
|
$bFileValid = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Is the valid option a stanza-only option and not located in a global section?
|
|
|
|
if ($oOptionRule{$strOption}{&OPTION_RULE_SECTION} eq CONFIG_SECTION_STANZA &&
|
|
|
|
$strSection eq CONFIG_SECTION_GLOBAL)
|
|
|
|
{
|
|
|
|
&log(WARN, optionGet(OPTION_CONFIG) . " valid option '${strOption}' is a stanza section option and is not " .
|
|
|
|
"valid in section ${strSection}\n" .
|
|
|
|
"HINT: global options can be specified in global or stanza sections but not visa-versa");
|
|
|
|
$bFileValid = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $bFileValid;
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(configFileValidate);
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# optionAltName
|
|
|
|
#
|
|
|
|
# Returns the ALT_NAME for the option if one exists.
|
|
|
|
####################################################################################################################################
|
|
|
|
sub optionAltName
|
|
|
|
{
|
|
|
|
my $strOption = shift;
|
|
|
|
|
|
|
|
my $strOptionAltName = undef;
|
|
|
|
|
|
|
|
# Check if the options exists as an alternate name (e.g. db-host has altname db1-host)
|
|
|
|
foreach my $strKey (keys(%oOptionRule))
|
|
|
|
{
|
|
|
|
if (defined($oOptionRule{$strKey}{&OPTION_RULE_ALT_NAME}) &&
|
|
|
|
$oOptionRule{$strKey}{&OPTION_RULE_ALT_NAME} eq $strOption)
|
|
|
|
{
|
|
|
|
$strOptionAltName = $strKey;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $strOptionAltName;
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(optionAltName);
|
|
|
|
|
2015-03-16 20:01:01 +02:00
|
|
|
####################################################################################################################################
|
2015-06-18 22:55:09 +02:00
|
|
|
# optionCommandRule
|
2015-03-16 20:01:01 +02:00
|
|
|
#
|
2015-06-18 22:55:09 +02:00
|
|
|
# Returns the option rules based on the command.
|
2015-03-16 20:01:01 +02:00
|
|
|
####################################################################################################################################
|
2015-06-18 22:55:09 +02:00
|
|
|
sub optionCommandRule
|
2015-03-16 20:01:01 +02:00
|
|
|
{
|
|
|
|
my $strOption = shift;
|
2015-06-18 22:55:09 +02:00
|
|
|
my $strCommand = shift;
|
2015-03-16 20:01:01 +02:00
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
if (defined($strCommand))
|
2015-03-25 00:50:14 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
return defined($oOptionRule{$strOption}{&OPTION_RULE_COMMAND}) &&
|
|
|
|
defined($oOptionRule{$strOption}{&OPTION_RULE_COMMAND}{$strCommand}) &&
|
|
|
|
ref($oOptionRule{$strOption}{&OPTION_RULE_COMMAND}{$strCommand}) eq 'HASH' ?
|
|
|
|
$oOptionRule{$strOption}{&OPTION_RULE_COMMAND}{$strCommand} : undef;
|
2015-03-25 00:50:14 +02:00
|
|
|
}
|
|
|
|
|
2016-02-23 16:25:22 +02:00
|
|
|
return;
|
2015-03-16 20:01:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# optionRequired
|
|
|
|
#
|
2015-06-18 22:55:09 +02:00
|
|
|
# Is the option required for this command?
|
2015-03-16 20:01:01 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
sub optionRequired
|
|
|
|
{
|
|
|
|
my $strOption = shift;
|
2015-06-18 22:55:09 +02:00
|
|
|
my $strCommand = shift;
|
2015-03-16 20:01:01 +02:00
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
# Get the command rule
|
|
|
|
my $oCommandRule = optionCommandRule($strOption, $strCommand);
|
2015-03-16 20:01:01 +02:00
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
# Check for required in command then option
|
|
|
|
my $bRequired = defined($oCommandRule) ? $$oCommandRule{&OPTION_RULE_REQUIRED} :
|
|
|
|
$oOptionRule{$strOption}{&OPTION_RULE_REQUIRED};
|
2015-03-16 20:01:01 +02:00
|
|
|
|
|
|
|
# Return required
|
|
|
|
return !defined($bRequired) || $bRequired;
|
|
|
|
}
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(optionRequired);
|
|
|
|
|
2015-10-28 11:10:36 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# optionType
|
|
|
|
#
|
|
|
|
# Get the option type.
|
|
|
|
####################################################################################################################################
|
|
|
|
sub optionType
|
|
|
|
{
|
|
|
|
my $strOption = shift;
|
|
|
|
|
|
|
|
return $oOptionRule{$strOption}{&OPTION_RULE_TYPE};
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(optionType);
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# optionTypeTest
|
|
|
|
#
|
|
|
|
# Test the option type.
|
|
|
|
####################################################################################################################################
|
|
|
|
sub optionTypeTest
|
|
|
|
{
|
|
|
|
my $strOption = shift;
|
|
|
|
my $strType = shift;
|
|
|
|
|
|
|
|
return optionType($strOption) eq $strType;
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(optionTypeTest);
|
|
|
|
|
2016-08-24 18:39:27 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# optionIndex
|
|
|
|
#
|
|
|
|
# Return name for options that can be indexed (e.g. db1-host, db2-host).
|
|
|
|
####################################################################################################################################
|
|
|
|
sub optionIndex
|
|
|
|
{
|
|
|
|
my $strOption = shift;
|
|
|
|
my $iIndex = shift;
|
|
|
|
my $bForce = shift;
|
|
|
|
|
|
|
|
# If the option doesn't have a prefix it can't be indexed
|
|
|
|
$iIndex = defined($iIndex) ? $iIndex : 1;
|
|
|
|
my $strPrefix = $oOptionRule{$strOption}{&OPTION_RULE_PREFIX};
|
|
|
|
|
|
|
|
if (!defined($strPrefix) && $iIndex > 1)
|
|
|
|
{
|
|
|
|
confess &log(ASSERT, "'${strOption}' option does not allow indexing");
|
|
|
|
}
|
|
|
|
|
|
|
|
# Index 1 is the same name as the option unless forced to include the index
|
|
|
|
if ($iIndex == 1 && (!defined($bForce) || !$bForce))
|
|
|
|
{
|
|
|
|
return $strOption;
|
|
|
|
}
|
|
|
|
|
|
|
|
return "${strPrefix}${iIndex}" . substr($strOption, length($strPrefix));
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(optionIndex);
|
|
|
|
|
2015-03-16 20:01:01 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# optionDefault
|
|
|
|
#
|
2015-06-18 22:55:09 +02:00
|
|
|
# Does the option have a default for this command?
|
2015-03-16 20:01:01 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
sub optionDefault
|
|
|
|
{
|
|
|
|
my $strOption = shift;
|
2015-06-18 22:55:09 +02:00
|
|
|
my $strCommand = shift;
|
2015-03-16 20:01:01 +02:00
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
# Get the command rule
|
|
|
|
my $oCommandRule = optionCommandRule($strOption, $strCommand);
|
2015-03-16 20:01:01 +02:00
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
# Check for default in command
|
|
|
|
my $strDefault = defined($oCommandRule) ? $$oCommandRule{&OPTION_RULE_DEFAULT} : undef;
|
2015-03-16 20:45:53 +02:00
|
|
|
|
2015-03-16 20:01:01 +02:00
|
|
|
# If defined return, else try to grab the global default
|
|
|
|
return defined($strDefault) ? $strDefault : $oOptionRule{$strOption}{&OPTION_RULE_DEFAULT};
|
|
|
|
}
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(optionDefault);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
2015-10-28 11:10:36 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# optionRange
|
|
|
|
#
|
|
|
|
# Gets the allowed setting range for the option if it exists.
|
|
|
|
####################################################################################################################################
|
|
|
|
sub optionRange
|
|
|
|
{
|
|
|
|
my $strOption = shift;
|
|
|
|
my $strCommand = shift;
|
|
|
|
|
|
|
|
# Get the command rule
|
|
|
|
my $oCommandRule = optionCommandRule($strOption, $strCommand);
|
|
|
|
|
|
|
|
# Check for default in command
|
|
|
|
if (defined($oCommandRule) && defined($$oCommandRule{&OPTION_RULE_ALLOW_RANGE}))
|
|
|
|
{
|
|
|
|
return $$oCommandRule{&OPTION_RULE_ALLOW_RANGE}[0], $$oCommandRule{&OPTION_RULE_ALLOW_RANGE}[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
# If defined return, else try to grab the global default
|
|
|
|
return $oOptionRule{$strOption}{&OPTION_RULE_ALLOW_RANGE}[0], $oOptionRule{$strOption}{&OPTION_RULE_ALLOW_RANGE}[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(optionRange);
|
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# optionSource
|
|
|
|
#
|
|
|
|
# How was the option set?
|
|
|
|
####################################################################################################################################
|
|
|
|
sub optionSource
|
|
|
|
{
|
|
|
|
my $strOption = shift;
|
|
|
|
|
2016-08-24 18:39:27 +02:00
|
|
|
optionValid($strOption, true);
|
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
return $oOption{$strOption}{source};
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(optionSource);
|
|
|
|
|
2016-06-18 15:55:00 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# optionValid
|
|
|
|
#
|
|
|
|
# Is the option valid for the current command?
|
|
|
|
####################################################################################################################################
|
|
|
|
sub optionValid
|
|
|
|
{
|
|
|
|
my $strOption = shift;
|
|
|
|
my $bError = shift;
|
|
|
|
|
|
|
|
if (defined($oOption{$strOption}) && defined($oOption{$strOption}{valid}) && $oOption{$strOption}{valid})
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (defined($bError) && $bError)
|
|
|
|
{
|
|
|
|
if (!defined($oOption{$strOption}))
|
|
|
|
{
|
|
|
|
confess &log(ASSERT, "option '${strOption}' does not exist");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!defined($oOption{$strOption}{valid}))
|
|
|
|
{
|
|
|
|
confess &log(ASSERT, "option '${strOption}' does not have 'valid' flag set");
|
|
|
|
}
|
|
|
|
|
2016-12-04 16:25:40 +02:00
|
|
|
confess &log(ASSERT, "option '${strOption}' not valid for command '" . commandGet() . "'");
|
2016-06-18 15:55:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(optionValid);
|
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# optionGet
|
|
|
|
#
|
|
|
|
# Get option value.
|
|
|
|
####################################################################################################################################
|
|
|
|
sub optionGet
|
|
|
|
{
|
|
|
|
my $strOption = shift;
|
|
|
|
my $bRequired = shift;
|
|
|
|
|
2016-06-18 15:55:00 +02:00
|
|
|
optionValid($strOption, true);
|
|
|
|
|
2015-04-19 23:29:52 +02:00
|
|
|
if (!defined($oOption{$strOption}{value}) && (!defined($bRequired) || $bRequired))
|
2015-03-03 03:36:12 +02:00
|
|
|
{
|
2015-03-12 18:15:19 +02:00
|
|
|
confess &log(ASSERT, "option ${strOption} is required");
|
2015-03-03 03:36:12 +02:00
|
|
|
}
|
|
|
|
|
2015-04-19 23:29:52 +02:00
|
|
|
return $oOption{$strOption}{value};
|
|
|
|
}
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(optionGet);
|
2015-03-03 05:58:32 +02:00
|
|
|
|
2016-02-06 06:03:29 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# optionSet
|
|
|
|
#
|
2016-09-07 14:07:37 +02:00
|
|
|
# Set option value and source if the option is valid for the command.
|
2016-02-06 06:03:29 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
sub optionSet
|
|
|
|
{
|
|
|
|
my $strOption = shift;
|
|
|
|
my $oValue = shift;
|
2016-12-05 00:51:00 +02:00
|
|
|
my $bForce = shift;
|
2016-02-06 06:03:29 +02:00
|
|
|
|
2016-12-05 00:51:00 +02:00
|
|
|
if (!optionValid($strOption, !defined($bForce) || !$bForce))
|
|
|
|
{
|
|
|
|
$oOption{$strOption}{valid} = true;
|
|
|
|
}
|
2016-06-18 15:55:00 +02:00
|
|
|
|
2016-09-07 14:07:37 +02:00
|
|
|
$oOption{$strOption}{source} = SOURCE_PARAM;
|
2016-02-06 06:03:29 +02:00
|
|
|
$oOption{$strOption}{value} = $oValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(optionSet);
|
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
####################################################################################################################################
|
2015-06-18 22:55:09 +02:00
|
|
|
# optionTest
|
2015-03-12 18:15:19 +02:00
|
|
|
#
|
|
|
|
# Test a option value.
|
|
|
|
####################################################################################################################################
|
|
|
|
sub optionTest
|
|
|
|
{
|
|
|
|
my $strOption = shift;
|
|
|
|
my $strValue = shift;
|
2015-01-31 22:37:59 +02:00
|
|
|
|
2016-06-18 15:55:00 +02:00
|
|
|
if (!optionValid($strOption))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
if (defined($strValue))
|
2015-01-31 22:37:59 +02:00
|
|
|
{
|
2016-06-18 15:55:00 +02:00
|
|
|
return optionGet($strOption) eq $strValue ? true : false;
|
2015-01-31 22:37:59 +02:00
|
|
|
}
|
2015-03-12 18:15:19 +02:00
|
|
|
|
2016-06-18 15:55:00 +02:00
|
|
|
return defined($oOption{$strOption}{value}) ? true : false;
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(optionTest);
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# optionRuleGet
|
|
|
|
#
|
|
|
|
# Get the option rules.
|
|
|
|
####################################################################################################################################
|
|
|
|
sub optionRuleGet
|
|
|
|
{
|
|
|
|
return dclone(\%oOptionRule);
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(optionRuleGet);
|
|
|
|
|
2015-04-01 21:58:33 +02:00
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
# commandGet
|
2015-04-01 21:58:33 +02:00
|
|
|
#
|
2015-08-29 20:20:46 +02:00
|
|
|
# Get the current command.
|
2015-04-01 21:58:33 +02:00
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
sub commandGet
|
2015-04-01 21:58:33 +02:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
return $strCommand;
|
2015-04-01 21:58:33 +02:00
|
|
|
}
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(commandGet);
|
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
# commandTest
|
2015-03-12 18:15:19 +02:00
|
|
|
#
|
2015-08-29 20:20:46 +02:00
|
|
|
# Test the current command.
|
2015-03-12 18:15:19 +02:00
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
sub commandTest
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
my $strCommandTest = shift;
|
|
|
|
|
|
|
|
return $strCommandTest eq $strCommand;
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(commandTest);
|
|
|
|
|
|
|
|
####################################################################################################################################
|
2016-12-04 21:44:53 +02:00
|
|
|
# commandBegin
|
2015-08-29 20:20:46 +02:00
|
|
|
#
|
2016-12-04 21:44:53 +02:00
|
|
|
# Log information about the command when it begins.
|
2015-08-29 20:20:46 +02:00
|
|
|
####################################################################################################################################
|
2016-12-04 21:44:53 +02:00
|
|
|
sub commandBegin
|
2015-08-29 20:20:46 +02:00
|
|
|
{
|
2016-09-17 17:53:28 +02:00
|
|
|
&log(
|
|
|
|
$strCommand eq CMD_INFO ? DEBUG : INFO,
|
2016-12-04 21:44:53 +02:00
|
|
|
"${strCommand} command begin " . BACKREST_VERSION . ':' . commandWrite($strCommand, true, '', false));
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 21:44:53 +02:00
|
|
|
push @EXPORT, qw(commandBegin);
|
2015-08-29 20:20:46 +02:00
|
|
|
|
|
|
|
####################################################################################################################################
|
2016-12-04 21:44:53 +02:00
|
|
|
# commandEnd
|
2015-08-29 20:20:46 +02:00
|
|
|
#
|
2016-12-04 21:44:53 +02:00
|
|
|
# Log information about the command that ended.
|
2015-08-29 20:20:46 +02:00
|
|
|
####################################################################################################################################
|
2016-12-04 21:44:53 +02:00
|
|
|
sub commandEnd
|
2015-08-29 20:20:46 +02:00
|
|
|
{
|
2016-12-04 21:44:53 +02:00
|
|
|
my $iExitCode = shift;
|
|
|
|
my $strSignal = shift;
|
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
if (defined($strCommand))
|
|
|
|
{
|
2016-12-04 21:44:53 +02:00
|
|
|
&log(
|
|
|
|
$strCommand eq CMD_INFO ? DEBUG : INFO,
|
|
|
|
"${strCommand} command end: " . (defined($iExitCode) && $iExitCode != 0 ?
|
|
|
|
($iExitCode == ERROR_TERM ? "terminated on signal " .
|
|
|
|
(defined($strSignal) ? "[SIG${strSignal}]" : 'from child process') :
|
|
|
|
"aborted with exception [${iExitCode}]") :
|
|
|
|
'completed successfully'));
|
2015-09-08 13:31:24 +02:00
|
|
|
}
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 21:44:53 +02:00
|
|
|
push @EXPORT, qw(commandEnd);
|
2015-08-29 20:20:46 +02:00
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# commandSet
|
|
|
|
#
|
|
|
|
# Set current command (usually for triggering follow-on commands).
|
|
|
|
####################################################################################################################################
|
|
|
|
sub commandSet
|
|
|
|
{
|
|
|
|
my $strValue = shift;
|
|
|
|
|
2016-12-04 21:44:53 +02:00
|
|
|
commandEnd();
|
2015-08-29 20:20:46 +02:00
|
|
|
|
|
|
|
$strCommand = $strValue;
|
|
|
|
|
2016-12-04 21:44:53 +02:00
|
|
|
commandBegin();
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(commandSet);
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# commandWrite
|
|
|
|
#
|
|
|
|
# Using the options that were passed to the current command, write the command string for another command. For example, this
|
|
|
|
# can be used to write the archive-get command for recovery.conf during a restore.
|
|
|
|
####################################################################################################################################
|
|
|
|
sub commandWrite
|
|
|
|
{
|
|
|
|
my $strNewCommand = shift;
|
|
|
|
my $bIncludeConfig = shift;
|
|
|
|
my $strExeString = shift;
|
|
|
|
my $bIncludeCommand = shift;
|
2015-10-08 17:43:56 +02:00
|
|
|
my $oOptionOverride = shift;
|
2015-08-29 20:20:46 +02:00
|
|
|
|
|
|
|
# Set defaults
|
2017-01-27 18:02:27 +02:00
|
|
|
$strExeString = defined($strExeString) ? $strExeString : BACKREST_BIN;
|
2015-08-29 20:20:46 +02:00
|
|
|
$bIncludeConfig = defined($bIncludeConfig) ? $bIncludeConfig : false;
|
|
|
|
$bIncludeCommand = defined($bIncludeCommand) ? $bIncludeCommand : true;
|
|
|
|
|
2015-10-08 17:43:56 +02:00
|
|
|
# if ($bIncludeConfig && $strExeString ne '')
|
|
|
|
# {
|
|
|
|
# $strExeString .= ' --no-config';
|
|
|
|
# }
|
|
|
|
|
|
|
|
# Iterate the options to figure out which ones are not default and need to be written out to the new command string
|
|
|
|
foreach my $strOption (sort(keys(%oOptionRule)))
|
2015-08-29 20:20:46 +02:00
|
|
|
{
|
2015-10-08 17:43:56 +02:00
|
|
|
# Skip the config option if it's already included
|
|
|
|
# next if ($bIncludeConfig && $strOption eq OPTION_CONFIG);
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2015-10-08 17:43:56 +02:00
|
|
|
# Process any option overrides first
|
|
|
|
if (defined($$oOptionOverride{$strOption}))
|
|
|
|
{
|
|
|
|
if (defined($$oOptionOverride{$strOption}{value}))
|
|
|
|
{
|
2016-02-23 16:25:22 +02:00
|
|
|
$strExeString .= commandWriteOptionFormat($strOption, false, {value => $$oOptionOverride{$strOption}{value}});
|
2015-10-08 17:43:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
# else look for non-default options in the current configuration
|
|
|
|
elsif ((!defined($oOptionRule{$strOption}{&OPTION_RULE_COMMAND}) ||
|
|
|
|
defined($oOptionRule{$strOption}{&OPTION_RULE_COMMAND}{$strNewCommand})) &&
|
|
|
|
defined($oOption{$strOption}{value}) &&
|
|
|
|
($bIncludeConfig ? $oOption{$strOption}{source} ne SOURCE_DEFAULT : $oOption{$strOption}{source} eq SOURCE_PARAM))
|
2015-08-29 20:20:46 +02:00
|
|
|
{
|
|
|
|
my $oValue;
|
2015-10-08 17:43:56 +02:00
|
|
|
my $bMulti = false;
|
2015-08-29 20:20:46 +02:00
|
|
|
|
|
|
|
# If this is a hash then it will break up into multple command-line options
|
|
|
|
if (ref($oOption{$strOption}{value}) eq 'HASH')
|
|
|
|
{
|
|
|
|
$oValue = $oOption{$strOption}{value};
|
2015-10-08 17:43:56 +02:00
|
|
|
$bMulti = true;
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
|
|
|
# Else a single value but store it in a hash anyway to make processing below simpler
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$oValue = {value => $oOption{$strOption}{value}};
|
|
|
|
}
|
|
|
|
|
2016-02-23 16:25:22 +02:00
|
|
|
$strExeString .= commandWriteOptionFormat($strOption, $bMulti, $oValue);
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($bIncludeCommand)
|
|
|
|
{
|
|
|
|
$strExeString .= " ${strNewCommand}";
|
|
|
|
}
|
|
|
|
|
|
|
|
return $strExeString;
|
2015-01-31 20:48:09 +02:00
|
|
|
}
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
push @EXPORT, qw(commandWrite);
|
|
|
|
|
2016-02-23 16:25:22 +02:00
|
|
|
# Helper function for commandWrite() to correctly format options for command-line usage
|
|
|
|
sub commandWriteOptionFormat
|
|
|
|
{
|
|
|
|
my $strOption = shift;
|
|
|
|
my $bMulti = shift;
|
|
|
|
my $oValue = shift;
|
|
|
|
|
|
|
|
# Loops though all keys in the hash
|
|
|
|
my $strOptionFormat = '';
|
|
|
|
my $strParam;
|
|
|
|
|
|
|
|
foreach my $strKey (sort(keys(%$oValue)))
|
|
|
|
{
|
|
|
|
# Get the value - if the original value was a hash then the key must be prefixed
|
|
|
|
my $strValue = ($bMulti ? "${strKey}=" : '') . $$oValue{$strKey};
|
|
|
|
|
|
|
|
# Handle the no- prefix for boolean values
|
|
|
|
if ($oOptionRule{$strOption}{&OPTION_RULE_TYPE} eq OPTION_TYPE_BOOLEAN)
|
|
|
|
{
|
|
|
|
$strParam = '--' . ($strValue ? '' : 'no-') . $strOption;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$strParam = "--${strOption}=${strValue}";
|
|
|
|
}
|
|
|
|
|
|
|
|
# Add quotes if the value has spaces in it
|
|
|
|
$strOptionFormat .= ' ' . (index($strValue, " ") != -1 ? "\"${strParam}\"" : $strParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $strOptionFormat;
|
|
|
|
}
|
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# commandHashGet
|
|
|
|
#
|
|
|
|
# Get the hash that contains all valid commands.
|
|
|
|
####################################################################################################################################
|
|
|
|
sub commandHashGet
|
|
|
|
{
|
|
|
|
return dclone(\%oCommandHash);
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(commandHashGet);
|
|
|
|
|
2014-12-16 00:20:42 +02:00
|
|
|
1;
|