1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-14 10:13:05 +02:00

Added the --repo-link option.

Allow internal symlinks to be suppressed when the repository is located on a filesystem that does not support symlinks. This does not affect any pgBackRest functionality, but the convenience link latest will not be created and neither will internal tablespace symlinks, which will affect the ability to bring up clusters in-place manually using filesystem snapshots.
This commit is contained in:
David Steele 2016-12-03 10:23:26 -05:00
parent 6ae4d7de81
commit 005fc08795
16 changed files with 167 additions and 71 deletions

View File

@ -198,6 +198,17 @@
<example>630</example>
</config-key>
<!-- CONFIG - GENERAL SECTION - REPO-LINK KEY -->
<config-key id="repo-link" name="Repository Symlink Creation">
<summary>Create convenience symlinks in repository.</summary>
<text>Creates the convenience link <path>latest</path> in the stanza directory and internal tablespace symlinks in each backup directory. The internal tablespace symlinks allow clusters to be brought up manually in-place using filesystem snapshots as long as the backup is not compressed.
This option should be disabled when the repository is located on a filesystem that does not support symlinks. No <backrest/> functionality will be affected, but certain manual operations on the repository may be less convenient.</text>
<example>n</example>
</config-key>
<!-- CONFIG - GENERAL SECTION - REPO-PATH KEY -->
<config-key id="repo-path" name="Repository Path">
<summary>Repository path where WAL segments and backups stored.</summary>

View File

@ -137,10 +137,16 @@
<release-core-list>
<release-bug-list>
<release-item>
<p>Fixed a bug where internal symlinks were not being created for tablespaces in the repository. This issue was only apparent when trying to bring up clusters in-place with filesystem snapshots and did not affect normal backup and restore.</p>
<p>Fixed a bug where internal symlinks were not being created for tablespaces in the repository. This issue was only apparent when trying to bring up clusters in-place manually using filesystem snapshots and did not affect normal backup and restore.</p>
</release-item>
</release-bug-list>
<release-feature-list>
<release-item>
<p>Added the <br-option>--repo-link</br-option> option to allow internal symlinks to be suppressed when the repository is located on a filesystem that does not support symlinks. This does not affect any <backrest/> functionality, but the convenience link <path>latest</path> will not be created and neither will internal tablespace symlinks, which will affect the ability to bring up clusters in-place manually using filesystem snapshots.</p>
</release-item>
</release-feature-list>
<release-refactor-list>
<release-item>
<release-item-contributor-list>

View File

@ -276,13 +276,15 @@ sub processManifest
$oFileMaster->pathCreate(PATH_BACKUP_TMP, $strPath);
}
# Create tablespace links
for my $strTarget ($oBackupManifest->keys(MANIFEST_SECTION_BACKUP_TARGET))
if (optionGet(OPTION_REPO_LINK))
{
if ($oBackupManifest->isTargetTablespace($strTarget))
for my $strTarget ($oBackupManifest->keys(MANIFEST_SECTION_BACKUP_TARGET))
{
$oFileMaster->linkCreate(
PATH_BACKUP_TMP, $strTarget, PATH_BACKUP_TMP, MANIFEST_TARGET_PGDATA . "/${strTarget}", false, true);
if ($oBackupManifest->isTargetTablespace($strTarget))
{
$oFileMaster->linkCreate(
PATH_BACKUP_TMP, $strTarget, PATH_BACKUP_TMP, MANIFEST_TARGET_PGDATA . "/${strTarget}", false, true);
}
}
}
}
@ -908,8 +910,12 @@ sub process
"/${strBackupLabel}.manifest.gz", true);
# Create a link to the most recent backup
$oFileLocal->remove(PATH_BACKUP_CLUSTER, "latest");
$oFileLocal->linkCreate(PATH_BACKUP_CLUSTER, $strBackupLabel, PATH_BACKUP_CLUSTER, "latest", undef, true);
$oFileLocal->remove(PATH_BACKUP_CLUSTER, LINK_LATEST);
if (optionGet(OPTION_REPO_LINK))
{
$oFileLocal->linkCreate(PATH_BACKUP_CLUSTER, $strBackupLabel, PATH_BACKUP_CLUSTER, LINK_LATEST, undef, true);
}
# Save backup info
$oBackupInfo->add($oBackupManifest);

