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

Fix delta restore failing when a linked file was missing.

This commit is contained in:
David Steele 2018-05-02 12:06:12 -04:00
parent 9d9fad88a2
commit 6a01db2b32
2 changed files with 15 additions and 5 deletions

View File

@ -32,6 +32,10 @@
<p>Fix <br-option>archive-copy</br-option> throwing <quote>path not found</quote> error for incr/diff backups.</p> <p>Fix <br-option>archive-copy</br-option> throwing <quote>path not found</quote> error for incr/diff backups.</p>
</release-item> </release-item>
<release-item>
<p>Fix delta restore failing when a linked file was missing.</p>
</release-item>
<release-item> <release-item>
<release-item-contributor-list> <release-item-contributor-list>
<release-item-ideator id="adams.clinton"/> <release-item-ideator id="adams.clinton"/>

View File

@ -9,6 +9,7 @@ use Carp qw(confess);
use Exporter qw(import); use Exporter qw(import);
our @EXPORT = qw(); our @EXPORT = qw();
use Fcntl qw(:mode);
use File::Basename qw(dirname); use File::Basename qw(dirname);
use File::stat qw(lstat); use File::stat qw(lstat);
@ -77,6 +78,7 @@ sub restoreFile
my $oStorageDb = storageDb(); my $oStorageDb = storageDb();
my $bCopy = true; my $bCopy = true;
# Zero file if requested
if ($bZero) if ($bZero)
{ {
$bCopy = false; $bCopy = false;
@ -90,16 +92,20 @@ sub restoreFile
$oDestinationFileIo->close(); $oDestinationFileIo->close();
} }
elsif ($oStorageDb->exists($strDbFile))
{
# Perform delta if requested # Perform delta if requested
if ($bDelta) elsif ($bDelta)
{
my $oStat = $oStorageDb->info($strDbFile, {bIgnoreMissing => true});
# Do the delta if the file exists and is not a link or the link destination exists
if (defined($oStat) &&
(!S_ISLNK($oStat->mode) ||
$oStorageDb->exists(
$oStorageDb->pathAbsolute(dirname($strDbFile), $oStorageDb->{oDriver}->linkDestination($strDbFile)))))
{ {
# If force then use size/timestamp delta # If force then use size/timestamp delta
if ($bForce) if ($bForce)
{ {
my $oStat = lstat($strDbFile);
# Make sure that timestamp/size are equal and that timestamp is before the copy start time of the backup # Make sure that timestamp/size are equal and that timestamp is before the copy start time of the backup
if (defined($oStat) && $oStat->size == $lSize && if (defined($oStat) && $oStat->size == $lSize &&
$oStat->mtime == $lModificationTime && $oStat->mtime < $lCopyTimeStart) $oStat->mtime == $lModificationTime && $oStat->mtime < $lCopyTimeStart)