pgbackrest.git / summary / log / commit / refs

commit    ef33febfb73f449085d6f3da9b0bd6157560e52f
Author:   David Steele <david@pgmasters.net>
Date:     Fri Jul 29 22:43:59 2016 +0000

    Temp files created during backup are now placed in the same directory as the target file.


doc/xml/release.xml | 4 ++++ lib/pgBackRest/File.pm | 35 ++++++++++++++++++++--------------- test/expect/backup-synthetic-005.log | 4 ++-- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 0887d502e..7840c56d9 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -140,6 +140,10 @@ <p>All remote types now take locks. The exceptions date to when the test harness and <backrest/> were running in the same VM and no longer apply.</p> </release-item> + <release-item> + <p>Temp files created during backup are now placed in the same directory as the target file.</p> + </release-item> + <release-item> <p>Output lock file name when a lock cannot be acquired to aid in debugging.</p> </release-item> diff --git a/lib/pgBackRest/File.pm b/lib/pgBackRest/File.pm index 2735762c6..574b0b572 100644 --- a/lib/pgBackRest/File.pm +++ b/lib/pgBackRest/File.pm @@ -331,24 +331,34 @@ sub pathGet {name => 'bTemp', default => false, trace => true} ); - # Make sure that any absolute path starts with /, otherwise it will actually be relative + # Is this an absolute path type? my $bAbsolute = $strType =~ /.*absolute.*/; - if ($bAbsolute && $strFile !~ /^\/.*/) + # Make sure a temp file is valid for this type and file + if ($bTemp) { - confess &log(ASSERT, "absolute path ${strType}:${strFile} must start with /"); + # Only allow temp files for PATH_BACKUP_ARCHIVE, PATH_BACKUP_ARCHIVE_OUT, PATH_BACKUP_TMP and any absolute path + if (!($strType eq PATH_BACKUP_ARCHIVE || $strType eq PATH_BACKUP_ARCHIVE_OUT || $strType eq PATH_BACKUP_TMP || $bAbsolute)) + { + confess &log(ASSERT, 'temp file not supported for path type ' . $strType); } - # Only allow temp files for PATH_BACKUP_ARCHIVE, PATH_BACKUP_ARCHIVE_OUT, PATH_BACKUP_TMP and any absolute path - if ($bTemp && !($strType eq PATH_BACKUP_ARCHIVE || $strType eq PATH_BACKUP_ARCHIVE_OUT || $strType eq PATH_BACKUP_TMP || - $bAbsolute)) + # The file must be defined + if (!defined($strFile)) { - confess &log(ASSERT, 'temp file not supported on path ' . $strType); + confess &log(ASSERT, 'strFile must be defined when temp file requested'); + } } # Get absolute path if ($bAbsolute) { + # Make sure that any absolute path starts with /, otherwise it will actually be relative + if ($strFile !~ /^\/.*/) + { + confess &log(ASSERT, "absolute path ${strType}:${strFile} must start with /"); + } + if (defined($bTemp) && $bTemp) { return $strFile . '.backrest.tmp'; @@ -378,14 +388,9 @@ sub pathGet # Get the backup tmp path if ($strType eq PATH_BACKUP_TMP) { - my $strTempPath = "$self->{strBackupPath}/temp/$self->{strStanza}.tmp"; - - if ($bTemp) - { - return "${strTempPath}/file.tmp" . (defined($self->{iThreadIdx}) ? ".$self->{iThreadIdx}" : ''); - } - - return "${strTempPath}" . (defined($strFile) ? "/${strFile}" : ''); + return + "$self->{strBackupPath}/temp/$self->{strStanza}.tmp" . (defined($strFile) ? "/${strFile}" : '') . + ($bTemp ? (defined($self->{iThreadIdx}) ? ".$self->{iThreadIdx}" : '') . '.tmp' : ''); } # Get the backup archive path diff --git a/test/expect/backup-synthetic-005.log b/test/expect/backup-synthetic-005.log index 454821dfd..26590033b 100644 --- a/test/expect/backup-synthetic-005.log +++ b/test/expect/backup-synthetic-005.log @@ -503,8 +503,8 @@ DETAIL: clean backup temp path: [TEST_PATH]/backup/repo/temp/db.tmp DEBUG: File->manifestRecurse(): iDepth = 2, oManifestHashRef = [hash], strPathFileOp = pg_data/pg_clog, strPathOp = [TEST_PATH]/backup/repo/temp/db.tmp, strPathType = backup:tmp DEBUG: File->manifestRecurse(): iDepth = 2, oManifestHashRef = [hash], strPathFileOp = pg_data/pg_stat, strPathOp = [TEST_PATH]/backup/repo/temp/db.tmp, strPathType = backup:tmp DEBUG: File->manifestRecurse(): iDepth = 2, oManifestHashRef = [hash], strPathFileOp = pg_data/pg_tblspc, strPathOp = [TEST_PATH]/backup/repo/temp/db.tmp, strPathType = backup:tmp - DEBUG: Backup->fileNotInManifest=>: stryFile = (file.tmp) - DEBUG: Backup->tmpClean: remove file [TEST_PATH]/backup/repo/temp/db.tmp/file.tmp + DEBUG: Backup->fileNotInManifest=>: stryFile = (pg_data/postgresql.conf.tmp) + DEBUG: Backup->tmpClean: remove file [TEST_PATH]/backup/repo/temp/db.tmp/pg_data/postgresql.conf.tmp DEBUG: Backup->processManifest(): bCompress = false, bHardLink = false, oBackupManifest = [object], strDbPath = [TEST_PATH]/db-master/db/base, strType = full DEBUG: File->pathCreate(): bCreateParents = <false>, bIgnoreExists = <false>, strMode = <0750>, strPath = pg_data, strPathType = backup:tmp DEBUG: File->pathCreate(): bCreateParents = <false>, bIgnoreExists = <false>, strMode = <0750>, strPath = pg_data/base, strPathType = backup:tmp [parent: 95bbc8ad544c]