Skip to content

Commit a8e5278

Browse files
author
Till Brehm
committed
Merge branch 'develop' into 'develop'
Performance backup garbage collection potentially tries to delete same file multiple times See merge request ispconfig/ispconfig3!1885
2 parents 0be3d1e + 4a2fa12 commit a8e5278

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

server/lib/classes/backup.inc.php

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,22 +1197,25 @@ protected static function getAllArchives($backup_dir, $backup_mode, $password, $
11971197
case 'borg':
11981198
$repos_path = $backup_dir . '/' . $entry;
11991199
if (is_dir($repos_path) && strncmp('borg_', $entry, 5) === 0) {
1200-
$archivesJson = json_decode(implode("", self::getReposArchives($backup_mode, $repos_path, $password, 'json')), TRUE);
1201-
foreach ($archivesJson['archives'] as $archive) {
1202-
if (is_null($prefix_list)) { //fallback if no prefix_list
1203-
$archives[] = [
1204-
'repos' => $entry,
1205-
'archive' => $archive['name'],
1206-
'created_at' => strtotime($archive['time']),
1207-
];
1208-
} else {
1209-
foreach ($prefix_list as $prefix) {
1210-
if (substr($archive['name'], 0, strlen($prefix)) == $prefix) { //filter backup list of all if no prefix_list
1211-
$archives[] = [
1212-
'repos' => $entry,
1213-
'archive' => $archive['name'],
1214-
'created_at' => strtotime($archive['time']),
1215-
];
1200+
$repos_archives = self::getReposArchives($backup_mode, $repos_path, $password, 'json');
1201+
if(is_array($repos_archives)) {
1202+
$archivesJson = json_decode(implode("", $repos_archives), TRUE);
1203+
foreach ($archivesJson['archives'] as $archive) {
1204+
if (is_null($prefix_list)) { //fallback if no prefix_list
1205+
$archives[] = [
1206+
'repos' => $entry,
1207+
'archive' => $archive['name'],
1208+
'created_at' => strtotime($archive['time']),
1209+
];
1210+
} else {
1211+
foreach ($prefix_list as $prefix) {
1212+
if (substr($archive['name'], 0, strlen($prefix)) == $prefix) { //filter backup list of all if no prefix_list
1213+
$archives[] = [
1214+
'repos' => $entry,
1215+
'archive' => $archive['name'],
1216+
'created_at' => strtotime($archive['time']),
1217+
];
1218+
}
12161219
}
12171220
}
12181221
}
@@ -1313,8 +1316,8 @@ protected static function backups_garbage_collection($server_id, $backup_type =
13131316
}
13141317
}
13151318
}
1316-
array_unique( $untracked_backup_files );
1317-
foreach ($untracked_backup_files as $f) {
1319+
$unique_untracked_backup_files = array_unique( $untracked_backup_files );
1320+
foreach ($unique_untracked_backup_files as $f) {
13181321
$backup_file = $backup_dir . '/web' . $domain_id . '/' . $f;
13191322
$app->log('Backup file ' . $backup_file . ' is not contained in database, deleting this file from disk', LOGLEVEL_DEBUG);
13201323
@unlink($backup_file);

0 commit comments

Comments
 (0)