Skip to content

Commit cc77c33

Browse files
author
Till Brehm
committed
Merge branch '6467_clear_backup_fix' into 'develop'
6467_clear_backup_fix See merge request ispconfig/ispconfig3!1737
2 parents dfd8ce8 + a91ae2f commit cc77c33

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

server/lib/classes/backup.inc.php

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ protected static function clearBackups($server_id, $web_id, $max_backup_copies,
11491149
@unlink($full_filename);
11501150
}
11511151
} elseif (self::backupModeIsRepos($backup_mode)) {
1152-
$repos_archives = self::getAllArchives($backup_dir, $backup_mode, $password);
1152+
$repos_archives = self::getAllArchives($backup_dir, $backup_mode, $password, $prefix_list);
11531153
usort($repos_archives, function ($a, $b) {
11541154
return ($a['created_at'] > $b['created_at']) ? -1 : 1;
11551155
});
@@ -1168,8 +1168,11 @@ protected static function clearBackups($server_id, $web_id, $max_backup_copies,
11681168
return true;
11691169
}
11701170

1171-
protected static function getAllArchives($backup_dir, $backup_mode, $password)
1172-
{
1171+
protected static function getAllArchives($backup_dir, $backup_mode, $password, $prefix_list = null) {
1172+
if (is_null($prefix_list)) {
1173+
global $app;
1174+
$app->log("prefix_list is null - [backupdir = $backup_dir, backupmode = $backup_mode ]", LOGLEVEL_WARN);
1175+
}
11731176
$d = dir($backup_dir);
11741177
$archives = [];
11751178
/**
@@ -1189,11 +1192,23 @@ protected static function getAllArchives($backup_dir, $backup_mode, $password)
11891192
if (is_dir($repos_path) && strncmp('borg_', $entry, 5) === 0) {
11901193
$archivesJson = json_decode(implode("", self::getReposArchives($backup_mode, $repos_path, $password, 'json')), TRUE);
11911194
foreach ($archivesJson['archives'] as $archive) {
1192-
$archives[] = [
1193-
'repos' => $entry,
1194-
'archive' => $archive['name'],
1195-
'created_at' => strtotime($archive['time']),
1196-
];
1195+
if (is_null($prefix_list)) { //fallback if no prefix_list
1196+
$archives[] = [
1197+
'repos' => $entry,
1198+
'archive' => $archive['name'],
1199+
'created_at' => strtotime($archive['time']),
1200+
];
1201+
} else {
1202+
foreach ($prefix_list as $prefix) {
1203+
if (substr($archive['name'], 0, strlen($prefix)) == $prefix) { //filter backup list of all if no prefix_list
1204+
$archives[] = [
1205+
'repos' => $entry,
1206+
'archive' => $archive['name'],
1207+
'created_at' => strtotime($archive['time']),
1208+
];
1209+
}
1210+
}
1211+
}
11971212
}
11981213
}
11991214
break;

0 commit comments

Comments
 (0)