1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-09-16 09:06:18 +02:00

Make backup.history sync more efficient.

Only the backup.history/[year] directory was being synced, so check if the backup.history is newly created and sync it as well.
This commit is contained in:
David Steele
2018-04-03 20:54:18 -04:00
parent 5890272247
commit 0dce8ba2fa
4 changed files with 54 additions and 37 deletions

View File

@@ -434,10 +434,6 @@ sub process
my $bCompress = cfgOption(CFGOPT_COMPRESS);
my $bHardLink = cfgOption(CFGOPT_REPO_HARDLINK);
# Create the cluster backup and history path
$oStorageRepo->pathCreate(
STORAGE_REPO_BACKUP . qw(/) . PATH_BACKUP_HISTORY, {bIgnoreExists => true, bCreateParent => true});
# Load the backup.info
my $oBackupInfo = new pgBackRest::Backup::Info($oStorageRepo->pathGet(STORAGE_REPO_BACKUP));
@@ -952,19 +948,33 @@ sub process
&log(INFO, "new backup label = ${strBackupLabel}");
# Check if the backup history path exists. This will change which path we sync below.
my $bHistoryExists = $oStorageRepo->pathExists(STORAGE_REPO_BACKUP . qw{/} . PATH_BACKUP_HISTORY);
# Copy a compressed version of the manifest to history. If the repo is encrypted then the passphrase to open the manifest is
# required.
my $strHistoryPath = $oStorageRepo->pathGet(
STORAGE_REPO_BACKUP . qw{/} . PATH_BACKUP_HISTORY . qw{/} . substr($strBackupLabel, 0, 4));
$oStorageRepo->copy(
$oStorageRepo->openRead(STORAGE_REPO_BACKUP . "/${strBackupLabel}/" . FILE_MANIFEST,
{'strCipherPass' => $strCipherPassManifest}),
$oStorageRepo->openWrite(
STORAGE_REPO_BACKUP . qw{/} . PATH_BACKUP_HISTORY . qw{/} . substr($strBackupLabel, 0, 4) .
"/${strBackupLabel}.manifest." . COMPRESS_EXT, {rhyFilter => [{strClass => STORAGE_FILTER_GZIP}],
"${strHistoryPath}/${strBackupLabel}.manifest." . COMPRESS_EXT,
{rhyFilter => [{strClass => STORAGE_FILTER_GZIP}],
bPathCreate => true, bAtomic => true,
strCipherPass => defined($strCipherPassManifest) ? $strCipherPassManifest : undef}));
# Sync history path
$oStorageRepo->pathSync(STORAGE_REPO_BACKUP . qw{/} . PATH_BACKUP_HISTORY);
# Sync entire history path if it did not already exist
if (!$bHistoryExists)
{
$oStorageRepo->pathSync(STORAGE_REPO_BACKUP . qw{/} . PATH_BACKUP_HISTORY, {bRecurse => true});
}
# Else sync only the history year path
else
{
$oStorageRepo->pathSync($strHistoryPath);
}
# Create a link to the most recent backup
$oStorageRepo->remove(STORAGE_REPO_BACKUP . qw(/) . LINK_LATEST);