pgbackrest.git / summary / log / commit / refs
commit 17e611cb883b6086a802c2adfbda384817feaa09
Author: David Steele <david@pgmasters.net>
Date: Sat Dec 01 17:40:01 2018 +0000
Replace keywords with more flexible if statements.
Keywords were extremely limited and prevented us from generating multi-version documentation and other improvements.
Replace keywords with an if statement that can evaluate a Perl expression with variable replacement.
Since keywords were used to generate cache keys, add a --key-var parameter to identify which variables should make up the key.
doc/doc.pl | 55 ++++---
doc/lib/BackRestDoc/Common/DocExecute.pm | 2 +-
doc/lib/BackRestDoc/Common/DocManifest.pm | 75 +++++----
doc/lib/BackRestDoc/Common/DocRender.pm | 8 +-
doc/lib/BackRestDoc/Custom/DocCustomRelease.pm | 2 +-
doc/manifest.xml | 4 +
doc/release.pl | 6 +-
doc/xml/dtd/doc.dtd | 20 +--
doc/xml/dtd/manifest.dtd | 1 -
doc/xml/release.xml | 4 +
doc/xml/user-guide.xml | 215 +++++++++++++------------
11 files changed, 209 insertions(+), 183 deletions(-)
diff --git a/doc/doc.pl b/doc/doc.pl
index 01a5a1111..fe06fcab1 100755
--- a/doc/doc.pl
+++ b/doc/doc.pl
@@ -63,18 +63,17 @@ doc.pl [options]
--no-cache Don't use execution cache
--cache-only Only use the execution cache - don't attempt to generate it
--pre Pre-build containers for execute elements marked pre
- --var Override variables defined in the XML
+ --var Override defined variable
+ --var-key Override defined variable and use in cache key
--doc-path Document path to render (manifest.xml should be located here)
--out Output types (html, pdf, markdown)
--require Require only certain sections of the document (to speed testing)
--include Include source in generation (links will reference website)
--exclude Exclude source from generation (links will reference website)
- Keyword Options:
- --keyword Keyword used to filter output
- --keyword-add Add keyword without overriding 'default' keyword
- --dev Add 'dev' keyword
- --debug Add 'debug' keyword
+ Variable Options:
+ --dev Set 'dev' variable to 'y'
+ --debug Set 'debug' variable to 'y'
=cut
####################################################################################################################################
@@ -87,11 +86,10 @@ my $strLogLevel = 'info';
my $bNoExe = false;
my $bNoCache = false;
my $bCacheOnly = false;
-my $oVariableOverride = {};
+my $rhVariableOverride = {};
+my $rhKeyVariableOverride = {};
my $strDocPath;
my @stryOutput;
-my @stryKeyword;
-my @stryKeywordAdd;
my @stryRequire;
my @stryInclude;
my @stryExclude;
@@ -105,8 +103,6 @@ GetOptions ('help' => \$bHelp,
'quiet' => \$bQuiet,
'log-level=s' => \$strLogLevel,
'out=s@' => \@stryOutput,
- 'keyword=s@' => \@stryKeyword,
- 'keyword-add=s@' => \@stryKeywordAdd,
'require=s@' => \@stryRequire,
'include=s@' => \@stryInclude,
'exclude=s@' => \@stryExclude,
@@ -117,7 +113,8 @@ GetOptions ('help' => \$bHelp,
'debug', \$bDebug,
'pre', \$bPre,
'cache-only', \$bCacheOnly,
- 'var=s%', $oVariableOverride,
+ 'key-var=s%', $rhKeyVariableOverride,
+ 'var=s%', $rhVariableOverride,
'doc-path=s', \$strDocPath)
or pod2usage(2);
@@ -170,25 +167,16 @@ eval
$strLogLevel = 'error';
}
- # If no keyword was passed then use default
- if (@stryKeyword == 0)
- {
- @stryKeyword = ('default');
- }
-
- # Push added keywords
- push(@stryKeyword, @stryKeywordAdd);
-
- # If --dev passed then add the dev keyword
+ # If --dev passed then set the dev var to 'y'
if ($bDev)
{
- push(@stryKeyword, 'dev');
+ $rhVariableOverride->{'dev'} = 'y';
}
- # If --debug passed then add the debug keyword
+ # If --debug passed then set the debug var to 'y'
if ($bDebug)
{
- push(@stryKeyword, 'debug');
+ $rhVariableOverride->{'debug'} = 'y';
}
# Doesn't make sense to pass include and exclude
@@ -219,10 +207,21 @@ eval
or confess &log(ERROR, "unable to create path ${strOutputPath}");
}
+ # Merge key variables into the variable list and ensure there are no duplicates
+ foreach my $strKey (sort(keys(%{$rhKeyVariableOverride})))
+ {
+ if (defined($rhVariableOverride->{$strKey}))
+ {
+ confess &log(ERROR, "'${strKey}' canot be passed as --var and --key-var");
+ }
+
+ $rhVariableOverride->{$strKey} = $rhKeyVariableOverride->{$strKey};
+ }
+
# Load the manifest
my $oManifest = new BackRestDoc::Common::DocManifest(
- $oStorageDoc, \@stryKeyword, \@stryRequire, \@stryInclude, \@stryExclude, $oVariableOverride, $strDocPath, $bDeploy,
- $bCacheOnly, $bPre);
+ $oStorageDoc, \@stryRequire, \@stryInclude, \@stryExclude, $rhKeyVariableOverride, $rhVariableOverride,
+ $strDocPath, $bDeploy, $bCacheOnly, $bPre);
if (!$bNoCache)
{
@@ -251,7 +250,7 @@ eval
foreach my $oHostDefine ($oManifest->sourceGet($strSource)->{doc}->nodeList('host-define', false))
{
- if ($oManifest->keywordMatch($oHostDefine->paramGet('keyword', false)))
+ if ($oManifest->evaluateIf($oHostDefine))
{
my $strImage = $oManifest->variableReplace($oHostDefine->paramGet('image'));
my $strFrom = $oManifest->variableReplace($oHostDefine->paramGet('from'));
diff --git a/doc/lib/BackRestDoc/Common/DocExecute.pm b/doc/lib/BackRestDoc/Common/DocExecute.pm
index db5ce9317..196a54701 100644
--- a/doc/lib/BackRestDoc/Common/DocExecute.pm
+++ b/doc/lib/BackRestDoc/Common/DocExecute.pm
@@ -919,7 +919,7 @@ sub cachePop
{
confess &log(ERROR,
"keys at index $self->{iCacheIdx} do not match, cache is invalid." .
- "\ncache key: " . $oJSON->encode($$hCache{key}) .
+ "\n cache key: " . $oJSON->encode($$hCache{key}) .
"\ncurrent key: " . $oJSON->encode($hCacheKey), ERROR_FILE_INVALID);
}
diff --git a/doc/lib/BackRestDoc/Common/DocManifest.pm b/doc/lib/BackRestDoc/Common/DocManifest.pm
index 566690f71..e02c95fb4 100644
--- a/doc/lib/BackRestDoc/Common/DocManifest.pm
+++ b/doc/lib/BackRestDoc/Common/DocManifest.pm
@@ -56,11 +56,11 @@ sub new
(
my $strOperation,
$self->{oStorage},
- $self->{stryKeyword},
$self->{stryRequire},
$self->{stryInclude},
$self->{stryExclude},
- my $oVariableOverride,
+ $self->{rhKeyVariableOverride},
+ my $rhVariableOverride,
$self->{strDocPath},
$self->{bDeploy},
$self->{bCacheOnly},
@@ -70,11 +70,11 @@ sub new
(
__PACKAGE__ . '->new', \@_,
{name => 'oStorage'},
- {name => 'stryKeyword'},
{name => 'stryRequire'},
{name => 'stryInclude'},
{name => 'stryExclude'},
- {name => 'oVariableOverride', required => false},
+ {name => 'rhKeyVariableOverride', required => false},
+ {name => 'rhVariableOverride', required => false},
{name => 'strDocPath', required => false},
{name => 'bDeploy', required => false},
{name => 'bCacheOnly', required => false},
@@ -122,7 +122,7 @@ sub new
$$oSourceHash{doc} = new BackRestDoc::Common::Doc("$self->{strDocPath}/xml/${strKey}.xml");
# Read variables from source
- $self->variableListParse($$oSourceHash{doc}->nodeGet('variable-list', false), $oVariableOverride);
+ $self->variableListParse($$oSourceHash{doc}->nodeGet('variable-list', false), $rhVariableOverride);
${$self->{oManifest}}{source}{$strKey} = $oSourceHash;
${$self->{oManifest}}{source}{$strKey}{strSourceType} = $strSourceType;
@@ -231,7 +231,7 @@ sub new
$self->variableSet('doc-path', $self->{strDocPath});
# Read variables from manifest
- $self->variableListParse($self->{oManifestXml}->nodeGet('variable-list', false), $oVariableOverride);
+ $self->variableListParse($self->{oManifestXml}->nodeGet('variable-list', false), $rhVariableOverride);
# Return from function and log return values if any
return logDebugReturn
@@ -254,29 +254,31 @@ sub isBackRest
}
####################################################################################################################################
-# keywordMatch
-#
-# See if all the keywords were on the command line.
+# Evaluate the if condition for a node
####################################################################################################################################
-sub keywordMatch
+sub evaluateIf
{
my $self = shift;
- my $strKeywordRequired = shift;
+ my $oNode = shift;
+
+ my $bIf = true;
- if (defined($strKeywordRequired))
+ # Evaluate if condition
+ if (defined($oNode->paramGet('if', false)))
{
- for my $strKeyword (split(',', $strKeywordRequired))
- {
- $strKeyword = trim($strKeyword);
+ my $strIf = $self->variableReplace($oNode->paramGet('if'));
- if (!grep(/^$strKeyword$/, @{$self->{stryKeyword}}))
- {
- return false;
- }
+ # In this case we really do want to evaluate the contents and not treat it as a literal
+ $bIf = eval($strIf); ## no critic (BuiltinFunctions::ProhibitStringyEval)
+
+ # Error if the eval failed
+ if ($@)
+ {
+ confess &log(ERROR, "unable to evaluate '${strIf}': $@");
}
}
- return true;
+ return $bIf;
}
####################################################################################################################################
@@ -293,20 +295,20 @@ sub variableListParse
(
$strOperation,
$oVariableList,
- $oVariableOverride
+ $rhVariableOverride
) =
logDebugParam
(
__PACKAGE__ . '->variableListParse', \@_,
{name => '$oVariableList', required => false},
- {name => '$oVariableOverride', required => false}
+ {name => '$rhVariableOverride', required => false}
);
if (defined($oVariableList))
{
foreach my $oVariable ($oVariableList->nodeList('variable'))
{
- if ($self->keywordMatch($oVariable->paramGet('keyword', false)))
+ if ($self->evaluateIf($oVariable))
{
my $strKey = $oVariable->paramGet('key');
my $strValue = $self->variableReplace($oVariable->valueGet());
@@ -322,7 +324,7 @@ sub variableListParse
}
}
- $self->variableSet($strKey, defined($$oVariableOverride{$strKey}) ? $$oVariableOverride{$strKey} : $strValue);
+ $self->variableSet($strKey, defined($rhVariableOverride->{$strKey}) ? $rhVariableOverride->{$strKey} : $strValue);
logDebugMisc
(
@@ -632,7 +634,14 @@ sub cacheKey
# Assign function parameters, defaults, and log debug info
my ($strOperation) = logDebugParam(__PACKAGE__ . '->cacheKey');
- my $strKeyword = join("\n", @{$self->{stryKeyword}});
+ # Generate a cache key from the variable override
+ my $strVariableKey = JSON::PP->new()->canonical()->allow_nonref()->encode($self->{rhKeyVariableOverride});
+
+ if ($strVariableKey eq '{}')
+ {
+ $strVariableKey = 'default';
+ }
+
my $strRequire = defined($self->{stryRequire}) && @{$self->{stryRequire}} > 0 ?
join("\n", @{$self->{stryRequire}}) : 'all';
@@ -640,7 +649,7 @@ sub cacheKey
return logDebugReturn
(
$strOperation,
- {name => 'strKeyword', value => $strKeyword},
+ {name => 'strVariableKey', value => $strVariableKey},
{name => 'strRequire', value => $strRequire},
);
}
@@ -666,7 +675,7 @@ sub cacheRead
if ($self->storage()->exists($strCacheFile))
{
- my ($strKeyword, $strRequire) = $self->cacheKey();
+ my ($strCacheKey, $strRequire) = $self->cacheKey();
my $oJSON = JSON::PP->new()->allow_nonref();
$self->{hCache} = $oJSON->decode(${$self->storage()->get($strCacheFile)});
@@ -674,10 +683,10 @@ sub cacheRead
{
my $hSource = ${$self->{oManifest}}{source}{$strSource};
- if (defined(${$self->{hCache}}{$strKeyword}{$strRequire}{$strSource}))
+ if (defined(${$self->{hCache}}{$strCacheKey}{$strRequire}{$strSource}))
{
- $$hSource{hyCache} = ${$self->{hCache}}{$strKeyword}{$strRequire}{$strSource};
- &log(DETAIL, "cache load $strSource (keyword = ${strKeyword}, require = ${strRequire})");
+ $$hSource{hyCache} = ${$self->{hCache}}{$strCacheKey}{$strRequire}{$strSource};
+ &log(DETAIL, "cache load $strSource (key = ${strCacheKey}, require = ${strRequire})");
}
}
}
@@ -697,7 +706,7 @@ sub cacheWrite
my ($strOperation) = logDebugParam(__PACKAGE__ . '->cacheWrite');
my $strCacheFile = $self->{bDeploy} ? $self->{strExeCacheDeploy} : $self->{strExeCacheLocal};
- my ($strKeyword, $strRequire) = $self->cacheKey();
+ my ($strCacheKey, $strRequire) = $self->cacheKey();
foreach my $strSource (sort(keys(%{${$self->{oManifest}}{source}})))
{
@@ -705,8 +714,8 @@ sub cacheWrite
if (defined($$hSource{hyCache}))
{
- ${$self->{hCache}}{$strKeyword}{$strRequire}{$strSource} = $$hSource{hyCache};
- &log(DETAIL, "cache load $strSource (keyword = ${strKeyword}, require = ${strRequire})");
+ ${$self->{hCache}}{$strCacheKey}{$strRequire}{$strSource} = $$hSource{hyCache};
+ &log(DETAIL, "cache load $strSource (key = ${strCacheKey}, require = ${strRequire})");
}
}
diff --git a/doc/lib/BackRestDoc/Common/DocRender.pm b/doc/lib/BackRestDoc/Common/DocRender.pm
index a0ff7409e..ce13bb2ef 100644
--- a/doc/lib/BackRestDoc/Common/DocRender.pm
+++ b/doc/lib/BackRestDoc/Common/DocRender.pm
@@ -219,7 +219,8 @@ sub new
$self->{oDoc} =
(new BackRestDoc::Custom::DocCustomRelease(
- ${$self->{oManifest}->sourceGet('release')}{doc}, $self->{oManifest}->keywordMatch('dev')))->docGet();
+ ${$self->{oManifest}->sourceGet('release')}{doc},
+ defined($self->{oManifest}->variableGet('dev')) && $self->{oManifest}->variableGet('dev') eq 'y'))->docGet();
}
else
{
@@ -325,7 +326,7 @@ sub preExecute
####################################################################################################################################
# build
#
-# Build the section map and perform keyword matching.
+# Build the section map and perform filtering.
####################################################################################################################################
sub build
{
@@ -341,7 +342,8 @@ sub build
if (defined($oParent))
{
- if (!$self->{oManifest}->keywordMatch($oNode->paramGet('keyword', false)))
+ # Evaluate if condition -- when false the node will be removed
+ if (!$self->{oManifest}->evaluateIf($oNode))
{
my $strDescription;
diff --git a/doc/lib/BackRestDoc/Custom/DocCustomRelease.pm b/doc/lib/BackRestDoc/Custom/DocCustomRelease.pm
index 175da82db..6e43b27a3 100644
--- a/doc/lib/BackRestDoc/Custom/DocCustomRelease.pm
+++ b/doc/lib/BackRestDoc/Custom/DocCustomRelease.pm
@@ -293,7 +293,7 @@ sub docGet
confess &log(ERROR, 'only one development release is allowed');
}
- $oSection = $oDoc->nodeAdd('section', undef, {id => 'development', keyword => 'dev'});
+ $oSection = $oDoc->nodeAdd('section', undef, {id => 'development', if => "'{[dev]}' eq 'y'"});
$oSection->nodeAdd('title')->textSet("Development Notes");
$iDevReleaseTotal++;
diff --git a/doc/manifest.xml b/doc/manifest.xml
index 10e586410..da78b4630 100644
--- a/doc/manifest.xml
+++ b/doc/manifest.xml
@@ -19,6 +19,10 @@
<variable key="project-logo">logo.png</variable>
<variable key="project-favicon">favicon.png</variable>
+ <!-- Is this a development or debug build of the docs? -->
+ <variable key="dev">n</variable>
+ <variable key="debug">n</variable>
+
<!-- Release date - static allows for reproducible builds -->
<variable key="release-date-static">n</variable>
<variable key="release-date" eval="y">
diff --git a/doc/release.pl b/doc/release.pl
index 351ad668e..b4ad393b5 100755
--- a/doc/release.pl
+++ b/doc/release.pl
@@ -138,8 +138,8 @@ eval
# Generate deployment docs for RHEL/Centos 6
&log(INFO, "Generate RHEL/CentOS 6 documentation");
- executeTest("${strDocExe} --deploy --keyword=co6 --out=pdf", {bShowOutputAsync => true});
- executeTest("${strDocExe} --deploy --cache-only --keyword=co6 --out=pdf --var=\"project-name=Crunchy BackRest\"");
+ executeTest("${strDocExe} --deploy --key-var=os-type=centos6 --out=pdf", {bShowOutputAsync => true});
+ executeTest("${strDocExe} --deploy --cache-only --key-var=os-type=centos6 --out=pdf");
# Generate deployment docs for Debian
&log(INFO, "Generate Debian/Ubuntu documentation");
@@ -157,7 +157,7 @@ eval
executeTest(
$strDocExe . ($bDev ? '' : ' --deploy --cache-only') . ' --out=html --var=project-url-root=index.html' .
- ($bDev ? ' --keyword=default --keyword=dev --no-exe' : ' --exclude=release'));
+ ($bDev ? ' --dev --no-exe' : ' --exclude=release'));
# Deploy to repository
&log(INFO, '...Deploy to repository');
diff --git a/doc/xml/dtd/doc.dtd b/doc/xml/dtd/doc.dtd
index 17e87807a..6345c6e30 100644
--- a/doc/xml/dtd/doc.dtd
+++ b/doc/xml/dtd/doc.dtd
@@ -56,11 +56,11 @@
<!ELEMENT execute-list (title, execute+)>
<!ATTLIST execute-list host CDATA #REQUIRED>
- <!ATTLIST execute-list keyword CDATA "">
+ <!ATTLIST execute-list if CDATA "">
<!ATTLIST execute-list show CDATA "">
<!ELEMENT execute (exe-cmd, exe-cmd-extra?, exe-user?, exe-var?, exe-retry?, exe-output?, (exe-highlight-type?, exe-highlight)?,
exe-err-expect?, exe-err-suppress?, exe-err-suppress-stderr?)>
- <!ATTLIST execute keyword CDATA "">
+ <!ATTLIST execute if CDATA "">
<!ATTLIST execute pre CDATA "">
<!ATTLIST execute user CDATA "">
<!ATTLIST execute filter CDATA "">
@@ -85,18 +85,18 @@
<!ELEMENT variable-list (variable+)>
<!ELEMENT variable (#PCDATA)>
<!ATTLIST variable key CDATA #REQUIRED>
- <!ATTLIST variable keyword CDATA "default">
+ <!ATTLIST variable if CDATA "default">
<!ATTLIST variable eval CDATA "n">
<!ELEMENT backrest-config (title, backrest-config-option+)>
<!ATTLIST backrest-config host CDATA #REQUIRED>
<!ATTLIST backrest-config owner CDATA "">
<!ATTLIST backrest-config show CDATA "">
- <!ATTLIST backrest-config keyword CDATA "">
+ <!ATTLIST backrest-config if CDATA "">
<!ATTLIST backrest-config reset CDATA "">
<!ATTLIST backrest-config file CDATA #REQUIRED>
<!ELEMENT backrest-config-option (#PCDATA)>
- <!ATTLIST backrest-config-option keyword CDATA "">
+ <!ATTLIST backrest-config-option if CDATA "">
<!ATTLIST backrest-config-option section CDATA #REQUIRED>
<!ATTLIST backrest-config-option key CDATA #REQUIRED>
<!ATTLIST backrest-config-option remove CDATA "n">
@@ -104,10 +104,10 @@
<!ELEMENT postgres-config (title, postgres-config-option+)>
<!ATTLIST postgres-config host CDATA #REQUIRED>
<!ATTLIST postgres-config file CDATA #REQUIRED>
- <!ATTLIST postgres-config keyword CDATA "">
+ <!ATTLIST postgres-config if CDATA "">
<!ATTLIST postgres-config show CDATA "">
<!ELEMENT postgres-config-option (#PCDATA)>
- <!ATTLIST postgres-config-option keyword CDATA "">
+ <!ATTLIST postgres-config-option if CDATA "">
<!ATTLIST postgres-config-option key CDATA #REQUIRED>
<!ELEMENT option-description EMPTY>
@@ -120,7 +120,7 @@
((p|list|table|host-add|execute-list|backrest-config|postgres-config|cmd-description|
option-description|code-block|block|section)*))>
<!ATTLIST section id CDATA #REQUIRED>
- <!ATTLIST section keyword CDATA "">
+ <!ATTLIST section if CDATA "">
<!ATTLIST section depend CDATA "">
<!ATTLIST section source CDATA "">
<!ATTLIST section toc CDATA "">
@@ -189,7 +189,7 @@
<!-- Host elements -->
<!ELEMENT host-define (#PCDATA)>
- <!ATTLIST host-define keyword CDATA "">
+ <!ATTLIST host-define if CDATA "">
<!ATTLIST host-define image CDATA #REQUIRED>
<!ATTLIST host-define from CDATA #REQUIRED>
@@ -224,7 +224,7 @@
br-setting|pg-option|pg-setting|link|user|proper)*>
<!ELEMENT p (#PCDATA|quote|b|i|id|code|code-block|host|file|path|cmd|setting|exe|backrest|postgres|br-option|br-setting|
pg-option|pg-setting|link|user|proper)*>
- <!ATTLIST p keyword CDATA "">
+ <!ATTLIST p if CDATA "">
<!ELEMENT text (#PCDATA|quote|b|i|ul|ol|id|code|code-block|host|file|path|cmd|setting|exe|backrest|postgres|br-option|
br-setting|pg-option|pg-setting|link|user|proper)*>
<!ELEMENT i (#PCDATA)>
diff --git a/doc/xml/dtd/manifest.dtd b/doc/xml/dtd/manifest.dtd
index 5a34af8b0..2a18865f9 100644
--- a/doc/xml/dtd/manifest.dtd
+++ b/doc/xml/dtd/manifest.dtd
@@ -4,7 +4,6 @@
<!ELEMENT variable (#PCDATA)>
<!ATTLIST variable key CDATA #REQUIRED>
<!ATTLIST variable eval CDATA "n">
- <!ATTLIST variable keyword CDATA "default">
<!ELEMENT source-list (source+)>
<!ELEMENT source EMPTY>
diff --git a/doc/xml/release.xml b/doc/xml/release.xml
index 840ade327..e943c1fa2 100644
--- a/doc/xml/release.xml
+++ b/doc/xml/release.xml
@@ -139,6 +139,10 @@
</release-improvement-list>
<release-development-list>
+ <release-item>
+ <p>Replace keywords with more flexible if statements.</p>
+ </release-item>
+
<release-item>
<p>Pre-build containers for any <id>execute</id> elements marked <id>pre</id>.</p>
</release-item>
diff --git a/doc/xml/user-guide.xml b/doc/xml/user-guide.xml
index 1c9fb68b9..0ec32b644 100644
--- a/doc/xml/user-guide.xml
+++ b/doc/xml/user-guide.xml
@@ -3,13 +3,21 @@
<doc title="{[project]} User Guide" subtitle="{[user-guide-subtitle]} / {[postgres]} {[pg-version]}" cmd-line-len="85">
<description>The {[project]} User Guide demonstrates how to quickly and easily setup {[project]} for your {[postgres]} database. Step-by-step instructions lead the user through all the important features of the fastest, most reliable {[postgres]} backup and restore solution.</description>
+ <!-- Variables used by the rest of the script -->
<variable-list>
- <!-- Variables used by the rest of the script -->
- <variable key="user-guide-subtitle" keyword="default">Debian & Ubuntu</variable>
- <variable key="user-guide-subtitle" keyword="co6">RHEL & CentOS 6</variable>
+ <!-- Defined OS types -->
+ <variable key="os-debian">debian</variable>
+ <variable key="os-centos6">centos6</variable>
+ <variable key="os-centos7">centos7</variable>
- <variable key="user-guide-os" keyword="default">Debian/Ubuntu</variable>
- <variable key="user-guide-os" keyword="co6">RHEL/CentOS 6</variable>
+ <!-- Defines the general OS type that will be used to generate commands. Also supported: centos6, centos7 -->
+ <variable key="os-type">debian</variable>
+
+ <variable key="user-guide-subtitle" if="'{[os-type]}' eq '{[os-debian]}'">Debian & Ubuntu</variable>
+ <variable key="user-guide-subtitle" if="'{[os-type]}' eq '{[os-centos6]}'">RHEL & CentOS 6</variable>
+
+ <variable key="user-guide-os" if="'{[os-type]}' eq '{[os-debian]}'">Debian/Ubuntu</variable>
+ <variable key="user-guide-os" if="'{[os-type]}' eq '{[os-centos6]}'">RHEL/CentOS 6</variable>
<variable key="pgbackrest-base-dir" eval="y">
use File::Basename qw(dirname);
@@ -18,21 +26,21 @@
dirname(dirname(abs_path($0)));
</variable>
- <variable key="pg-version" keyword="default">9.4</variable>
- <variable key="pg-version" keyword="co6">9.5</variable>
+ <variable key="pg-version" if="'{[os-type]}' eq '{[os-debian]}'">9.4</variable>
+ <variable key="pg-version" if="'{[os-type]}' eq '{[os-centos6]}'">9.5</variable>
<variable key="pg-version-nodot">95</variable>
- <variable key="pg-version-upgrade" keyword="default">9.5</variable>
- <variable key="pg-version-upgrade" keyword="co6">9.6</variable>
- <variable key="pg-version-upgrade-nodot" keyword="co6">96</variable>
+ <variable key="pg-version-upgrade" if="'{[os-type]}' eq '{[os-debian]}'">9.5</variable>
+ <variable key="pg-version-upgrade" if="'{[os-type]}' eq '{[os-centos6]}'">9.6</variable>
+ <variable key="pg-version-upgrade-nodot" if="'{[os-type]}' eq '{[os-centos6]}'">96</variable>
- <variable key="pg-bin-path" keyword="default">/usr/lib/postgresql/{[pg-version]}/bin</variable>
- <variable key="pg-bin-path" keyword="co6">/usr/pgsql-{[pg-version]}/bin</variable>
+ <variable key="pg-bin-path" if="'{[os-type]}' eq '{[os-debian]}'">/usr/lib/postgresql/{[pg-version]}/bin</variable>
+ <variable key="pg-bin-path" if="'{[os-type]}' eq '{[os-centos6]}'">/usr/pgsql-{[pg-version]}/bin</variable>
- <variable key="pg-bin-upgrade-path" keyword="default">/usr/lib/postgresql/{[pg-version-upgrade]}/bin</variable>
- <variable key="pg-bin-upgrade-path" keyword="co6">/usr/pgsql-{[pg-version-upgrade]}/bin</variable>
+ <variable key="pg-bin-upgrade-path" if="'{[os-type]}' eq '{[os-debian]}'">/usr/lib/postgresql/{[pg-version-upgrade]}/bin</variable>
+ <variable key="pg-bin-upgrade-path" if="'{[os-type]}' eq '{[os-centos6]}'">/usr/pgsql-{[pg-version-upgrade]}/bin</variable>
- <variable key="pg-home-path" keyword="default">/var/lib/postgresql</variable>
- <variable key="pg-home-path" keyword="co6">/var/lib/pgsql</variable>
+ <variable key="pg-home-path" if="'{[os-type]}' eq '{[os-debian]}'">/var/lib/postgresql</variable>
+ <variable key="pg-home-path" if="'{[os-type]}' eq '{[os-centos6]}'">/var/lib/pgsql</variable>
<variable key="pg-group">postgres</variable>
@@ -52,44 +60,44 @@
<variable key="backrest-config-include-path">{[backrest-config-path]}/conf.d</variable>
<variable key="backrest-config-demo">{[backrest-config-path]}/{[project-exe]}.conf</variable>
- <variable key="pg-path-default" keyword="default">/var/lib/postgresql/[version]/[cluster]</variable>
- <variable key="pg-path-default" keyword="co6">/var/lib/pgsql/[version]/data</variable>
+ <variable key="pg-path-default" if="'{[os-type]}' eq '{[os-debian]}'">/var/lib/postgresql/[version]/[cluster]</variable>
+ <variable key="pg-path-default" if="'{[os-type]}' eq '{[os-centos6]}'">/var/lib/pgsql/[version]/data</variable>
- <variable key="pg-path" keyword="default">/var/lib/postgresql/{[pg-version]}/{[postgres-cluster-demo]}</variable>
- <variable key="pg-path" keyword="co6">/var/lib/pgsql/{[pg-version]}/data</variable>
+ <variable key="pg-path" if="'{[os-type]}' eq '{[os-debian]}'">/var/lib/postgresql/{[pg-version]}/{[postgres-cluster-demo]}</variable>
+ <variable key="pg-path" if="'{[os-type]}' eq '{[os-centos6]}'">/var/lib/pgsql/{[pg-version]}/data</variable>
- <variable key="pg-path-upgrade" keyword="default">/var/lib/postgresql/{[pg-version-upgrade]}/{[postgres-cluster-demo]}</variable>
- <variable key="pg-path-upgrade" keyword="co6">/var/lib/pgsql/{[pg-version-upgrade]}/data</variable>
+ <variable key="pg-path-upgrade" if="'{[os-type]}' eq '{[os-debian]}'">/var/lib/postgresql/{[pg-version-upgrade]}/{[postgres-cluster-demo]}</variable>
+ <variable key="pg-path-upgrade" if="'{[os-type]}' eq '{[os-centos6]}'">/var/lib/pgsql/{[pg-version-upgrade]}/data</variable>
<variable key="spool-path">/var/spool/pgbackrest</variable>
- <variable key="postgres-config-demo" keyword="default">/etc/postgresql/{[pg-version]}/{[postgres-cluster-demo]}/postgresql.conf</variable>
- <variable key="postgres-config-demo" keyword="co6">{[pg-path]}/postgresql.conf</variable>
+ <variable key="postgres-config-demo" if="'{[os-type]}' eq '{[os-debian]}'">/etc/postgresql/{[pg-version]}/{[postgres-cluster-demo]}/postgresql.conf</variable>
+ <variable key="postgres-config-demo" if="'{[os-type]}' eq '{[os-centos6]}'">{[pg-path]}/postgresql.conf</variable>
- <variable key="postgres-config-demo-upgrade" keyword="default">/etc/postgresql/{[pg-version-upgrade]}/{[postgres-cluster-demo]}/postgresql.conf</variable>
- <variable key="postgres-config-demo-upgrade" keyword="co6">{[pg-path-upgrade]}/postgresql.conf</variable>
+ <variable key="postgres-config-demo-upgrade" if="'{[os-type]}' eq '{[os-debian]}'">/etc/postgresql/{[pg-version-upgrade]}/{[postgres-cluster-demo]}/postgresql.conf</variable>
+ <variable key="postgres-config-demo-upgrade" if="'{[os-type]}' eq '{[os-centos6]}'">{[pg-path-upgrade]}/postgresql.conf</variable>
- <variable key="postgres-hba-demo" keyword="default">/etc/postgresql/{[pg-version]}/{[postgres-cluster-demo]}/pg_hba.conf</variable>
- <variable key="postgres-hba-demo" keyword="co6">{[pg-path]}/pg_hba.conf</variable>
+ <variable key="postgres-hba-demo" if="'{[os-type]}' eq '{[os-debian]}'">/etc/postgresql/{[pg-version]}/{[postgres-cluster-demo]}/pg_hba.conf</variable>
+ <variable key="postgres-hba-demo" if="'{[os-type]}' eq '{[os-centos6]}'">{[pg-path]}/pg_hba.conf</variable>
- <variable key="postgres-hba-demo-upgrade" keyword="default">/etc/postgresql/{[pg-version-upgrade]}/{[postgres-cluster-demo]}/pg_hba.conf</variable>
- <variable key="postgres-hba-demo-upgrade" keyword="co6">{[pg-path-upgrade]}/pg_hba.conf</variable>
+ <variable key="postgres-hba-demo-upgrade" if="'{[os-type]}' eq '{[os-debian]}'">/etc/postgresql/{[pg-version-upgrade]}/{[postgres-cluster-demo]}/pg_hba.conf</variable>
+ <variable key="postgres-hba-demo-upgrade" if="'{[os-type]}' eq '{[os-centos6]}'">{[pg-path-upgrade]}/pg_hba.conf</variable>
<variable key="postgres-pgpass">{[pg-home-path]}/.pgpass</variable>
- <variable key="postgres-log-demo" keyword="default">/var/log/postgresql/postgresql-{[pg-version]}-{[postgres-cluster-demo]}.log</variable>
- <variable key="postgres-log-demo" keyword="co6">{[pg-path]}/pg_log/postgresql.log</variable>
+ <variable key="postgres-log-demo" if="'{[os-type]}' eq '{[os-debian]}'">/var/log/postgresql/postgresql-{[pg-version]}-{[postgres-cluster-demo]}.log</variable>
+ <variable key="postgres-log-demo" if="'{[os-type]}' eq '{[os-centos6]}'">{[pg-path]}/pg_log/postgresql.log</variable>
- <variable key="postgres-log-pgstartup-demo" keyword="co6">/var/lib/pgsql/{[pg-version]}/pgstartup.log</variable>
+ <variable key="postgres-log-pgstartup-demo" if="'{[os-type]}' eq '{[os-centos6]}'">/var/lib/pgsql/{[pg-version]}/pgstartup.log</variable>
- <variable key="postgres-recovery-demo" keyword="default">{[pg-path]}/recovery.conf</variable>
- <variable key="postgres-recovery-demo" keyword="co6">{[pg-path]}/recovery.conf</variable>
+ <variable key="postgres-recovery-demo" if="'{[os-type]}' eq '{[os-debian]}'">{[pg-path]}/recovery.conf</variable>
+ <variable key="postgres-recovery-demo" if="'{[os-type]}' eq '{[os-centos6]}'">{[pg-path]}/recovery.conf</variable>
<variable key="pg-switch-wal">pg_switch_xlog</variable>
<!-- Hosts -->
- <variable key="host-os" keyword="default">u16</variable>
- <variable key="host-os" keyword="co6">co6</variable>
+ <variable key="host-os" if="'{[os-type]}' eq '{[os-debian]}'">u16</variable>
+ <variable key="host-os" if="'{[os-type]}' eq '{[os-centos6]}'">co6</variable>
<variable key="host-image">pgbackrest/doc:{[host-os]}</variable>
@@ -133,28 +141,28 @@
<!-- Database cluster commmands -->
<variable key="pg-cluster-wait">sleep 2</variable>
- <variable key="pg-cluster-create" keyword="default">pg_createcluster {[pg-version]} {[postgres-cluster-demo]}</variable>
- <variable key="pg-cluster-create" keyword="co6">service postgresql-{[pg-version]} initdb</variable>
+ <variable key="pg-cluster-create" if="'{[os-type]}' eq '{[os-debian]}'">pg_createcluster {[pg-version]} {[postgres-cluster-demo]}</variable>
+ <variable key="pg-cluster-create" if="'{[os-type]}' eq '{[os-centos6]}'">service postgresql-{[pg-version]} initdb</variable>
- <variable key="pg-cluster-create-upgrade" keyword="default">pg_createcluster {[pg-version-upgrade]} {[postgres-cluster-demo]}</variable>
+ <variable key="pg-cluster-create-upgrade" if="'{[os-type]}' eq '{[os-debian]}'">pg_createcluster {[pg-version-upgrade]} {[postgres-cluster-demo]}</variable>
- <variable key="pg-cluster-start" keyword="default">pg_ctlcluster {[pg-version]} {[postgres-cluster-demo]} start</variable>
- <variable key="pg-cluster-start" keyword="co6">service postgresql-{[pg-version]} start</variable>
+ <variable key="pg-cluster-start" if="'{[os-type]}' eq '{[os-debian]}'">pg_ctlcluster {[pg-version]} {[postgres-cluster-demo]} start</variable>
+ <variable key="pg-cluster-start" if="'{[os-type]}' eq '{[os-centos6]}'">service postgresql-{[pg-version]} start</variable>
- <variable key="pg-cluster-start-upgrade" keyword="default">pg_ctlcluster {[pg-version-upgrade]} {[postgres-cluster-demo]} start</variable>
- <variable key="pg-cluster-start-upgrade" keyword="co6">service postgresql-{[pg-version-upgrade]} start</variable>
+ <variable key="pg-cluster-start-upgrade" if="'{[os-type]}' eq '{[os-debian]}'">pg_ctlcluster {[pg-version-upgrade]} {[postgres-cluster-demo]} start</variable>
+ <variable key="pg-cluster-start-upgrade" if="'{[os-type]}' eq '{[os-centos6]}'">service postgresql-{[pg-version-upgrade]} start</variable>
- <variable key="pg-cluster-stop" keyword="default">pg_ctlcluster {[pg-version]} {[postgres-cluster-demo]} stop</variable>
- <variable key="pg-cluster-stop" keyword="co6">service postgresql-{[pg-version]} stop</variable>
+ <variable key="pg-cluster-stop" if="'{[os-type]}' eq '{[os-debian]}'">pg_ctlcluster {[pg-version]} {[postgres-cluster-demo]} stop</variable>
+ <variable key="pg-cluster-stop" if="'{[os-type]}' eq '{[os-centos6]}'">service postgresql-{[pg-version]} stop</variable>
- <variable key="pg-cluster-restart" keyword="default">pg_ctlcluster {[pg-version]} {[postgres-cluster-demo]} restart</variable>
- <variable key="pg-cluster-restart" keyword="co6">service postgresql-{[pg-version]} restart</variable>
+ <variable key="pg-cluster-restart" if="'{[os-type]}' eq '{[os-debian]}'">pg_ctlcluster {[pg-version]} {[postgres-cluster-demo]} restart</variable>
+ <variable key="pg-cluster-restart" if="'{[os-type]}' eq '{[os-centos6]}'">service postgresql-{[pg-version]} restart</variable>
- <variable key="pg-cluster-reload" keyword="default">pg_ctlcluster {[pg-version]} {[postgres-cluster-demo]} reload</variable>
- <variable key="pg-cluster-reload" keyword="co6">service postgresql-{[pg-version]} reload</variable>
+ <variable key="pg-cluster-reload" if="'{[os-type]}' eq '{[os-debian]}'">pg_ctlcluster {[pg-version]} {[postgres-cluster-demo]} reload</variable>
+ <variable key="pg-cluster-reload" if="'{[os-type]}' eq '{[os-centos6]}'">service postgresql-{[pg-version]} reload</variable>
- <variable key="pg-cluster-check-upgrade" keyword="default">pg_lsclusters</variable>
- <variable key="pg-cluster-check-upgrade" keyword="co6">service postgresql-{[pg-version-upgrade]} status</variable>
+ <variable key="pg-cluster-check-upgrade" if="'{[os-type]}' eq '{[os-debian]}'">pg_lsclusters</variable>
+ <variable key="pg-cluster-check-upgrade" if="'{[os-type]}' eq '{[os-centos6]}'">service postgresql-{[pg-version-upgrade]} status</variable>
<!-- Common commands -->
<variable key="ssh-key-install">
@@ -183,7 +191,7 @@
<!-- Setup hosts used to build the documentation
============================================================================================================================ -->
- <host-define keyword="default" image="{[host-image]}" from="ubuntu:16.04">
+ <host-define if="'{[os-type]}' eq '{[os-debian]}'" image="{[host-image]}" from="ubuntu:16.04">
# Update apt repositories
RUN apt-get update
@@ -216,7 +224,7 @@
ENTRYPOINT service ssh restart && bash
</host-define>
- <host-define keyword="co6" image="{[host-image]}" from="centos:6">
+ <host-define if="'{[os-type]}' eq '{[os-centos6]}'" image="{[host-image]}" from="centos:6">
# Install packages
RUN yum install -y openssh-server openssh-clients sudo wget vim 2>&1
@@ -329,12 +337,12 @@
<execute-list host="{[br-install-host]}">
<title>Install required Perl packages</title>
- <execute keyword="default" user="root" pre="y">
+ <execute if="'{[os-type]}' eq '{[os-debian]}'" user="root" pre="y">
<exe-cmd>apt-get install libdbd-pg-perl libio-socket-ssl-perl libxml-libxml-perl</exe-cmd>
<exe-cmd-extra>-y 2>&1</exe-cmd-extra>
</execute>
- <execute keyword="co6" user="root" pre="y">
+ <execute if="'{[os-type]}' eq '{[os-centos6]}'" user="root" pre="y">
<exe-cmd>yum install perl perl-Time-HiRes perl-parent perl-JSON
perl-Digest-SHA perl-DBD-Pg perl-XML-LibXML perl-IO-Socket-SSL</exe-cmd>
<exe-cmd-extra>-y 2>&1</exe-cmd-extra>
@@ -486,9 +494,9 @@
</execute>
</host-add>
- <p keyword="default">{[user-guide-os]} packages for <backrest/> are available at <link url="https://www.postgresql.org/download/linux/ubuntu/">apt.postgresql.org</link>. If they are not provided for your distribution/version it is easy to download the source and install manually.</p>
+ <p if="'{[os-type]}' eq '{[os-debian]}'">{[user-guide-os]} packages for <backrest/> are available at <link url="https://www.postgresql.org/download/linux/ubuntu/">apt.postgresql.org</link>. If they are not provided for your distribution/version it is easy to download the source and install manually.</p>
- <p keyword="co6">{[user-guide-os]} packages for <backrest/> are available from <link url="{[crunchy-url-base]}">Crunchy Data</link> or <link url="http://yum.postgresql.org">yum.postgresql.org</link>, but it is also easy to download the source and install manually.</p>
+ <p if="'{[os-type]}' eq '{[os-centos6]}'">{[user-guide-os]} packages for <backrest/> are available from <link url="{[crunchy-url-base]}">Crunchy Data</link> or <link url="http://yum.postgresql.org">yum.postgresql.org</link>, but it is also easy to download the source and install manually.</p>
<host-add id="{[host-build-id]}" name="{[host-build]}" user="{[host-build-user]}" image="{[host-build-image]}" os="{[host-os]}" mount="{[host-build-mount]}"/>
@@ -519,16 +527,16 @@
<execute-list host="{[host-build]}">
<title>Install build dependencies</title>
- <execute keyword="default" user="root" show="n" pre="y">
+ <execute if="'{[os-type]}' eq '{[os-debian]}'" user="root" show="n" pre="y">
<exe-cmd>apt-get update</exe-cmd>
</execute>
- <execute keyword="default" user="root" pre="y">
+ <execute if="'{[os-type]}' eq '{[os-debian]}'" user="root" pre="y">
<exe-cmd>apt-get install build-essential libssl-dev libxml2-dev libperl-dev</exe-cmd>
<exe-cmd-extra>-y 2>&1</exe-cmd-extra>
</execute>
- <execute keyword="co6" user="root" pre="y">
+ <execute if="'{[os-type]}' eq '{[os-centos6]}'" user="root" pre="y">
<exe-cmd>
yum install build-essential gcc openssl-devel libxml2-devel
perl-ExtUtils-Embed
@@ -566,13 +574,13 @@
<host-add id="{[host-pg1-id]}" name="{[host-pg1]}" user="{[host-pg1-user]}" image="{[host-pg1-image]}" os="{[host-os]}" mount="{[host-pg1-mount]}"/>
- <execute-list keyword="pg11" host="{[host-pg1]}">
+ <execute-list if="{[pg-version]} >= 11" host="{[host-pg1]}">
<title>Create <user>{[br-user]}</user> user</title>
- <execute keyword="default" user="root">
+ <execute if="'{[os-type]}' eq '{[os-debian]}'" user="root">
<exe-cmd>adduser --ingroup {[pg-group]} --disabled-password --gecos "" {[br-user]}</exe-cmd>
</execute>
- <execute keyword="co6" user="root">
+ <execute if="'{[os-type]}' eq '{[os-centos6]}'" user="root">
<exe-cmd>adduser -g{[pg-group]} -n {[br-user]}</exe-cmd>
</execute>
</execute-list>
@@ -615,7 +623,7 @@
-D {[pg-path]} -k -A peer</exe-cmd>
</execute>
- <execute keyword="default" user="root" output="y" filter="n">
+ <execute if="'{[os-type]}' eq '{[os-debian]}'" user="root" output="y" filter="n">
<exe-cmd>{[pg-cluster-create]}</exe-cmd>
</execute>
</execute-list>
@@ -636,9 +644,9 @@
<postgres-config-option key="log_line_prefix">''</postgres-config-option>
</postgres-config>
- <p keyword="co6">By default {[user-guide-os]} includes the day of the week in the log filename. This makes automating the user guide a bit more complicated so the <pg-option>log_filename</pg-option> is set to a constant.</p>
+ <p if="'{[os-type]}' eq '{[os-centos6]}'">By default {[user-guide-os]} includes the day of the week in the log filename. This makes automating the user guide a bit more complicated so the <pg-option>log_filename</pg-option> is set to a constant.</p>
- <postgres-config host="{[host-pg1]}" keyword="co6" file="{[postgres-config-demo]}">
+ <postgres-config host="{[host-pg1]}" if="'{[os-type]}' eq '{[os-centos6]}'" file="{[postgres-config-demo]}">
<title>Set <pg-option>log_filename</pg-option></title>
<postgres-config-option key="log_filename">'postgresql.log'</postgres-config-option>
@@ -836,7 +844,7 @@
</execute-list>
<!-- Decided not to show the error in this part of the user guide but added as a debug statement for reference. -->
- <execute-list keyword="debug" host="{[host-pg1]}">
+ <execute-list if="'{[debug]}' eq 'y'" host="{[host-pg1]}">
<title>Example of an invalid configuration</title>
<execute user="postgres" output="y" err-expect="82">
@@ -953,7 +961,7 @@
<execute-list host="{[host-pg1]}">
<title>Attempt to start the corrupted {[postgres-cluster-demo]} cluster</title>
- <execute keyword="default" user="root" output="y" err-expect="1">
+ <execute if="'{[os-type]}' eq '{[os-debian]}'" user="root" output="y" err-expect="1">
<exe-cmd>{[pg-cluster-start]}</exe-cmd>
<exe-highlight>could not find the database system</exe-highlight>
</execute>
@@ -962,15 +970,15 @@
<exe-cmd>{[pg-cluster-wait]}</exe-cmd>
</execute>
- <execute keyword="co6" user="root" show="n">
+ <execute if="'{[os-type]}' eq '{[os-centos6]}'" user="root" show="n">
<exe-cmd>rm -f {[postgres-log-pgstartup-demo]}</exe-cmd>
</execute>
- <execute keyword="co6" user="root" err-expect="1">
+ <execute if="'{[os-type]}' eq '{[os-centos6]}'" user="root" err-expect="1">
<exe-cmd>{[pg-cluster-start]}</exe-cmd>
</execute>
- <execute keyword="co6" user="root" output="y">
+ <execute if="'{[os-type]}' eq '{[os-centos6]}'" user="root" output="y">
<exe-cmd>cat {[postgres-log-pgstartup-demo]}</exe-cmd>
<exe-highlight-type>error</exe-highlight-type>
<exe-highlight>could not find the database system</exe-highlight>
@@ -1182,7 +1190,7 @@
</execute-list>
</section>
- <section keyword="default" id="jq">
+ <section if="'{[os-type]}' eq '{[os-debian]}'" id="jq">
<title>Using <proper>jq</proper></title>
<p><proper>jq</proper> is a command-line utility that can easily extract data from JSON.</p>
@@ -1976,13 +1984,13 @@
<execute-list host="{[host-repo1]}">
<title>Create <user>{[br-user]}</user> user</title>
- <execute keyword="default" user="root">
+ <execute if="'{[os-type]}' eq '{[os-debian]}'" user="root">
<exe-cmd>adduser --disabled-password --gecos "" {[br-user]}</exe-cmd>
</execute>
- <execute keyword="co6" user="root">
+ <execute if="'{[os-type]}' eq '{[os-centos6]}'" user="root">
<exe-cmd>groupadd {[br-group]}</exe-cmd>
</execute>
- <execute keyword="co6" user="root">
+ <execute if="'{[os-type]}' eq '{[os-centos6]}'" user="root">
<exe-cmd>adduser -g{[br-group]} -n {[br-user]}</exe-cmd>
</execute>
</execute-list>
@@ -2028,7 +2036,7 @@
<p>Note that ssh has been configured to only allow <backrest/> to be run via passwordless ssh. This enhances security in the event that one of the service accounts is hijacked.</p>
- <!-- <block keyword="pg11" id="setup-ssh">
+ <!-- <block if="{[pg-version]} >= 11" id="setup-ssh">
<block-variable-replace key="setup-ssh-host">{[host-pg1]}</block-variable-replace>
<block-variable-replace key="setup-ssh-user">pgbackrest</block-variable-replace>
<block-variable-replace key="setup-ssh-user-home-path">{[br-home-path]}</block-variable-replace>
@@ -2052,7 +2060,7 @@
<backrest-config-option section="demo" key="pg1-path">{[pg-path]}</backrest-config-option>
<backrest-config-option section="demo" key="pg1-host">{[host-pg1]}</backrest-config-option>
- <backrest-config-option keyword="pg11" section="demo" key="pg1-host-user">{[br-user]}</backrest-config-option>
+ <backrest-config-option if="{[pg-version]} >= 11" section="demo" key="pg1-host-user">{[br-user]}</backrest-config-option>
<backrest-config-option section="global" key="start-fast">y</backrest-config-option>
<backrest-config-option section="global" key="repo1-retention-full">2</backrest-config-option>
@@ -2078,7 +2086,7 @@
<p>Commands are run the same as on a single host configuration except that some commands such as <cmd>backup</cmd> and <cmd>expire</cmd> are run from the <host>repository</host> host instead of the <host>database</host> host.</p>
- <execute-list keyword="pg11" host="{[host-pg1]}">
+ <execute-list if="{[pg-version]} >= 11" host="{[host-pg1]}">
<title>Set permissions required for backup</title>
<execute user="postgres">
@@ -2313,13 +2321,13 @@
<host-add id="{[host-pg2-id]}" name="{[host-pg2]}" user="{[host-pg2-user]}" image="{[host-pg2-image]}" os="{[host-os]}" mount="{[host-pg2-mount]}"/>
- <execute-list keyword="pg11" host="{[host-pg2]}">
+ <execute-list if="{[pg-version]} >= 11" host="{[host-pg2]}">
<title>Create <user>{[br-user]}</user> user</title>
- <execute keyword="default" user="root">
+ <execute if="'{[os-type]}' eq '{[os-debian]}'" user="root">
<exe-cmd>adduser --ingroup {[pg-group]} --disabled-password --gecos "" {[br-user]}</exe-cmd>
</execute>
- <execute keyword="co6" user="root">
+ <execute if="'{[os-type]}' eq '{[os-centos6]}'" user="root">
<exe-cmd>adduser -g{[pg-group]} -n {[br-user]}</exe-cmd>
</execute>
</execute-list>
@@ -2346,7 +2354,7 @@
<block-variable-replace key="setup-ssh-user-home-path">{[pg-home-path]}</block-variable-replace>
</block>
- <!-- <block keyword="pg11" id="setup-ssh">
+ <!-- <block if="{[pg-version]} >= 11" id="setup-ssh">
<block-variable-replace key="setup-ssh-host">{[host-pg2]}</block-variable-replace>
<block-variable-replace key="setup-ssh-user">{[br-user]}</block-variable-replace>
<block-variable-replace key="setup-ssh-user-home-path">{[br-home-path]}</block-variable-replace>
@@ -2376,9 +2384,9 @@
<backrest-config-option section="global" key="log-timestamp">n</backrest-config-option>
</backrest-config>
- <p keyword="default">The demo cluster must be created (even though it will be overwritten on restore) in order to create the <postgres/> configuration files.</p>
+ <p if="'{[os-type]}' eq '{[os-debian]}'">The demo cluster must be created (even though it will be overwritten on restore) in order to create the <postgres/> configuration files.</p>
- <execute-list keyword="default" host="{[host-pg2]}">
+ <execute-list if="'{[os-type]}' eq '{[os-debian]}'" host="{[host-pg2]}">
<title>Create demo cluster</title>
<execute user="root">
@@ -2386,9 +2394,9 @@
</execute>
</execute-list>
- <p keyword="co6">Create the path where <postgres/> will be restored.</p>
+ <p if="'{[os-type]}' eq '{[os-centos6]}'">Create the path where <postgres/> will be restored.</p>
- <execute-list keyword="co6" host="{[host-pg2]}">
+ <execute-list if="'{[os-type]}' eq '{[os-centos6]}'" host="{[host-pg2]}">
<title>Create <postgres/> path</title>
<execute user="postgres">
@@ -2403,11 +2411,11 @@
<execute-list host="{[host-pg2]}">
<title>Restore the {[postgres-cluster-demo]} standby cluster</title>
- <execute user="postgres" keyword="default">
+ <execute user="postgres" if="'{[os-type]}' eq '{[os-debian]}'">
<exe-cmd>{[project-exe]} {[dash]}-stanza={[postgres-cluster-demo]} {[dash]}-delta restore</exe-cmd>
</execute>
- <execute user="postgres" keyword="co6">
+ <execute user="postgres" if="'{[os-type]}' eq '{[os-centos6]}'">
<exe-cmd>{[project-exe]} {[dash]}-stanza={[postgres-cluster-demo]} restore</exe-cmd>
</execute>
@@ -2603,9 +2611,9 @@
</execute>
</execute-list>
- <p keyword="co6">By default {[user-guide-os]} stores the <file>postgresql.conf</file> file in the <postgres/> data directory. That means the change made to <file>postgresql.conf</file> was overwritten by the last restore and the <pg-option>hot_standby</pg-option> setting must be enabled again. Other solutions to this problem are to store the <file>postgresql.conf</file> file elsewhere or to enable the <pg-option>hot_standby</pg-option> setting on the <host>{[host-pg1]}</host> host where it will be ignored.</p>
+ <p if="'{[os-type]}' eq '{[os-centos6]}'">By default {[user-guide-os]} stores the <file>postgresql.conf</file> file in the <postgres/> data directory. That means the change made to <file>postgresql.conf</file> was overwritten by the last restore and the <pg-option>hot_standby</pg-option> setting must be enabled again. Other solutions to this problem are to store the <file>postgresql.conf</file> file elsewhere or to enable the <pg-option>hot_standby</pg-option> setting on the <host>{[host-pg1]}</host> host where it will be ignored.</p>
- <postgres-config host="{[host-pg2]}" keyword="co6" file="{[postgres-config-demo]}">
+ <postgres-config host="{[host-pg2]}" if="'{[os-type]}' eq '{[os-centos6]}'" file="{[postgres-config-demo]}">
<title>Enable <pg-option>hot_standby</pg-option></title>
<postgres-config-option key="hot_standby">on</postgres-config-option>
@@ -2831,7 +2839,8 @@
<backrest-config-option section="demo" key="pg2-path">{[pg-path]}</backrest-config-option>
<backrest-config-option section="demo" key="pg2-host">{[host-pg2]}</backrest-config-option>
- <backrest-config-option keyword="pg11" section="demo" key="pg2-host-user">{[br-user]}</backrest-config-option>
+ <backrest-config-option if="{[pg-version]} >= 11" section="demo"
+ key="pg2-host-user">{[br-user]}</backrest-config-option>
<backrest-config-option section="global" key="backup-standby">y</backrest-config-option>
</backrest-config>
@@ -2889,11 +2898,11 @@
</exe-cmd>
</execute>
- <execute user="root" keyword="default">
+ <execute user="root" if="'{[os-type]}' eq '{[os-debian]}'">
<exe-cmd>{[pg-cluster-create-upgrade]}</exe-cmd>
</execute>
- <execute user="postgres" output="y" keyword="default">
+ <execute user="postgres" output="y" if="'{[os-type]}' eq '{[os-debian]}'">
<exe-cmd>sh -c 'cd /var/lib/postgresql &&
/usr/lib/postgresql/{[pg-version-upgrade]}/bin/pg_upgrade
{[dash]}-old-bindir=/usr/lib/postgresql/{[pg-version]}/bin
@@ -2906,7 +2915,7 @@
<exe-highlight>Upgrade Complete</exe-highlight>
</execute>
- <execute user="postgres" output="y" keyword="co6">
+ <execute user="postgres" output="y" if="'{[os-type]}' eq '{[os-centos6]}'">
<exe-cmd>sh -c 'cd /var/lib/pgsql &&
/usr/pgsql-{[pg-version-upgrade]}/bin/pg_upgrade
{[dash]}-old-bindir=/usr/pgsql-{[pg-version]}/bin
@@ -3007,11 +3016,11 @@
<execute-list host="{[host-pg1]}">
<title>Remove old cluster</title>
- <execute keyword="default" user="root">
+ <execute if="'{[os-type]}' eq '{[os-debian]}'" user="root">
<exe-cmd>pg_dropcluster {[pg-version]} {[postgres-cluster-demo]}</exe-cmd>
</execute>
- <execute keyword="co6" user="root">
+ <execute if="'{[os-type]}' eq '{[os-centos6]}'" user="root">
<exe-cmd>rm -rf {[pg-path]}</exe-cmd>
</execute>
</execute-list>
@@ -3021,21 +3030,21 @@
<execute-list host="{[host-pg2]}">
<title>Remove old cluster and create the new cluster</title>
- <execute keyword="default" user="root">
+ <execute if="'{[os-type]}' eq '{[os-debian]}'" user="root">
<exe-cmd>pg_dropcluster {[pg-version]} {[postgres-cluster-demo]}</exe-cmd>
</execute>
- <execute keyword="co6" user="root">
+ <execute if="'{[os-type]}' eq '{[os-centos6]}'" user="root">
<exe-cmd>rm -rf {[pg-path]}</exe-cmd>
</execute>
- <execute user="postgres" keyword="co6">
+ <execute user="postgres" if="'{[os-type]}' eq '{[os-centos6]}'">
<exe-cmd>
mkdir -p -m 700 {[pg-bin-upgrade-path]}
</exe-cmd>
</execute>
- <execute user="root" keyword="default">
+ <execute user="root" if="'{[os-type]}' eq '{[os-debian]}'">
<exe-cmd>{[pg-cluster-create-upgrade]}</exe-cmd>
</execute>
</execute-list>
@@ -3063,11 +3072,11 @@
<execute-list host="{[host-pg2]}">
<title>Restore the {[postgres-cluster-demo]} standby cluster</title>
- <execute user="postgres" keyword="default">
+ <execute user="postgres" if="'{[os-type]}' eq '{[os-debian]}'">
<exe-cmd>{[project-exe]} {[dash]}-stanza={[postgres-cluster-demo]} {[dash]}-delta restore</exe-cmd>
</execute>
- <execute user="postgres" keyword="co6">
+ <execute user="postgres" if="'{[os-type]}' eq '{[os-centos6]}'">
<exe-cmd>{[project-exe]} {[dash]}-stanza={[postgres-cluster-demo]} restore</exe-cmd>
</execute>
</execute-list>
[parent: 47490ba9600c]