Skip to content

Commit 69b1bc6

Browse files
author
Florian Schaal
committed
remove backups when deleting a web-domain
1 parent 4ad6849 commit 69b1bc6

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

server/plugins-available/apache2_plugin.inc.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,6 +1984,34 @@ function delete($event_name, $data) {
19841984
$app->services->restartServiceDelayed('httpd', 'reload');
19851985
}
19861986

1987+
//* Remove the web-backups
1988+
if($data['old']['type'] == 'vhost') {
1989+
$server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
1990+
$backup_dir = $server_config['backup_dir'];
1991+
//* mount backup directory, if necessary
1992+
$mount_backup = true;
1993+
$server_config['backup_dir_mount_cmd'] = trim($server_config['backup_dir_mount_cmd']);
1994+
if($server_config['backup_dir'] != '') {
1995+
if($server_config['backup_dir_is_mount'] == 'y' && $server_config['backup_dir_mount_cmd'] != ''){
1996+
if(!$app->system->is_mounted($backup_dir)){
1997+
exec(escapeshellcmd($server_config['backup_dir_mount_cmd']));
1998+
sleep(1);
1999+
if(!$app->system->is_mounted($backup_dir)) $mount_backup = false;
2000+
}
2001+
}
2002+
if($mount_backup){
2003+
//* remove web-archives
2004+
$web_backup_dir = $backup_dir.'/web'.$data_old['domain_id'];
2005+
//** do not use rm -rf $web_backup_dir because database(s) may exits
2006+
exec(escapeshellcmd('rm -f '.$web_backup_dir.'/web'.$data_old['domain_id'].'_').'*');
2007+
//* cleanup database
2008+
$sql = "DELETE FROM web_backup WHERE server_id = ".$conf['server_id']." AND parent_domain_id = ".$data_old['domain_id']." AND filename LIKE 'web".$data_old['domain_id']."_%'";
2009+
$app->db->query($sql);
2010+
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
2011+
}
2012+
}
2013+
unset($server_config);
2014+
}
19872015
}
19882016
if($data['old']['type'] != 'vhost') $app->system->web_folder_protection($data['old']['document_root'], true);
19892017
}

0 commit comments

Comments
 (0)