mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-03-17 20:58:34 +02:00
Implement issue #79: Support comment characters in config file
This commit is contained in:
parent
e9099b99aa
commit
5c43e7035a
@ -739,6 +739,8 @@ example: db-path=/data/db
|
||||
|
||||
* Fixed an issue where archive-copy would fail on an incr/diff backup when hardlink=n. In this case the pg_xlog path does not already exist and must be created. Reported by Michael Renner
|
||||
|
||||
* Allow comments/disabling in pg_backrest.conf using #. Suggested by Michael Renner.
|
||||
|
||||
* Replaced JSON module with JSON::PP which ships with core Perl.
|
||||
|
||||
### v0.65: Improved resume and restore logging, compact restores
|
||||
|
@ -692,6 +692,9 @@ Run a <id>full</id> backup on the <id>db</id> stanza. <param>--type</param> can
|
||||
<release-feature>
|
||||
<text>Fixed an issue where archive-copy would fail on an incr/diff backup when hardlink=n. In this case the pg_xlog path does not already exist and must be created. Reported by Michael Renner</text>
|
||||
</release-feature>
|
||||
<release-feature>
|
||||
<text>Allow comments/disabling in pg_backrest.conf using #. Suggested by Michael Renner.</text>
|
||||
</release-feature>
|
||||
<release-feature>
|
||||
<text>Replaced JSON module with JSON::PP which ships with core Perl.</text>
|
||||
</release-feature>
|
||||
|
@ -553,7 +553,8 @@ sub ini_load
|
||||
{
|
||||
$strLine = trim($strLine);
|
||||
|
||||
if ($strLine ne '')
|
||||
# Skip lines that are blank or comments
|
||||
if ($strLine ne '' && $strLine !~ '^#.*')
|
||||
{
|
||||
# Get the section
|
||||
if (index($strLine, '[') == 0)
|
||||
@ -610,23 +611,40 @@ sub ini_save
|
||||
open($hFile, '>', $strFile)
|
||||
or confess &log(ERROR, "unable to open ${strFile}");
|
||||
|
||||
# Create the JSON object canonical so that fields are alpha ordered and pass unit tests
|
||||
# Create the JSON object canonical so that fields are alpha ordered to pass unit tests
|
||||
my $oJSON = JSON::PP->new()->canonical();
|
||||
|
||||
# Write the INI file
|
||||
foreach my $strSection (sort(keys $oConfig))
|
||||
{
|
||||
# Add a linefeed between sections
|
||||
if (!$bFirst)
|
||||
{
|
||||
syswrite($hFile, "\n")
|
||||
or confess "unable to write lf: $!";
|
||||
}
|
||||
|
||||
# Write the section comment if present
|
||||
if (defined(${$oConfig}{$strSection}{'[comment]'}))
|
||||
{
|
||||
syswrite($hFile, "# " . ${$oConfig}{$strSection}{'[comment]'} . "\n")
|
||||
or confess "unable to comment for section ${strSection}: $!";
|
||||
}
|
||||
|
||||
# Write the section
|
||||
syswrite($hFile, "[${strSection}]\n")
|
||||
or confess "unable to write section ${strSection}: $!";
|
||||
|
||||
# Iterate through all keys in the section
|
||||
foreach my $strKey (sort(keys ${$oConfig}{"${strSection}"}))
|
||||
{
|
||||
# Skip comments
|
||||
if ($strKey eq '[comment]')
|
||||
{
|
||||
next;
|
||||
}
|
||||
|
||||
# If the value is a hash then convert it to JSON, otherwise store as is
|
||||
my $strValue = ${$oConfig}{"${strSection}"}{"${strKey}"};
|
||||
|
||||
if (defined($strValue))
|
||||
|
@ -872,6 +872,7 @@ sub BackRestTestCommon_ConfigCreate
|
||||
$oParamHash{'global:command'}{'cmd-remote'} = $strCommonCommandRemote;
|
||||
}
|
||||
|
||||
$oParamHash{'global:command'}{'[comment]'} = 'psql command and options';
|
||||
$oParamHash{'global:command'}{'cmd-psql'} = $strCommonCommandPsql;
|
||||
|
||||
if (defined($strRemote) && $strRemote eq BACKUP)
|
||||
@ -885,9 +886,12 @@ sub BackRestTestCommon_ConfigCreate
|
||||
$oParamHash{$strCommonStanza}{'db-user'} = $strCommonUser;
|
||||
}
|
||||
|
||||
$oParamHash{'global:log'}{'[comment]'} = 'file and console log settings';
|
||||
$oParamHash{'global:log'}{'log-level-console'} = 'debug';
|
||||
$oParamHash{'global:log'}{'log-level-file'} = 'trace';
|
||||
|
||||
$oParamHash{'global:general'}{'[comment]'} = 'general settings for all operations';
|
||||
|
||||
if ($strLocal eq BACKUP)
|
||||
{
|
||||
$oParamHash{'global:general'}{'repo-path'} = $strCommonRepoPath;
|
||||
@ -898,13 +902,6 @@ sub BackRestTestCommon_ConfigCreate
|
||||
|
||||
if (defined($strRemote))
|
||||
{
|
||||
# $oParamHash{'global:log'}{'log-level-console'} = 'trace';
|
||||
|
||||
# if ($bArchiveAsync)
|
||||
# {
|
||||
# $oParamHash{'global:archive'}{path} = BackRestTestCommon_LocalPathGet();
|
||||
# }
|
||||
|
||||
$oParamHash{'global:general'}{'repo-remote-path'} = $strCommonRepoPath;
|
||||
}
|
||||
else
|
||||
@ -914,12 +911,8 @@ sub BackRestTestCommon_ConfigCreate
|
||||
|
||||
if ($bArchiveAsync)
|
||||
{
|
||||
$oParamHash{'global:archive'}{'[comment]'} = 'WAL archive settings';
|
||||
$oParamHash{'global:archive'}{'archive-async'} = 'y';
|
||||
#
|
||||
# if (!$bCompressAsync)
|
||||
# {
|
||||
# $oParamHash{'global:archive'}{'compress_async'} = 'n';
|
||||
# }
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -934,8 +927,8 @@ sub BackRestTestCommon_ConfigCreate
|
||||
|
||||
if (($strLocal eq BACKUP) || ($strLocal eq DB && !defined($strRemote)))
|
||||
{
|
||||
$oParamHash{'db:command'}{'cmd-psql-option'} = "--port=${iCommonDbPort}";
|
||||
$oParamHash{'global:backup'}{'thread-max'} = $iThreadMax;
|
||||
$oParamHash{"${strCommonStanza}:command"}{'[comment]'} = 'cluster-specific command options';
|
||||
$oParamHash{"${strCommonStanza}:command"}{'cmd-psql-option'} = "--port=${iCommonDbPort}";
|
||||
|
||||
if (defined($bHardlink) && $bHardlink)
|
||||
{
|
||||
@ -950,13 +943,16 @@ sub BackRestTestCommon_ConfigCreate
|
||||
$oParamHash{'global:general'}{'compress'} = 'n';
|
||||
}
|
||||
|
||||
# if (defined($bChecksum) && $bChecksum)
|
||||
# {
|
||||
# $oParamHash{'global:backup'}{'checksum'} = 'y';
|
||||
# }
|
||||
|
||||
# Stanza settings
|
||||
$oParamHash{$strCommonStanza}{'[comment]'} = "cluster-specific settings";
|
||||
$oParamHash{$strCommonStanza}{'db-path'} = $strCommonDbCommonPath;
|
||||
|
||||
# Comments
|
||||
if (defined($oParamHash{'global:backup'}))
|
||||
{
|
||||
$oParamHash{'global:backup'}{'[comment]'} = "backup settings";
|
||||
}
|
||||
|
||||
# Write out the configuration file
|
||||
my $strFile = BackRestTestCommon_TestPathGet() . '/pg_backrest.conf';
|
||||
ini_save($strFile, \%oParamHash);
|
||||
|
Loading…
x
Reference in New Issue
Block a user