View File

@ -15,6 +15,12 @@ use pgBackRest::Common::Log;
use pgBackRest::Common::String;
use pgBackRest::Config::Config;
####################################################################################################################################
# Latest backup link constant
####################################################################################################################################
use constant LINK_LATEST => OPTION_DEFAULT_RESTORE_SET;
push @EXPORT, qw(LINK_LATEST);
####################################################################################################################################
# backupRegExpGet - Generate a regexp depending on the backups that need to be found
####################################################################################################################################

View File

@ -262,6 +262,8 @@ use constant OPTION_PROTOCOL_TIMEOUT => 'protocol
push @EXPORT, qw(OPTION_PROTOCOL_TIMEOUT);
use constant OPTION_PROCESS_MAX => 'process-max';
push @EXPORT, qw(OPTION_PROCESS_MAX);
use constant OPTION_REPO_LINK => 'repo-link';
push @EXPORT, qw(OPTION_REPO_LINK);
# Commands
use constant OPTION_CMD_SSH => 'cmd-ssh';
@ -456,6 +458,8 @@ use constant OPTION_DEFAULT_LOG_PATH => '/var/log
push @EXPORT, qw(OPTION_DEFAULT_LOG_PATH);
use constant OPTION_DEFAULT_NEUTRAL_UMASK => true;
push @EXPORT, qw(OPTION_DEFAULT_NEUTRAL_UMASK);
use constant OPTION_DEFAULT_REPO_LINK => true;
push @EXPORT, qw(OPTION_DEFAULT_REPO_LINK);
use constant OPTION_DEFAULT_REPO_PATH => '/var/lib/' . BACKREST_EXE;
push @EXPORT, qw(OPTION_DEFAULT_REPO_PATH);
use constant OPTION_DEFAULT_SPOOL_PATH => '/var/spool/' . BACKREST_EXE;
@ -1199,6 +1203,17 @@ my %oOptionRule =
}
},
&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,
},
},
&OPTION_REPO_PATH =>
{
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,

View File

@ -568,6 +568,23 @@ my $oConfigHelpData =
"edit/check recovery.conf before manually restarting."
},
# REPO-LINK Option Help
#---------------------------------------------------------------------------------------------------------------------------
'repo-link' =>
{
section => 'general',
summary =>
"Create convenience symlinks in repository.",
description =>
"Creates the convenience link latest in the stanza directory and internal tablespace symlinks in each backup " .
"directory. The internal tablespace symlinks allow clusters to be brought up manually in-place using " .
"filesystem snapshots as long as the backup is not compressed.\n" .
"\n" .
"This option should be disabled when the repository is located on a filesystem that does not support symlinks. " .
"No pgBackRest functionality will be affected, but certain manual operations on the repository may be less " .
"convenient."
},
# REPO-PATH Option Help
#---------------------------------------------------------------------------------------------------------------------------
'repo-path' =>
@ -898,6 +915,7 @@ my $oConfigHelpData =
'online' => 'default',
'process-max' => 'section',
'protocol-timeout' => 'section',
'repo-link' => 'section',
'repo-path' => 'section',
'resume' => 'section',
'retention-archive' => 'section',

View File

