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

Backup start/stop timestamp now stored in backup.manifest

This commit is contained in:
David Steele 2014-08-12 19:04:46 -04:00
parent 34cb57f925
commit 672c6b2ccb
3 changed files with 20 additions and 10 deletions

View File

@ -12,12 +12,6 @@ Put something here, there are people to recognize!
## feature backlog
* When resuming backups, do not resume from a backup of a different type.
* Set backup dir name to date/time when backup completes (after stop backup). This indicates the time from which recovery is possible. Right now the timestamp is from the beginning of the backup which can be misleading.
* Store actual backup begin and end times in backup.manifest
* Move backups to be removed to temp before deleting.
* Async archive-get.

View File

@ -823,11 +823,11 @@ sub backup_manifest_build
${$oBackupManifestRef}{"${strSection}"}{"$strName"}{user} = $oManifestHash{name}{"${strName}"}{user};
${$oBackupManifestRef}{"${strSection}"}{"$strName"}{group} = $oManifestHash{name}{"${strName}"}{group};
${$oBackupManifestRef}{"${strSection}"}{"$strName"}{permission} = $oManifestHash{name}{"${strName}"}{permission};
${$oBackupManifestRef}{"${strSection}"}{"$strName"}{modification_time} = $oManifestHash{name}{"${strName}"}{modification_time};
if ($cType eq "f")
{
${$oBackupManifestRef}{"${strSection}"}{"$strName"}{size} = $oManifestHash{name}{"${strName}"}{size};
${$oBackupManifestRef}{"${strSection}"}{"$strName"}{modification_time} = $oManifestHash{name}{"${strName}"}{modification_time};
}
if ($cType eq "f" || $cType eq "l")
@ -1268,6 +1268,9 @@ sub backup
my $strDbClusterPath = shift;
my $bStartFast = shift;
# Record timestamp start
my $strTimestampStart = timestamp_get();
# Not supporting remote backup hosts yet
if ($oFile->is_remote(PATH_BACKUP))
{
@ -1335,6 +1338,7 @@ sub backup
# Start backup
my %oBackupManifest;
${oBackupManifest}{backup}{label} = $strBackupPath;
${oBackupManifest}{backup}{timestamp_start} = $strTimestampStart;
my $strArchiveStart = $oDb->backup_start($strBackupPath, $bStartFast);
${oBackupManifest}{backup}{"archive-start"} = $strArchiveStart;
@ -1416,6 +1420,9 @@ sub backup
# Need some sort of backup validate - create a manifest and compare the backup to manifest
# !!! DO IT
# Record timestamp stop in the config
${oBackupManifest}{backup}{timestamp_stop} = timestamp_get();
# Save the backup conf file final time
config_save($strBackupConfFile, \%oBackupManifest);

View File

@ -22,7 +22,7 @@ our @EXPORT = qw(version_get
data_hash_build trim common_prefix wait_for_file date_string_get file_size_format execute
log log_file_set log_level_set test_set test_check
lock_file_create lock_file_remove
config_save config_load
config_save config_load timestamp_get
TRACE DEBUG ERROR ASSERT WARN INFO OFF true false
TEST TEST_ENCLOSE TEST_MANIFEST_BUILD);
@ -400,6 +400,16 @@ sub test_check
return index($strLog, TEST_ENCLOSE . '-' . $strTest . '-' . TEST_ENCLOSE) != -1;
}
####################################################################################################################################
# TIMESTAMP_GET - Get backrest standard timestamp
####################################################################################################################################
sub timestamp_get
{
my ($iSecond, $iMinute, $iHour, $iMonthDay, $iMonth, $iYear, $iWeekDay, $iYearDay, $bIsDst) = localtime(time);
return sprintf("%4d-%02d-%02d %02d:%02d:%02d", $iYear + 1900, $iMonth + 1, $iMonthDay, $iHour, $iMinute, $iSecond);
}
####################################################################################################################################
# LOG - log messages
####################################################################################################################################
@ -449,8 +459,7 @@ sub log
# Format the message text
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
$strMessageFormat = sprintf("%4d-%02d-%02d %02d:%02d:%02d", $year+1900, $mon+1, $mday, $hour, $min, $sec) .
sprintf(" T%02d", threads->tid()) .
$strMessageFormat = timestamp_get() . sprintf(" T%02d", threads->tid()) .
(" " x (7 - length($strLevel))) . "${strLevel}: ${strMessageFormat}" .
(defined($iCode) ? " (code ${iCode})" : "") . "\n";