pgbackrest.git / summary / log / commit / refs

commit    005fc08795c0bd299f999eff665b4eb4e789b2d2
Author:   David Steele <david@pgmasters.net>
Date:     Sat Dec 03 15:23:26 2016 +0000

    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.


doc/xml/reference.xml | 11 +++ doc/xml/release.xml | 8 +- lib/pgBackRest/Backup.pm | 20 ++-- lib/pgBackRest/BackupCommon.pm | 6 ++ lib/pgBackRest/Config/Config.pm | 15 +++ lib/pgBackRest/Config/ConfigHelpData.pm | 18 ++++ test/expect/backup-synthetic-001.log | 6 +- test/expect/backup-synthetic-002.log | 6 +- test/expect/backup-synthetic-003.log | 6 +- test/expect/backup-synthetic-004.log | 6 +- test/expect/backup-synthetic-005.log | 6 +- test/expect/backup-synthetic-006.log | 6 +- test/expect/backup-synthetic-007.log | 6 +- test/expect/backup-synthetic-008.log | 6 +- test/lib/pgBackRestTest/Backup/BackupTest.pm | 4 +- .../pgBackRestTest/Backup/Common/HostBackupTest.pm | 106 ++++++++++++++------- 16 files changed, 166 insertions(+), 70 deletions(-) diff --git a/doc/xml/reference.xml b/doc/xml/reference.xml index 8d506e85f..c1b857887 100644 --- a/doc/xml/reference.xml +++ b/doc/xml/reference.xml @@ -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> diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 40550ac2f..3bbbf6a30 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -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> diff --git a/lib/pgBackRest/Backup.pm b/lib/pgBackRest/Backup.pm index 2a90a94c2..339eb3dbb 100644 --- a/lib/pgBackRest/Backup.pm +++ b/lib/pgBackRest/Backup.pm @@ -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); diff --git a/lib/pgBackRest/BackupCommon.pm b/lib/pgBackRest/BackupCommon.pm index 110b5d4ec..9ee51e924 100644 --- a/lib/pgBackRest/BackupCommon.pm +++ b/lib/pgBackRest/BackupCommon.pm @@ -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 #################################################################################################################################### diff --git a/lib/pgBackRest/Config/Config.pm b/lib/pgBackRest/Config/Config.pm index 3832569ef..e37827973 100644 --- a/lib/pgBackRest/Config/Config.pm +++ b/lib/pgBackRest/Config/Config.pm @@ -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, diff --git a/lib/pgBackRest/Config/ConfigHelpData.pm b/lib/pgBackRest/Config/ConfigHelpData.pm index 8a3ce7292..c47fd882b 100644 --- a/lib/pgBackRest/Config/ConfigHelpData.pm +++ b/lib/pgBackRest/Config/ConfigHelpData.pm @@ -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', diff --git a/test/expect/backup-synthetic-001.log b/test/expect/backup-synthetic-001.log index c7333d4ff..4351e2a14 100644 --- a/test/expect/backup-synthetic-001.log +++ b/test/expect/backup-synthetic-001.log @@ -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 diff --git a/test/expect/backup-synthetic-002.log b/test/expect/backup-synthetic-002.log index 9fa06a319..67cad85e6 100644 --- a/test/expect/backup-synthetic-002.log +++ b/test/expect/backup-synthetic-002.log @@ -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 diff --git a/test/expect/backup-synthetic-003.log b/test/expect/backup-synthetic-003.log index d4a8ccd49..104a8b0c4 100644 --- a/test/expect/backup-synthetic-003.log +++ b/test/expect/backup-synthetic-003.log @@ -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 diff --git a/test/expect/backup-synthetic-004.log b/test/expect/backup-synthetic-004.log index 04d93479a..e389badb4 100644 --- a/test/expect/backup-synthetic-004.log +++ b/test/expect/backup-synthetic-004.log @@ -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 diff --git a/test/expect/backup-synthetic-005.log b/test/expect/backup-synthetic-005.log index eff83698a..d58995d02 100644 --- a/test/expect/backup-synthetic-005.log +++ b/test/expect/backup-synthetic-005.log @@ -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 diff --git a/test/expect/backup-synthetic-006.log b/test/expect/backup-synthetic-006.log index 16bc76335..fbef658a3 100644 --- a/test/expect/backup-synthetic-006.log +++ b/test/expect/backup-synthetic-006.log @@ -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 diff --git a/test/expect/backup-synthetic-007.log b/test/expect/backup-synthetic-007.log index 233577a9e..c4a034af0 100644 --- a/test/expect/backup-synthetic-007.log +++ b/test/expect/backup-synthetic-007.log @@ -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 diff --git a/test/expect/backup-synthetic-008.log b/test/expect/backup-synthetic-008.log index cfe0031ac..a06db562c 100644 --- a/test/expect/backup-synthetic-008.log +++ b/test/expect/backup-synthetic-008.log @@ -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 diff --git a/test/lib/pgBackRestTest/Backup/BackupTest.pm b/test/lib/pgBackRestTest/Backup/BackupTest.pm index 99fd21d18..2dbeaaba9 100755 --- a/test/lib/pgBackRestTest/Backup/BackupTest.pm +++ b/test/lib/pgBackRestTest/Backup/BackupTest.pm @@ -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 diff --git a/test/lib/pgBackRestTest/Backup/Common/HostBackupTest.pm b/test/lib/pgBackRestTest/Backup/Common/HostBackupTest.pm index 4585857d2..25f9c45f0 100644 --- a/test/lib/pgBackRestTest/Backup/Common/HostBackupTest.pm +++ b/test/lib/pgBackRestTest/Backup/Common/HostBackupTest.pm @@ -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 '..'); + # Iterate file links + for my $strFile (sort(keys(%{$hTablespaceManifest}))) + { + # Make sure the link is in the expected manifest + my $hManifestTarget = + $oExpectedManifest->{&MANIFEST_SECTION_BACKUP_TARGET}{&MANIFEST_TARGET_PGTBLSPC . "/${strFile}"}; - # 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"); + } - 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 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}"; - # 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}'"); + } + } - if ($hTablespaceManifest->{$strFile}{link_destination} ne $strLinkDestination) + # Iterate manifest targets + for my $strTarget (sort(keys(%{$oExpectedManifest->{&MANIFEST_SECTION_BACKUP_TARGET}}))) { - confess &log(ERROR, - "'${strFile}' link should reference '${strLinkDestination}' but actually references " . - "'$hTablespaceManifest->{$strFile}{link_destination}'"); + 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}'"); + } } } - - # 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]; } #################################################################################################################################### [parent: 6ae4d7de81cf]