@ -2105,12 +2105,12 @@ db-version="9.4"
[db:history]
1={"db-catalog-version":201409291,"db-control-version":942,"db-system-id":6353949018581704918,"db-version":"9.4"}
diff backup - cannot resume - disabled (db-master host)
> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --no-online --no-resume --log-level-console=detail --type=diff --stanza=db backup --test --test-delay=0.2 --test-point=backup-noresume=y
diff backup - cannot resume - disabled / no repo link (db-master host)
> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --no-online --no-resume --log-level-console=detail --no-repo-link --type=diff --stanza=db backup --test --test-delay=0.2 --test-point=backup-noresume=y
------------------------------------------------------------------------------------------------------------------------------------
P00 WARN: option retention-full is not set, the repository may run out of space
HINT: to retain full backups indefinitely (without warning), set option 'retention-full' to the maximum.
P00 INFO: backup start [BACKREST-VERSION]: --no-compress --config=[TEST_PATH]/db-master/pgbackrest.conf --db-path=[TEST_PATH]/db-master/db/base --lock-path=[TEST_PATH]/db-master/repo/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/repo/log --no-online --repo-path=[TEST_PATH]/db-master/repo --no-resume --stanza=db --start-fast --test --test-delay=0.2 --test-point=backup-noresume=y --type=diff
P00 INFO: backup start [BACKREST-VERSION]: --no-compress --config=[TEST_PATH]/db-master/pgbackrest.conf --db-path=[TEST_PATH]/db-master/db/base --lock-path=[TEST_PATH]/db-master/repo/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/repo/log --no-online --no-repo-link --repo-path=[TEST_PATH]/db-master/repo --no-resume --stanza=db --start-fast --test --test-delay=0.2 --test-point=backup-noresume=y --type=diff
P00 WARN: backup [BACKUP-DIFF-1] missing in repository removed from backup.info
P00 INFO: last backup label = [BACKUP-FULL-2], version = [VERSION-1]
P00 WARN: aborted backup exists, but cannot be resumed (resume is disabled) - will be dropped and recreated

View File

@ -1705,12 +1705,12 @@ db-version="9.4"
[db:history]
1={"db-catalog-version":201409291,"db-control-version":942,"db-system-id":6353949018581704918,"db-version":"9.4"}
diff backup - cannot resume - disabled (db-master host)
> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --no-online --no-resume --log-level-console=detail --type=diff --stanza=db backup --test --test-delay=0.2 --test-point=backup-noresume=y
diff backup - cannot resume - disabled / no repo link (db-master host)
> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --no-online --no-resume --log-level-console=detail --no-repo-link --type=diff --stanza=db backup --test --test-delay=0.2 --test-point=backup-noresume=y
------------------------------------------------------------------------------------------------------------------------------------
P00 WARN: option retention-full is not set, the repository may run out of space
HINT: to retain full backups indefinitely (without warning), set option 'retention-full' to the maximum.
P00 INFO: backup start [BACKREST-VERSION]: --no-compress --config=[TEST_PATH]/db-master/pgbackrest.conf --db-path=[TEST_PATH]/db-master/db/base --hardlink --lock-path=[TEST_PATH]/db-master/repo/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/repo/log --no-online --repo-path=[TEST_PATH]/db-master/repo --no-resume --stanza=db --start-fast --test --test-delay=0.2 --test-point=backup-noresume=y --type=diff
P00 INFO: backup start [BACKREST-VERSION]: --no-compress --config=[TEST_PATH]/db-master/pgbackrest.conf --db-path=[TEST_PATH]/db-master/db/base --hardlink --lock-path=[TEST_PATH]/db-master/repo/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/repo/log --no-online --no-repo-link --repo-path=[TEST_PATH]/db-master/repo --no-resume --stanza=db --start-fast --test --test-delay=0.2 --test-point=backup-noresume=y --type=diff
P00 WARN: backup [BACKUP-DIFF-1] missing in repository removed from backup.info
P00 INFO: last backup label = [BACKUP-FULL-2], version = [VERSION-1]
P00 WARN: aborted backup exists, but cannot be resumed (resume is disabled) - will be dropped and recreated

View File

@ -1624,12 +1624,12 @@ db-version="9.4"
[db:history]
1={"db-catalog-version":201409291,"db-control-version":942,"db-system-id":6353949018581704918,"db-version":"9.4"}
diff backup - cannot resume - disabled (db-master host)
> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --no-online --no-resume --log-level-console=detail --type=diff --stanza=db backup --test --test-delay=0.2 --test-point=backup-noresume=y
diff backup - cannot resume - disabled / no repo link (db-master host)
> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --no-online --no-resume --log-level-console=detail --no-repo-link --type=diff --stanza=db backup --test --test-delay=0.2 --test-point=backup-noresume=y
------------------------------------------------------------------------------------------------------------------------------------
P00 WARN: option retention-full is not set, the repository may run out of space
HINT: to retain full backups indefinitely (without warning), set option 'retention-full' to the maximum.
P00 INFO: backup start [BACKREST-VERSION]: --config=[TEST_PATH]/db-master/pgbackrest.conf --db-path=[TEST_PATH]/db-master/db/base --lock-path=[TEST_PATH]/db-master/repo/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/repo/log --no-online --repo-path=[TEST_PATH]/db-master/repo --no-resume --stanza=db --start-fast --test --test-delay=0.2 --test-point=backup-noresume=y --type=diff
P00 INFO: backup start [BACKREST-VERSION]: --config=[TEST_PATH]/db-master/pgbackrest.conf --db-path=[TEST_PATH]/db-master/db/base --lock-path=[TEST_PATH]/db-master/repo/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/repo/log --no-online --no-repo-link --repo-path=[TEST_PATH]/db-master/repo --no-resume --stanza=db --start-fast --test --test-delay=0.2 --test-point=backup-noresume=y --type=diff
P00 WARN: backup [BACKUP-DIFF-1] missing in repository removed from backup.info
P00 INFO: last backup label = [BACKUP-FULL-2], version = [VERSION-1]
P00 WARN: aborted backup exists, but cannot be resumed (resume is disabled) - will be dropped and recreated

