You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-06-18 23:57:33 +02:00
Automatically enable backup checksum delta when anomalies (e.g. timeline switch) are detected.
There are a number of cases where a checksum delta is more appropriate than the default time-based delta: * Timeline has switched since the prior backup * File timestamp is older than recorded in the prior backup * File size changed but timestamp did not * File timestamp is in the future compared to the start of the backup * Online option has changed since the prior backup A practical example is that checksum delta will be enabled after a failover to standby due to the timeline switch. In this case, timestamps can't be trusted and our recommendation has been to run a full backup, which can impact the retention schedule and requires manual intervention. Now, a checksum delta will be performed if the backup type is incr/diff. This means more CPU will be used during the backup but the backup size will be smaller and the retention schedule will not be impacted. Contributed by Cynthia Shang.
This commit is contained in:
committed by
David Steele
parent
cca7a4ffd4
commit
34c63276cd
@ -968,32 +968,22 @@ sub run
|
||||
# Also create tablespace 11 to be sure it does not conflict with path of tablespace 1
|
||||
$oHostDbMaster->manifestTablespaceCreate(\%oManifest, 11);
|
||||
|
||||
# Change only the time on a valid file and update the timestamp in the expected manifest
|
||||
# Change only the time to be in the past on a valid file and update the timestamp in the expected manifest
|
||||
utime($lTime - 100, $lTime - 100, $oHostDbMaster->dbBasePath() . '/changetime.txt')
|
||||
or confess &log(ERROR, "unable to set time for file ".$oHostDbMaster->dbBasePath() . '/changetime.txt');
|
||||
$oManifest{&MANIFEST_SECTION_TARGET_FILE}{'pg_data/changetime.txt'}{&MANIFEST_SUBKEY_TIMESTAMP} = $lTime - 100;
|
||||
|
||||
# Change the content of the changecontent file to be the same size but not the timestamp on the file
|
||||
# Change the content of the changecontent file to be the same size but leave the timestamp the same on the file
|
||||
storageDb()->put($oHostDbMaster->dbBasePath() . '/changecontent.txt', 'CHGCONT');
|
||||
utime($lTime, $lTime, $oHostDbMaster->dbBasePath() . '/changecontent.txt')
|
||||
or confess &log(ERROR, "unable to set time for file ".$oHostDbMaster->dbBasePath() . '/changecontent.txt');
|
||||
|
||||
if ($bDeltaBackup)
|
||||
{
|
||||
# With --delta, the changetime file will not be recopied and the reference will remain to the last backup however,
|
||||
# the changecontent file will be recopied since the checksum has changed so update the checksum and remove the reference
|
||||
$oManifest{&MANIFEST_SECTION_TARGET_FILE}{'pg_data/changecontent.txt'}{&MANIFEST_SUBKEY_CHECKSUM} =
|
||||
"a094d94583e209556d03c3c5da33131a065f1689";
|
||||
delete($oManifest{&MANIFEST_SECTION_TARGET_FILE}{'pg_data/changecontent.txt'}{&MANIFEST_SUBKEY_REFERENCE});
|
||||
}
|
||||
else
|
||||
{
|
||||
# Without --delta, the changetime reference will be removed since the timestamp has changed but since the timestamp on
|
||||
# the changecontent did not change even though the contents did, it will still reference the prior backup - this may be
|
||||
# a rare occurrence and not good but it is one reason to use --delta
|
||||
delete($oManifest{&MANIFEST_SECTION_TARGET_FILE}{'pg_data/changetime.txt'}{&MANIFEST_SUBKEY_REFERENCE});
|
||||
$oManifest{&MANIFEST_SECTION_TARGET_FILE}{'pg_data/changetime.txt'}{&MANIFEST_SUBKEY_TIMESTAMP} = $lTime - 100;
|
||||
}
|
||||
# The changecontent & changetime files have conditions that will force the delta option to be turned on which should result
|
||||
# in the reference of changecontent to be removed but the reference to changetime to stay since the checksum wouldn't change
|
||||
$oManifest{&MANIFEST_SECTION_TARGET_FILE}{'pg_data/changecontent.txt'}{&MANIFEST_SUBKEY_CHECKSUM} =
|
||||
"a094d94583e209556d03c3c5da33131a065f1689";
|
||||
delete($oManifest{&MANIFEST_SECTION_TARGET_FILE}{'pg_data/changecontent.txt'}{&MANIFEST_SUBKEY_REFERENCE});
|
||||
$oManifest{&MANIFEST_SECTION_TARGET_FILE}{'pg_data/changetime.txt'}{&MANIFEST_SUBKEY_TIMESTAMP} = $lTime - 100;
|
||||
|
||||
$strBackup = $oHostBackup->backup(
|
||||
$strType, 'resume and add tablespace 2',
|
||||
|
Reference in New Issue
Block a user