From 3d06bad1c292ddef53dc384f96bbef7e1cd3725d Mon Sep 17 00:00:00 2001 From: Falko Timme <ft@falkotimme.com> Date: Fri, 09 Jan 2015 10:32:32 -0500 Subject: [PATCH] - Made sure SQL backups from servers that differ from the server where the website is on can be restored. A download of the backup is not possible in such a case, therefore I hide the "Download" button. --- server/plugins-available/backup_plugin.inc.php | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-) diff --git a/server/plugins-available/backup_plugin.inc.php b/server/plugins-available/backup_plugin.inc.php index c3ed1ae..249ca04 100644 --- a/server/plugins-available/backup_plugin.inc.php +++ b/server/plugins-available/backup_plugin.inc.php @@ -67,16 +67,30 @@ $app->uses('ini_parser,file,getconf,system'); - $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$backup['parent_domain_id']); + $web = $app->dbmaster->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$backup['parent_domain_id']); $server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); $backup_dir = $server_config['backup_dir'].'/web'.$web['domain_id']; //* mount backup directory, if necessary + /* $backup_dir_is_ready = true; $server_config['backup_dir_mount_cmd'] = trim($server_config['backup_dir_mount_cmd']); if($server_config['backup_dir_is_mount'] == 'y' && $server_config['backup_dir_mount_cmd'] != ''){ if(!$app->system->is_mounted($server_config['backup_dir'])){ exec(escapeshellcmd($server_config['backup_dir_mount_cmd'])); + sleep(1); + if(!$app->system->is_mounted($server_config['backup_dir'])) $backup_dir_is_ready = false; + } + }*/ + $backup_dir_is_ready = true; + $backup_dir_mount_cmd = '/usr/local/ispconfig/server/scripts/backup_dir_mount.sh'; + if( $server_config['backup_dir_is_mount'] == 'y' && + is_file($backup_dir_mount_cmd) && + is_executable($backup_dir_mount_cmd) && + fileowner($backup_dir_mount_cmd) === 0 + ){ + if(!$app->system->is_mounted($backup_dir)){ + exec($backup_dir_mount_cmd); sleep(1); if(!$app->system->is_mounted($server_config['backup_dir'])) $backup_dir_is_ready = false; } @@ -86,7 +100,7 @@ //* Make backup available for download if($action_name == 'backup_download') { //* Copy the backup file to the backup folder of the website - if(file_exists($backup_dir.'/'.$backup['filename']) && !stristr($backup_dir.'/'.$backup['filename'], '..') && !stristr($backup_dir.'/'.$backup['filename'], 'etc')) { + if(file_exists($backup_dir.'/'.$backup['filename']) && file_exists($web['document_root'].'/backup/') && !stristr($backup_dir.'/'.$backup['filename'], '..') && !stristr($backup_dir.'/'.$backup['filename'], 'etc')) { copy($backup_dir.'/'.$backup['filename'], $web['document_root'].'/backup/'.$backup['filename']); chgrp($web['document_root'].'/backup/'.$backup['filename'], $web['system_group']); $app->log('cp '.$backup_dir.'/'.$backup['filename'].' '.$web['document_root'].'/backup/'.$backup['filename'], LOGLEVEL_DEBUG); -- Gitblit v1.9.1