Skip to content

Commit 67c56b8

Browse files
committed
take next full backup into account to estimate next partial backup
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
1 parent 825de35 commit 67c56b8

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lib/Service/CronService.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ public function __construct(
108108
public function nextBackups(): array {
109109
$partialETA = $fullETA = -1;
110110

111+
$delayPartial = $this->configService->getAppValueInt(ConfigService::DELAY_PARTIAL_RP);
112+
$delayUnit = $this->configService->getAppValue(ConfigService::DELAY_UNIT);
113+
$delayPartial = $delayPartial * 3600 * (($delayUnit !== 'h') ? 24 : 1);
114+
111115
try {
112116
$this->getTime();
113117
$time = time() - 3600; // we start checking now.
@@ -116,12 +120,16 @@ public function nextBackups(): array {
116120
if (!$this->verifyTime($time)) {
117121
continue;
118122
}
123+
124+
$last = max($fullETA, $this->configService->getAppValueInt(ConfigService::DATE_FULL_RP));
125+
126+
// TODO: minor glitch: this will estimate the partial backup with one hour late.
119127
if ($fullETA === -1 && $this->verifyFullBackup($time)) {
120128
$fullETA = $time;
121129
} elseif ($partialETA === -1
122130
&& $this->verifyIncrementalBackup($time)
123-
&& ($this->configService->getAppValueInt(ConfigService::DATE_FULL_RP) > 0
124-
|| $fullETA > 0)) { // we check that the incremental backup can have a parent
131+
&& ($last > 0) // we check that the incremental backup can have a parent
132+
&& ($time - $last) > $delayPartial) { // we check the time since next full rp
125133
$partialETA = $time;
126134
}
127135

@@ -133,8 +141,8 @@ public function nextBackups(): array {
133141
}
134142

135143
return [
136-
'partial' => $partialETA,
137-
'full' => $fullETA
144+
'partial' => $partialETA + 300,
145+
'full' => $fullETA + 300
138146
];
139147
}
140148

0 commit comments

Comments
 (0)