Skip to content

Commit c4f85a9

Browse files
author
Till Brehm
committed
Merge branch 'number_of_backups' into 'develop'
backups: # backups and default exclusions Closes #3270 and #5787 See merge request ispconfig/ispconfig3!1233
2 parents a7a114c + 8ae1a80 commit c4f85a9

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

server/lib/classes/backup.inc.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -691,11 +691,11 @@ protected static function get7zDecompressOptions($password)
691691
* @see backup_plugin::mount_backup_dir()
692692
* @author Ramil Valitov <ramilvalitov@gmail.com>
693693
*/
694-
protected static function clearBackups($server_id, $web_id, $max_backup_copies, $backup_dir)
694+
protected static function clearBackups($server_id, $web_id, $max_backup_copies, $backup_dir, $prefix_list=null)
695695
{
696696
global $app;
697697

698-
$files = self::get_files($backup_dir);
698+
$files = self::get_files($backup_dir, $prefix_list);
699699
usort($files, function ($a, $b) use ($backup_dir) {
700700
$time_a = filemtime($backup_dir . '/' . $a);
701701
$time_b = filemtime($backup_dir . '/' . $b);
@@ -1214,7 +1214,11 @@ protected static function make_database_backup($web_domain, $backup_job)
12141214

12151215
//* Remove old backups
12161216
self::backups_garbage_collection($server_id, 'mysql', $domain_id);
1217-
self::clearBackups($server_id, $domain_id, intval($rec['backup_copies']), $db_backup_dir);
1217+
$prefix_list = array(
1218+
'db_'.escapeshellarg($db_name).'_',
1219+
'manual-db_'.escapeshellarg($db_name).'_',
1220+
);
1221+
self::clearBackups($server_id, $domain_id, intval($rec['backup_copies']), $db_backup_dir, $prefix_list);
12181222
} else {
12191223
$app->log('Failed to process mysql backup format ' . $backup_format_db . ' for database ' . $rec['database_name'], LOGLEVEL_ERROR);
12201224
}
@@ -1285,7 +1289,13 @@ protected static function make_web_backup($web_domain, $backup_job)
12851289
self::prepare_backup_dir($server_id, $web_domain);
12861290
$web_backup_dir = $backup_dir . '/web' . $web_id;
12871291

1288-
$backup_excludes = array(escapeshellarg('./backup\*'));
1292+
# default exclusions
1293+
$backup_excludes = array(
1294+
escapeshellarg('./backup\*'),
1295+
'./bin', './dev', './etc', './lib', './lib32', './lib64', './opt', './sys', './usr', './var', './proc', './run', './tmp',
1296+
'./log',
1297+
);
1298+
12891299
$b_excludes = explode(',', trim($web_domain['backup_excludes']));
12901300
if (is_array($b_excludes) && !empty($b_excludes)) {
12911301
foreach ($b_excludes as $b_exclude) {
@@ -1324,7 +1334,11 @@ protected static function make_web_backup($web_domain, $backup_job)
13241334
$app->log('Backup of web files for domain ' . $web_domain['domain'] . ' failed using path ' . $web_path . ' failed.', LOGLEVEL_ERROR);
13251335
}
13261336

1327-
self::clearBackups($server_id, $web_id, intval($web_domain['backup_copies']), $web_backup_dir);
1337+
$prefix_list = array(
1338+
'web',
1339+
'manual-web',
1340+
);
1341+
self::clearBackups($server_id, $web_id, intval($web_domain['backup_copies']), $web_backup_dir, $prefix_list);
13281342
return true;
13291343
}
13301344

0 commit comments

Comments
 (0)