diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php
index de71874f1f9f482d89c279857c5d4105ffbc5b66..499f23eb13d57f0b3af31df9532db6e703773874 100644
--- a/server/plugins-available/apache2_plugin.inc.php
+++ b/server/plugins-available/apache2_plugin.inc.php
@@ -1984,6 +1984,34 @@ class apache2_plugin {
 				$app->services->restartServiceDelayed('httpd', 'reload');
 			}
 
+			//* Delete the web-backups
+			if($data['old']['type'] == 'vhost') {
+				$server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
+				$backup_dir = $server_config['backup_dir'];
+				//* mount backup directory, if necessary
+				$mount_backup = true;
+				$server_config['backup_dir_mount_cmd'] = trim($server_config['backup_dir_mount_cmd']);
+				if($server_config['backup_dir'] != '') {
+					if($server_config['backup_dir_is_mount'] == 'y' && $server_config['backup_dir_mount_cmd'] != ''){
+						if(!$app->system->is_mounted($backup_dir)){
+							exec(escapeshellcmd($server_config['backup_dir_mount_cmd']));
+							sleep(1);
+							if(!$app->system->is_mounted($backup_dir)) $mount_backup = false;
+						}
+					}
+					if($mount_backup){
+						$web_backup_dir = $backup_dir.'/web'.$data_old['domain_id'];
+						//** do not use rm -rf $web_backup_dir because database(s) may exits
+						exec(escapeshellcmd('rm -f '.$web_backup_dir.'/web'.$data_old['domain_id'].'_').'*');
+						//* cleanup database
+						$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']."_%'";
+						$app->db->query($sql);
+						if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
+
+						$app->log('Deleted the web backup files', LOGLEVEL_DEBUG);
+					}
+				}
+			}
 		}
 		if($data['old']['type'] != 'vhost') $app->system->web_folder_protection($data['old']['document_root'], true);
 	}
diff --git a/server/plugins-available/mail_plugin.inc.php b/server/plugins-available/mail_plugin.inc.php
index 5bf37d14e46c6b76e9d7b55ca98949fe230e3499..378c4aded895c09830ae42481bdb6781e6eaecf8 100644
--- a/server/plugins-available/mail_plugin.inc.php
+++ b/server/plugins-available/mail_plugin.inc.php
@@ -317,13 +317,45 @@ class mail_plugin {
 		$app->uses("getconf");
 		$mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail');
 
+		$maildir_path_deleted = false;
 		$old_maildir_path = escapeshellcmd($data['old']['maildir']);
 		if($old_maildir_path != $mail_config['homedir_path'] && strlen($old_maildir_path) > strlen($mail_config['homedir_path']) && !stristr($old_maildir_path, '//') && !stristr($old_maildir_path, '..') && !stristr($old_maildir_path, '*') && strlen($old_maildir_path) >= 10) {
 			exec('rm -rf '.escapeshellcmd($old_maildir_path));
 			$app->log('Deleted the Maildir: '.$data['old']['maildir'], LOGLEVEL_DEBUG);
+			$maildir_path_deleted = true;
 		} else {
 			$app->log('Possible security violation when deleting the maildir: '.$data['old']['maildir'], LOGLEVEL_ERROR);
 		}
+		//* Delete the mail-backups
+		$server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
+		$backup_dir = $server_config['backup_dir'];
+		//* mount backup directory, if necessary
+		$mount_backup = true;
+		$server_config['backup_dir_mount_cmd'] = trim($server_config['backup_dir_mount_cmd']);
+		if($server_config['backup_dir'] != '' && $maildir_path_deleted) {
+			if($server_config['backup_dir_is_mount'] == 'y' && $server_config['backup_dir_mount_cmd'] != ''){
+				if(!$app->system->is_mounted($backup_dir)){
+					exec(escapeshellcmd($server_config['backup_dir_mount_cmd']));
+					sleep(1);
+					if(!$app->system->is_mounted($backup_dir)) $mount_backup = false;
+				}
+			}
+			if($mount_backup){
+				$sql = "SELECT * FROM mail_domain WHERE domain = '".explode("@",$data['old']['email'])[1]."'";
+				$domain_rec = $app->db->queryOneRecord($sql);
+				$mail_backup_dir = $backup_dir.'/mail'.$domain_rec['domain_id'];
+				$mail_backup_files = 'mail'.$data['old']['mailuser_id'];
+				exec(escapeshellcmd('rm -f '.$mail_backup_dir.'/'.$mail_backup_files).'*');
+				//* cleanup database
+				$sql = "DELETE FROM mail_backup WHERE server_id = ".$conf['server_id']." AND parent_domain_id = ".$domain_rec['domain_id']." AND mailuser_id = ".$data['old']['mailuser_id'];
+				$app->db->query($sql);
+				if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
+
+				$app->log('Deleted the mail backups for: '.$data['old']['email'], LOGLEVEL_DEBUG);
+				
+				
+			}
+		}
 	}
 
 	function domain_delete($event_name, $data) {
@@ -333,11 +365,13 @@ class mail_plugin {
 		$app->uses("getconf");
 		$mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail');
 
+		$maildomain_path_deleted = false;
 		//* Delete maildomain path
 		$old_maildomain_path = escapeshellcmd($mail_config['homedir_path'].'/'.$data['old']['domain']);
 		if($old_maildomain_path != $mail_config['homedir_path'] && !stristr($old_maildomain_path, '//') && !stristr($old_maildomain_path, '..') && !stristr($old_maildomain_path, '*') && !stristr($old_maildomain_path, '&') && strlen($old_maildomain_path) >= 10  && !empty($data['old']['domain'])) {
 			exec('rm -rf '.escapeshellcmd($old_maildomain_path));
 			$app->log('Deleted the mail domain directory: '.$old_maildomain_path, LOGLEVEL_DEBUG);
+			$maildomain_path_deleted = true;
 		} else {
 			$app->log('Possible security violation when deleting the mail domain directory: '.$old_maildomain_path, LOGLEVEL_ERROR);
 		}
@@ -350,6 +384,33 @@ class mail_plugin {
 		} else {
 			$app->log('Possible security violation when deleting the mail domain mailfilter directory: '.$old_maildomain_path, LOGLEVEL_ERROR);
 		}
+		
+		//* Delete the mail-backups
+		$server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
+		$backup_dir = $server_config['backup_dir'];
+		//* mount backup directory, if necessary
+		$mount_backup = true;
+		$server_config['backup_dir_mount_cmd'] = trim($server_config['backup_dir_mount_cmd']);
+		if($server_config['backup_dir'] != '' && $maildomain_path_deleted) {
+			if($server_config['backup_dir_is_mount'] == 'y' && $server_config['backup_dir_mount_cmd'] != ''){
+				if(!$app->system->is_mounted($backup_dir)){
+					exec(escapeshellcmd($server_config['backup_dir_mount_cmd']));
+					sleep(1);
+					if(!$app->system->is_mounted($backup_dir)) $mount_backup = false;
+				}
+			}
+			if($mount_backup){
+				$mail_backup_dir = $backup_dir.'/mail'.$data['old']['domain_id'];
+				exec(escapeshellcmd('rm -rf '.$mail_backup_dir));
+				//* cleanup database
+				$sql = "DELETE FROM mail_backup WHERE server_id = ".$conf['server_id']." AND parent_domain_id = ".$data['old']['domain_id'];
+				$app->db->query($sql);
+				if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
+
+				$app->log('Deleted the mail backup directory: '.$mail_backup_dir, LOGLEVEL_DEBUG);
+			}
+		}
+
 	}
 
 	function transport_update($event_name, $data) {