1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-01-18 04:58:51 +02:00

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

This commit is contained in:
David Steele 2016-07-29 18:43:59 -04:00
parent 95bbc8ad54
commit ef33febfb7
3 changed files with 26 additions and 17 deletions

View File

@ -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> <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>
<release-item>
<p>Temp files created during backup are now placed in the same directory as the target file.</p>
</release-item>
<release-item> <release-item>
<p>Output lock file name when a lock cannot be acquired to aid in debugging.</p> <p>Output lock file name when a lock cannot be acquired to aid in debugging.</p>
</release-item> </release-item>

View File

@ -331,24 +331,34 @@ sub pathGet
{name => 'bTemp', default => false, trace => true} {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.*/; 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 # The file must be defined
if ($bTemp && !($strType eq PATH_BACKUP_ARCHIVE || $strType eq PATH_BACKUP_ARCHIVE_OUT || $strType eq PATH_BACKUP_TMP || if (!defined($strFile))
$bAbsolute))
{ {
confess &log(ASSERT, 'temp file not supported on path ' . $strType); confess &log(ASSERT, 'strFile must be defined when temp file requested');
}
} }
# Get absolute path # Get absolute path
if ($bAbsolute) 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) if (defined($bTemp) && $bTemp)
{ {
return $strFile . '.backrest.tmp'; return $strFile . '.backrest.tmp';
@ -378,14 +388,9 @@ sub pathGet
# Get the backup tmp path # Get the backup tmp path
if ($strType eq PATH_BACKUP_TMP) if ($strType eq PATH_BACKUP_TMP)
{ {
my $strTempPath = "$self->{strBackupPath}/temp/$self->{strStanza}.tmp"; return
"$self->{strBackupPath}/temp/$self->{strStanza}.tmp" . (defined($strFile) ? "/${strFile}" : '') .
if ($bTemp) ($bTemp ? (defined($self->{iThreadIdx}) ? ".$self->{iThreadIdx}" : '') . '.tmp' : '');
{
return "${strTempPath}/file.tmp" . (defined($self->{iThreadIdx}) ? ".$self->{iThreadIdx}" : '');
}
return "${strTempPath}" . (defined($strFile) ? "/${strFile}" : '');
} }
# Get the backup archive path # Get the backup archive path

View File

@ -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_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_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: 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->fileNotInManifest=>: stryFile = (pg_data/postgresql.conf.tmp)
DEBUG: Backup->tmpClean: remove file [TEST_PATH]/backup/repo/temp/db.tmp/file.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: 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, strPathType = backup:tmp
DEBUG: File->pathCreate(): bCreateParents = <false>, bIgnoreExists = <false>, strMode = <0750>, strPath = pg_data/base, strPathType = backup:tmp DEBUG: File->pathCreate(): bCreateParents = <false>, bIgnoreExists = <false>, strMode = <0750>, strPath = pg_data/base, strPathType = backup:tmp