View File

@ -1700,12 +1700,12 @@ db-version="9.4"
[db:history]
1={"db-catalog-version":201409291,"db-control-version":942,"db-system-id":6353949018581704918,"db-version":"9.4"}
diff backup - cannot resume - disabled (db-master host)
> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --no-online --no-resume --log-level-console=detail --type=diff --stanza=db backup --test --test-delay=0.2 --test-point=backup-noresume=y
diff backup - cannot resume - disabled / no repo link (db-master host)
> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --no-online --no-resume --log-level-console=detail --no-repo-link --type=diff --stanza=db backup --test --test-delay=0.2 --test-point=backup-noresume=y
------------------------------------------------------------------------------------------------------------------------------------
P00 WARN: option retention-full is not set, the repository may run out of space
HINT: to retain full backups indefinitely (without warning), set option 'retention-full' to the maximum.
P00 INFO: backup start [BACKREST-VERSION]: --config=[TEST_PATH]/db-master/pgbackrest.conf --db-path=[TEST_PATH]/db-master/db/base --hardlink --lock-path=[TEST_PATH]/db-master/repo/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/repo/log --no-online --repo-path=[TEST_PATH]/db-master/repo --no-resume --stanza=db --start-fast --test --test-delay=0.2 --test-point=backup-noresume=y --type=diff
P00 INFO: backup start [BACKREST-VERSION]: --config=[TEST_PATH]/db-master/pgbackrest.conf --db-path=[TEST_PATH]/db-master/db/base --hardlink --lock-path=[TEST_PATH]/db-master/repo/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/repo/log --no-online --no-repo-link --repo-path=[TEST_PATH]/db-master/repo --no-resume --stanza=db --start-fast --test --test-delay=0.2 --test-point=backup-noresume=y --type=diff
P00 WARN: backup [BACKUP-DIFF-1] missing in repository removed from backup.info
P00 INFO: last backup label = [BACKUP-FULL-2], version = [VERSION-1]
P00 WARN: aborted backup exists, but cannot be resumed (resume is disabled) - will be dropped and recreated

View File

