Skip to content

Commit 22903ac

Browse files
committed
- Fixed FS#3123 - Old backups are still shown in backup list.
1 parent 2c76f1a commit 22903ac

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed

interface/lib/classes/plugin_backuplist.inc.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ function onShow() {
108108
}
109109

110110
//* Get the data
111-
$sql = "SELECT * FROM web_backup WHERE parent_domain_id = ".$this->form->id." ORDER BY tstamp DESC, backup_type ASC";
111+
$web = $app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE domain_id = ".$this->form->id);
112+
$sql = "SELECT * FROM web_backup WHERE parent_domain_id = ".$this->form->id." AND server_id = ".$web['server_id']." ORDER BY tstamp DESC, backup_type ASC";
112113
$records = $app->db->queryAllRecords($sql);
113114

114115
$bgcolor = "#FFFFFF";

server/cron_daily.php

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ function send_notification_email($template, $placeholders, $recipients) {
11031103
chmod(escapeshellcmd($backup_dir), $backup_dir_permissions);
11041104
}
11051105

1106-
$sql = "SELECT * FROM web_domain WHERE server_id = '".$conf['server_id']."' AND (type = 'vhost' OR type = 'vhostsubdomain') AND backup_interval != 'none'";
1106+
$sql = "SELECT * FROM web_domain WHERE server_id = ".$conf['server_id']." AND (type = 'vhost' OR type = 'vhostsubdomain')";
11071107
$records = $app->db->queryAllRecords($sql);
11081108
if(is_array($records)) {
11091109
foreach($records as $rec) {
@@ -1136,16 +1136,18 @@ function send_notification_email($template, $placeholders, $recipients) {
11361136
exec('tar pczf '.escapeshellarg($web_backup_dir.'/'.$web_backup_file).' --exclude=backup\* --directory '.escapeshellarg($web_path).' .', $tmp_output, $retval);
11371137
}
11381138
if($retval == 0 || $backup_mode != 'userzip'){ // tar can return 1 (due to harmless warings) and still create valid backups
1139-
chown($web_backup_dir.'/'.$web_backup_file, 'root');
1140-
chgrp($web_backup_dir.'/'.$web_backup_file, 'root');
1141-
chmod($web_backup_dir.'/'.$web_backup_file, 0750);
1142-
1143-
//* Insert web backup record in database
1144-
//$insert_data = "(server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (".$conf['server_id'].",".$web_id.",'web','".$backup_mode."',".time().",'".$app->db->quote($web_backup_file)."')";
1145-
//$app->dbmaster->datalogInsert('web_backup', $insert_data, 'backup_id');
1146-
$sql = "INSERT INTO web_backup (server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (".$conf['server_id'].",".$web_id.",'web','".$backup_mode."',".time().",'".$app->db->quote($web_backup_file)."')";
1147-
$app->db->query($sql);
1148-
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
1139+
if(is_file($web_backup_dir.'/'.$web_backup_file)){
1140+
chown($web_backup_dir.'/'.$web_backup_file, 'root');
1141+
chgrp($web_backup_dir.'/'.$web_backup_file, 'root');
1142+
chmod($web_backup_dir.'/'.$web_backup_file, 0750);
1143+
1144+
//* Insert web backup record in database
1145+
//$insert_data = "(server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (".$conf['server_id'].",".$web_id.",'web','".$backup_mode."',".time().",'".$app->db->quote($web_backup_file)."')";
1146+
//$app->dbmaster->datalogInsert('web_backup', $insert_data, 'backup_id');
1147+
$sql = "INSERT INTO web_backup (server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (".$conf['server_id'].",".$web_id.",'web','".$backup_mode."',".time().",'".$app->db->quote($web_backup_file)."')";
1148+
$app->db->query($sql);
1149+
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
1150+
}
11491151
} else {
11501152
if(is_file($web_backup_dir.'/'.$web_backup_file)) unlink($web_backup_dir.'/'.$web_backup_file);
11511153
}
@@ -1198,7 +1200,7 @@ function send_notification_email($template, $placeholders, $recipients) {
11981200

11991201
/* If backup_interval is set to none and we have a
12001202
backup directory for the website, then remove the backups */
1201-
if($rec['backup_interval'] == 'none') {
1203+
if($rec['backup_interval'] == 'none' || $rec['backup_interval'] == '') {
12021204
$web_id = $rec['domain_id'];
12031205
$web_user = $rec['system_user'];
12041206
$web_backup_dir = realpath($backup_dir.'/web'.$web_id);
@@ -1209,7 +1211,7 @@ function send_notification_email($template, $placeholders, $recipients) {
12091211
}
12101212
}
12111213

1212-
$sql = "SELECT * FROM web_database WHERE server_id = '".$conf['server_id']."' AND backup_interval != 'none'";
1214+
$sql = "SELECT * FROM web_database WHERE server_id = ".$conf['server_id']." AND backup_interval != 'none' AND backup_interval != ''";
12131215
$records = $app->db->queryAllRecords($sql);
12141216
if(is_array($records)) {
12151217

@@ -1239,17 +1241,18 @@ function send_notification_email($template, $placeholders, $recipients) {
12391241
if($retval == 0) exec("gzip -c '".escapeshellcmd($db_backup_dir.'/'.$db_backup_file)."' > '".escapeshellcmd($db_backup_dir.'/'.$db_backup_file).".gz'", $tmp_output, $retval);
12401242

12411243
if($retval == 0){
1242-
chmod($db_backup_dir.'/'.$db_backup_file.'.gz', 0750);
1243-
chown($db_backup_dir.'/'.$db_backup_file.'.gz', fileowner($db_backup_dir));
1244-
chgrp($db_backup_dir.'/'.$db_backup_file.'.gz', filegroup($db_backup_dir));
1245-
1246-
//* Insert web backup record in database
1247-
//$insert_data = "(server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (".$conf['server_id'].",$web_id,'mysql','sqlgz',".time().",'".$app->db->quote($db_backup_file).".gz')";
1248-
//$app->dbmaster->datalogInsert('web_backup', $insert_data, 'backup_id');
1249-
$sql = "INSERT INTO web_backup (server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (".$conf['server_id'].",$web_id,'mysql','sqlgz',".time().",'".$app->db->quote($db_backup_file).".gz')";
1250-
$app->db->query($sql);
1251-
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
1252-
1244+
if(is_file($db_backup_dir.'/'.$db_backup_file.'.gz')){
1245+
chmod($db_backup_dir.'/'.$db_backup_file.'.gz', 0750);
1246+
chown($db_backup_dir.'/'.$db_backup_file.'.gz', fileowner($db_backup_dir));
1247+
chgrp($db_backup_dir.'/'.$db_backup_file.'.gz', filegroup($db_backup_dir));
1248+
1249+
//* Insert web backup record in database
1250+
//$insert_data = "(server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (".$conf['server_id'].",$web_id,'mysql','sqlgz',".time().",'".$app->db->quote($db_backup_file).".gz')";
1251+
//$app->dbmaster->datalogInsert('web_backup', $insert_data, 'backup_id');
1252+
$sql = "INSERT INTO web_backup (server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (".$conf['server_id'].",$web_id,'mysql','sqlgz',".time().",'".$app->db->quote($db_backup_file).".gz')";
1253+
$app->db->query($sql);
1254+
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
1255+
}
12531256
} else {
12541257
if(is_file($db_backup_dir.'/'.$db_backup_file.'.gz')) unlink($db_backup_dir.'/'.$db_backup_file.'.gz');
12551258
}

0 commit comments

Comments
 (0)