Show real next backup date (#196)

* Get the next backup date from what is scheduled in the background task.
* Show different message if cron is not running.
This commit is contained in:
Thomas Casteleyn
2021-06-30 14:59:36 +02:00
committed by GitHub
parent c7d87ad5b0
commit 94f662c71a
2 changed files with 18 additions and 6 deletions

View File

@@ -49,7 +49,8 @@ Dict::Add('EN US', 'English', 'English', array(
'bkp-status-backups-auto' => 'Scheduled backups',
'bkp-status-backups-manual' => 'Manual backups',
'bkp-status-backups-none' => 'No backup yet',
'bkp-next-backup' => 'The next backup will occur on <b>%1$s</b> (%2$s) at %3$s',
'bkp-next-backup' => 'The next backup will occur on <b>%1$s</b> (%2$s) at %3$s.',
'bkp-next-backup-unknown' => 'The next backup is <b>not scheduled</b> yet.',
'bkp-button-backup-now' => 'Backup now!',
'bkp-button-restore-now' => 'Restore!',
'bkp-confirm-backup' => 'Please confirm that you do request the backup to occur right now.',

View File

@@ -337,18 +337,29 @@ try {
);
}
// Do backup now
// Next occurrence
//
$oBackupExec = new BackupExec();
$oNext = $oBackupExec->GetNextOccurrence();
$sNextOccurrence = Dict::Format('bkp-next-backup', $aWeekDayToString[$oNext->Format('N')], $oNext->Format('Y-m-d'),
$oNext->Format('H:i'));
/** @var \BackgroundTask $oTask */
$oTask = MetaModel::GetObjectByName(BackgroundTask::class, BackupExec::class, false);
if ($oTask)
{
$oTimezone = new DateTimeZone(MetaModel::GetConfig()->Get('timezone'));
$oNext = new DateTime($oTask->Get('next_run_date'), $oTimezone);
$sNextOccurrence = Dict::Format('bkp-next-backup', $aWeekDayToString[$oNext->Format('N')], $oNext->Format('Y-m-d'),
$oNext->Format('H:i'));
}
else
{
$sNextOccurrence = Dict::S('bkp-next-backup-unknown');
}
$oFieldsetBackupNow->AddSubBlock(
AlertUIBlockFactory::MakeForInformation('', $sNextOccurrence)
->SetIsClosable(false)
->SetIsCollapsible(false)
);
// Do backup now
//
$oLaunchBackupButton = ButtonUIBlockFactory::MakeForPrimaryAction(Dict::S('bkp-button-backup-now'));
$oLaunchBackupButton->SetOnClickJsCode('LaunchBackupNow();');
$oFieldsetBackupNow->AddSubBlock($oLaunchBackupButton);