@ -2082,12 +2082,12 @@ db-version="9.4"
[db:history]
1={"db-catalog-version":201409291,"db-control-version":942,"db-system-id":6353949018581704918,"db-version":"9.4"}
diff backup - cannot resume - disabled (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --no-online --no-resume --log-level-console=detail --type=diff --stanza=db backup --test --test-delay=0.2 --test-point=backup-noresume=y
diff backup - cannot resume - disabled / no repo link (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --no-online --no-resume --log-level-console=detail --no-repo-link --type=diff --stanza=db backup --test --test-delay=0.2 --test-point=backup-noresume=y
------------------------------------------------------------------------------------------------------------------------------------
P00 WARN: option retention-full is not set, the repository may run out of space
HINT: to retain full backups indefinitely (without warning), set option 'retention-full' to the maximum.
P00 INFO: backup start [BACKREST-VERSION]: --no-compress --config=[TEST_PATH]/backup/pgbackrest.conf --db-cmd=[BACKREST-BIN] --db-config=[TEST_PATH]/db-master/pgbackrest.conf --db-host=db-master --db-path=[TEST_PATH]/db-master/db/base --db-user=[USER-1] --lock-path=[TEST_PATH]/backup/repo/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/backup/repo/log --no-online --repo-path=[TEST_PATH]/backup/repo --no-resume --stanza=db --start-fast --test --test-delay=0.2 --test-point=backup-noresume=y --type=diff
P00 INFO: backup start [BACKREST-VERSION]: --no-compress --config=[TEST_PATH]/backup/pgbackrest.conf --db-cmd=[BACKREST-BIN] --db-config=[TEST_PATH]/db-master/pgbackrest.conf --db-host=db-master --db-path=[TEST_PATH]/db-master/db/base --db-user=[USER-1] --lock-path=[TEST_PATH]/backup/repo/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/backup/repo/log --no-online --no-repo-link --repo-path=[TEST_PATH]/backup/repo --no-resume --stanza=db --start-fast --test --test-delay=0.2 --test-point=backup-noresume=y --type=diff
P00 WARN: backup [BACKUP-DIFF-1] missing in repository removed from backup.info
P00 INFO: last backup label = [BACKUP-FULL-2], version = [VERSION-1]
P00 WARN: aborted backup exists, but cannot be resumed (resume is disabled) - will be dropped and recreated

View File

@ -1784,12 +1784,12 @@ db-version="9.4"
[db:history]
1={"db-catalog-version":201409291,"db-control-version":942,"db-system-id":6353949018581704918,"db-version":"9.4"}
diff backup - cannot resume - disabled (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --no-online --no-resume --log-level-console=detail --type=diff --stanza=db backup --test --test-delay=0.2 --test-point=backup-noresume=y
diff backup - cannot resume - disabled / no repo link (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --no-online --no-resume --log-level-console=detail --no-repo-link --type=diff --stanza=db backup --test --test-delay=0.2 --test-point=backup-noresume=y
------------------------------------------------------------------------------------------------------------------------------------
P00 WARN: option retention-full is not set, the repository may run out of space
HINT: to retain full backups indefinitely (without warning), set option 'retention-full' to the maximum.
P00 INFO: backup start [BACKREST-VERSION]: --no-compress --config=[TEST_PATH]/backup/pgbackrest.conf --db-cmd=[BACKREST-BIN] --db-config=[TEST_PATH]/db-master/pgbackrest.conf --db-host=db-master --db-path=[TEST_PATH]/db-master/db/base --db-user=[USER-1] --hardlink --lock-path=[TEST_PATH]/backup/repo/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/backup/repo/log --no-online --repo-path=[TEST_PATH]/backup/repo --no-resume --stanza=db --start-fast --test --test-delay=0.2 --test-point=backup-noresume=y --type=diff
P00 INFO: backup start [BACKREST-VERSION]: --no-compress --config=[TEST_PATH]/backup/pgbackrest.conf --db-cmd=[BACKREST-BIN] --db-config=[TEST_PATH]/db-master/pgbackrest.conf --db-host=db-master --db-path=[TEST_PATH]/db-master/db/base --db-user=[USER-1] --hardlink --lock-path=[TEST_PATH]/backup/repo/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/backup/repo/log --no-online --no-repo-link --repo-path=[TEST_PATH]/backup/repo --no-resume --stanza=db --start-fast --test --test-delay=0.2 --test-point=backup-noresume=y --type=diff
P00 WARN: backup [BACKUP-DIFF-1] missing in repository removed from backup.info
P00 INFO: last backup label = [BACKUP-FULL-2], version = [VERSION-1]
P00 WARN: aborted backup exists, but cannot be resumed (resume is disabled) - will be dropped and recreated

View File

@ -1698,12 +1698,12 @@ db-version="9.4"
[db:history]
1={"db-catalog-version":201409291,"db-control-version":942,"db-system-id":6353949018581704918,"db-version":"9.4"}
diff backup - cannot resume - disabled (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --no-online --no-resume --log-level-console=detail --type=diff --stanza=db backup --test --test-delay=0.2 --test-point=backup-noresume=y
diff backup - cannot resume - disabled / no repo link (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --no-online --no-resume --log-level-console=detail --no-repo-link --type=diff --stanza=db backup --test --test-delay=0.2 --test-point=backup-noresume=y
------------------------------------------------------------------------------------------------------------------------------------
P00 WARN: option retention-full is not set, the repository may run out of space
HINT: to retain full backups indefinitely (without warning), set option 'retention-full' to the maximum.
P00 INFO: backup start [BACKREST-VERSION]: --config=[TEST_PATH]/backup/pgbackrest.conf --db-cmd=[BACKREST-BIN] --db-config=[TEST_PATH]/db-master/pgbackrest.conf --db-host=db-master --db-path=[TEST_PATH]/db-master/db/base --db-user=[USER-1] --lock-path=[TEST_PATH]/backup/repo/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/backup/repo/log --no-online --repo-path=[TEST_PATH]/backup/repo --no-resume --stanza=db --start-fast --test --test-delay=0.2 --test-point=backup-noresume=y --type=diff
P00 INFO: backup start [BACKREST-VERSION]: --config=[TEST_PATH]/backup/pgbackrest.conf --db-cmd=[BACKREST-BIN] --db-config=[TEST_PATH]/db-master/pgbackrest.conf --db-host=db-master --db-path=[TEST_PATH]/db-master/db/base --db-user=[USER-1] --lock-path=[TEST_PATH]/backup/repo/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/backup/repo/log --no-online --no-repo-link --repo-path=[TEST_PATH]/backup/repo --no-resume --stanza=db --start-fast --test --test-delay=0.2 --test-point=backup-noresume=y --type=diff
P00 WARN: backup [BACKUP-DIFF-1] missing in repository removed from backup.info
P00 INFO: last backup label = [BACKUP-FULL-2], version = [VERSION-1]
P00 WARN: aborted backup exists, but cannot be resumed (resume is disabled) - will be dropped and recreated

View File

@ -1774,12 +1774,12 @@ db-version="9.4"
[db:history]
1={"db-catalog-version":201409291,"db-control-version":942,"db-system-id":6353949018581704918,"db-version":"9.4"}
diff backup - cannot resume - disabled (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --no-online --no-resume --log-level-console=detail --type=diff --stanza=db backup --test --test-delay=0.2 --test-point=backup-noresume=y
diff backup - cannot resume - disabled / no repo link (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --no-online --no-resume --log-level-console=detail --no-repo-link --type=diff --stanza=db backup --test --test-delay=0.2 --test-point=backup-noresume=y
------------------------------------------------------------------------------------------------------------------------------------
P00 WARN: option retention-full is not set, the repository may run out of space
HINT: to retain full backups indefinitely (without warning), set option 'retention-full' to the maximum.
P00 INFO: backup start [BACKREST-VERSION]: --config=[TEST_PATH]/backup/pgbackrest.conf --db-cmd=[BACKREST-BIN] --db-config=[TEST_PATH]/db-master/pgbackrest.conf --db-host=db-master --db-path=[TEST_PATH]/db-master/db/base --db-user=[USER-1] --hardlink --lock-path=[TEST_PATH]/backup/repo/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/backup/repo/log --no-online --repo-path=[TEST_PATH]/backup/repo --no-resume --stanza=db --start-fast --test --test-delay=0.2 --test-point=backup-noresume=y --type=diff
P00 INFO: backup start [BACKREST-VERSION]: --config=[TEST_PATH]/backup/pgbackrest.conf --db-cmd=[BACKREST-BIN] --db-config=[TEST_PATH]/db-master/pgbackrest.conf --db-host=db-master --db-path=[TEST_PATH]/db-master/db/base --db-user=[USER-1] --hardlink --lock-path=[TEST_PATH]/backup/repo/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/backup/repo/log --no-online --no-repo-link --repo-path=[TEST_PATH]/backup/repo --no-resume --stanza=db --start-fast --test --test-delay=0.2 --test-point=backup-noresume=y --type=diff
P00 WARN: backup [BACKUP-DIFF-1] missing in repository removed from backup.info
P00 INFO: last backup label = [BACKUP-FULL-2], version = [VERSION-1]
P00 WARN: aborted backup exists, but cannot be resumed (resume is disabled) - will be dropped and recreated

View File

@ -1454,8 +1454,8 @@ sub backupTestRun
executeTest("sudo chmod -R g+w " . dirname($strTmpPath));
$strBackup = $oHostBackup->backup(
$strType, 'cannot resume - disabled',
{oExpectedManifest => \%oManifest, strTest => TEST_BACKUP_NORESUME,
$strType, 'cannot resume - disabled / no repo link',
{oExpectedManifest => \%oManifest, strTest => TEST_BACKUP_NORESUME, bRepoLink => false,
strOptionalParam => '--no-resume --log-level-console=detail'});
# Restore

View File

@ -15,6 +15,7 @@ use Exporter qw(import);
our @EXPORT = qw();
use Storable qw(dclone);
use pgBackRest::BackupCommon;
use pgBackRest::Common::Exception;
use pgBackRest::Common::Ini;
use pgBackRest::Common::Log;
@ -212,6 +213,7 @@ sub backupBegin
(defined($oExpectedManifest) ? " --no-online" : '') .
(defined($$oParam{strOptionalParam}) ? " $$oParam{strOptionalParam}" : '') .
(defined($$oParam{bStandby}) && $$oParam{bStandby} ? " --backup-standby" : '') .
(defined($oParam->{bRepoLink}) && !$oParam->{bRepoLink} ? ' --no-repo-link' : '') .
($strType ne 'incr' ? " --type=${strType}" : '') .
' --stanza=' . $self->stanza() . ' backup' .
(defined($strTest) ? " --test --test-delay=${fTestDelay} --test-point=" . lc($strTest) . '=y' : ''),
@ -280,49 +282,62 @@ sub backupEnd
my $hTablespaceManifest = $self->{oFile}->manifest(
PATH_BACKUP_CLUSTER, "${strBackup}/" . MANIFEST_TARGET_PGDATA . '/' . DB_PATH_PGTBLSPC);
# Iterate file links
for my $strFile (sort(keys(%{$hTablespaceManifest})))
# Remove . and ..
delete($hTablespaceManifest->{'.'});
delete($hTablespaceManifest->{'..'});
# Only check links if repo links are disabled
if (!defined($oParam->{bRepoLink}) || $oParam->{bRepoLink})
{
next if ($strFile eq '.' || $strFile eq '..');
# Make sure the link is in the expected manifest
my $hManifestTarget = $oExpectedManifest->{&MANIFEST_SECTION_BACKUP_TARGET}{&MANIFEST_TARGET_PGTBLSPC . "/${strFile}"};
if (!defined($hManifestTarget) || $hManifestTarget->{&MANIFEST_SUBKEY_TYPE} ne MANIFEST_VALUE_LINK ||
$hManifestTarget->{&MANIFEST_SUBKEY_TABLESPACE_ID} ne $strFile)
# Iterate file links
for my $strFile (sort(keys(%{$hTablespaceManifest})))
{
confess &log(ERROR, "'${strFile}' is not in expected manifest as a link with the correct tablespace id");
# Make sure the link is in the expected manifest
my $hManifestTarget =
$oExpectedManifest->{&MANIFEST_SECTION_BACKUP_TARGET}{&MANIFEST_TARGET_PGTBLSPC . "/${strFile}"};
if (!defined($hManifestTarget) || $hManifestTarget->{&MANIFEST_SUBKEY_TYPE} ne MANIFEST_VALUE_LINK ||
$hManifestTarget->{&MANIFEST_SUBKEY_TABLESPACE_ID} ne $strFile)
{
confess &log(ERROR, "'${strFile}' is not in expected manifest as a link with the correct tablespace id");
}
# Make sure the link really is a link
if ($hTablespaceManifest->{$strFile}{type} ne 'l')
{
confess &log(ERROR, "'${strFile}' in tablespace directory is not a link");
}
# Make sure the link destination is correct
my $strLinkDestination = '../../' . MANIFEST_TARGET_PGTBLSPC . "/${strFile}";
if ($hTablespaceManifest->{$strFile}{link_destination} ne $strLinkDestination)
{
confess &log(ERROR,
"'${strFile}' link should reference '${strLinkDestination}' but actually references " .
"'$hTablespaceManifest->{$strFile}{link_destination}'");
}
}
# Make sure the link really is a link
if ($hTablespaceManifest->{$strFile}{type} ne 'l')
# Iterate manifest targets
for my $strTarget (sort(keys(%{$oExpectedManifest->{&MANIFEST_SECTION_BACKUP_TARGET}})))
{
confess &log(ERROR, "'${strFile}' in tablespace directory is not a link");
}
my $hManifestTarget = $oExpectedManifest->{&MANIFEST_SECTION_BACKUP_TARGET}{$strTarget};
my $strTablespaceId = $hManifestTarget->{&MANIFEST_SUBKEY_TABLESPACE_ID};
# Make sure the link destination is correct
my $strLinkDestination = '../../' . MANIFEST_TARGET_PGTBLSPC . "/${strFile}";
if ($hTablespaceManifest->{$strFile}{link_destination} ne $strLinkDestination)
{
confess &log(ERROR,
"'${strFile}' link should reference '${strLinkDestination}' but actually references " .
"'$hTablespaceManifest->{$strFile}{link_destination}'");
# Make sure the target exists as a link on disk
if ($hManifestTarget->{&MANIFEST_SUBKEY_TYPE} eq MANIFEST_VALUE_LINK && defined($strTablespaceId) &&
!defined($hTablespaceManifest->{$strTablespaceId}))
{
confess &log(ERROR,
"target '${strTarget}' does not have a link at '" . DB_PATH_PGTBLSPC. "/${strTablespaceId}'");
}
}
}
# Iterate manifest targets
for my $strTarget (sort(keys(%{$oExpectedManifest->{&MANIFEST_SECTION_BACKUP_TARGET}})))
# Else make sure the tablespace directory is empty
elsif (keys(%{$hTablespaceManifest}) > 0)
{
my $hManifestTarget = $oExpectedManifest->{&MANIFEST_SECTION_BACKUP_TARGET}{$strTarget};
my $strTablespaceId = $hManifestTarget->{&MANIFEST_SUBKEY_TABLESPACE_ID};
# Make sure the target exists as a link on disk
if ($hManifestTarget->{&MANIFEST_SUBKEY_TYPE} eq MANIFEST_VALUE_LINK && defined($strTablespaceId) &&
!defined($hTablespaceManifest->{$strTablespaceId}))
{
confess &log(ERROR, "target '${strTarget}' does not have a link at '" . DB_PATH_PGTBLSPC. "/${strTablespaceId}'");
}
confess &log(ERROR, DB_PATH_PGTBLSPC . ' directory should be empty when --no-' . OPTION_REPO_LINK);
}
}
# Else there should not be a tablespace directory at all
@ -331,6 +346,24 @@ sub backupEnd
confess &log(ERROR, 'backup must be full or hard-linked to have ' . DB_PATH_PGTBLSPC . ' directory');
}
# Check that latest link exists unless repo links are disabled
my $strLatestLink = $self->{oFile}->pathGet(PATH_BACKUP_CLUSTER, LINK_LATEST);
my $bLatestLinkExists = fileExists($strLatestLink);
if (!defined($oParam->{bRepoLink}) || $oParam->{bRepoLink})
{
my $strLatestLinkDestination = readlink($strLatestLink);
if ($strLatestLinkDestination ne $strBackup)
{
confess &log(ERROR, "'" . LINK_LATEST . "' link should be '${strBackup}' but is '${strLatestLinkDestination}");
}
}
elsif ($bLatestLinkExists)
{
confess &log(ERROR, "'" . LINK_LATEST . "' link should not exist when --no-" . OPTION_REPO_LINK);
}
# Only do compare for synthetic backups since for real backups the expected manifest *is* the actual manifest.
if ($self->synthetic())
{
@ -549,14 +582,15 @@ sub backupLast
{
my $self = shift;
my @stryBackup = $self->{oFile}->list(PATH_BACKUP_CLUSTER, undef, undef, 'reverse');
my @stryBackup = $self->{oFile}->list(
PATH_BACKUP_CLUSTER, undef, '[0-9]{8}-[0-9]{6}F(_[0-9]{8}-[0-9]{6}(D|I)){0,1}', 'reverse');
if (!defined($stryBackup[3]))
if (!defined($stryBackup[0]))
{
confess 'no backup was found: ' . join(@stryBackup, ', ');
}
return $stryBackup[3];
return $stryBackup[0];
}
####################################################################################################################################