Added backup function to froxlor, fixes #186

Thanks to monotek.
This commit is contained in:
Andreas Burchert (scarya)
2011-04-24 02:18:50 +02:00
parent a97e7d3697
commit 7890730afa
17 changed files with 525 additions and 7 deletions

View File

@@ -0,0 +1,106 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Settings
* @version $Id: 215.backup.php 1 2010-09-14 08:09:17Z monotek $
*/
return array(
'groups' => array(
'backup' => array(
'title' => $lng['backup'],
'fields' => array(
'backup_enabled' => array(
'label' => $lng['serversettings']['backup_enabled'],
'settinggroup' => 'system',
'varname' => 'backup_enabled',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField',
'overview_option' => true
),
'backup_dir' => array(
'label' => $lng['serversettings']['backupdir']['description'],
'settinggroup' => 'system',
'varname' => 'backup_dir',
'type' => 'string',
'default' => '#froxlor_backup',
'save_method' => 'storeSettingField',
),
'backup_mysqldump_path' => array(
'label' => $lng['serversettings']['mysqldump_path']['description'],
'settinggroup' => 'system',
'varname' => 'backup_mysqldump_path',
'type' => 'string',
'default' => '/usr/bin/mysqldump',
'save_method' => 'storeSettingField',
),
'backup_count' => array(
'label' => $lng['serversettings']['backup_count'],
'settinggroup' => 'system',
'varname' => 'backup_count',
'type' => 'bool',
'default' => 'true',
'save_method' => 'storeSettingField',
'overview_option' => false
),
'backup_bigfile' => array(
'label' => $lng['serversettings']['backup_bigfile'],
'settinggroup' => 'system',
'varname' => 'backup_bigfile',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField',
'overview_option' => false
),
'backup_ftp_enabled_' => array(
'label' => $lng['serversettings']['backup_ftp_enabled'],
'settinggroup' => 'system',
'varname' => 'backup_ftp_enabled',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField',
'overview_option' => false
),
'backup_server' => array(
'label' => $lng['serversettings']['backup_ftp_server'],
'settinggroup' => 'system',
'varname' => 'backup_ftp_server',
'type' => 'string',
'default' => '',
'save_method' => 'storeSettingField',
),
'backup_user' => array(
'label' => $lng['serversettings']['backup_ftp_user'],
'settinggroup' => 'system',
'varname' => 'backup_ftp_user',
'type' => 'string',
'default' => '',
'save_method' => 'storeSettingField',
),
'backup_pass' => array(
'label' => $lng['serversettings']['backup_ftp_pass'],
'settinggroup' => 'system',
'varname' => 'backup_ftp_pass',
'type' => 'string',
'default' => '',
'save_method' => 'storeSettingField',
),
),
),
),
);
?>

View File

@@ -53,7 +53,8 @@ if($page == 'customers'
'c.diskspace' => $lng['customer']['diskspace'],
'c.diskspace_used' => $lng['customer']['diskspace'] . ' (' . $lng['panel']['used'] . ')',
'c.traffic' => $lng['customer']['traffic'],
'c.traffic_used' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')'
'c.traffic_used' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')',
'c.backup_allowed' => $lng['backup_allowed']
/*
'c.mysqls' => $lng['customer']['mysqls'],
'c.mysqls_used' => $lng['customer']['mysqls'] . ' (' . $lng['panel']['used'] . ')',
@@ -509,6 +510,15 @@ if($page == 'customers'
$password = validatePassword($password);
}
$backup_allowed = 0;
if(isset($_POST['backup_allowed']))
$backup_allowed = intval($_POST['backup_allowed']);
if ($backup_allowed != 0)
{
$backup_allowed = 1;
}
$sendpassword = 0;
if(isset($_POST['sendpassword']))
$sendpassword = intval($_POST['sendpassword']);
@@ -676,6 +686,7 @@ if($page == 'customers'
`aps_packages` = '" . (int)$number_of_aps_packages . "',
`perlenabled` = '" . $db->escape($perlenabled) . "',
`email_autoresponder` = '" . $db->escape($email_autoresponder) . "',
`backup_allowed' = '" . $db->escape($backup_allowed) . "',
`theme` = '" . $db->escape($_theme) . "'"
);
$customerid = $db->insert_id();
@@ -885,7 +896,8 @@ if($page == 'customers'
#$phpenabled = makeyesno('phpenabled', '1', '0', '1');
#$perlenabled = makeyesno('perlenabled', '1', '0', '0');
#$store_defaultindex = makeyesno('store_defaultindex', '1', '0', '1');
$backup_allowed = makeyesno('backup_allowed', '1', '0', '0');
$customer_add_data = include_once dirname(__FILE__).'/lib/formfields/admin/customer/formfield.customer_add.php';
$customer_add_form = htmlform::genHTMLForm($customer_add_data);
@@ -1012,6 +1024,14 @@ if($page == 'customers'
{
$tickets = - 1;
}
$backup_allowed = 0;
if (isset($_POST['backup_allowed']))
$backup_allowed = intval($_POST['backup_allowed']);
if($backup_allowed != '0'){
$backup_allowed = 1;
}
$mysqls = 0;
if(isset($_POST['mysqls']))
@@ -1232,7 +1252,8 @@ if($page == 'customers'
$db->query("UPDATE `" . TABLE_MAIL_USERS . "` SET `imap`='" . (int)$email_imap . "' WHERE `customerid`='" . (int)$id . "'");
}
$db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `name`='" . $db->escape($name) . "', `firstname`='" . $db->escape($firstname) . "', `company`='" . $db->escape($company) . "', `street`='" . $db->escape($street) . "', `zipcode`='" . $db->escape($zipcode) . "', `city`='" . $db->escape($city) . "', `phone`='" . $db->escape($phone) . "', `fax`='" . $db->escape($fax) . "', `email`='" . $db->escape($email) . "', `customernumber`='" . $db->escape($customernumber) . "', `def_language`='" . $db->escape($def_language) . "', `password` = '" . $password . "', `diskspace`='" . $db->escape($diskspace) . "', `traffic`='" . $db->escape($traffic) . "', `subdomains`='" . $db->escape($subdomains) . "', `emails`='" . $db->escape($emails) . "', `email_accounts` = '" . $db->escape($email_accounts) . "', `email_forwarders`='" . $db->escape($email_forwarders) . "', `ftps`='" . $db->escape($ftps) . "', `tickets`='" . $db->escape($tickets) . "', `mysqls`='" . $db->escape($mysqls) . "', `deactivated`='" . $db->escape($deactivated) . "', `phpenabled`='" . $db->escape($phpenabled) . "', `email_quota`='" . $db->escape($email_quota) . "', `imap`='" . $db->escape($email_imap) . "', `pop3`='" . $db->escape($email_pop3) . "', `aps_packages`='" . (int)$number_of_aps_packages . "', `perlenabled`='" . $db->escape($perlenabled) . "', `email_autoresponder`='" . $db->escape($email_autoresponder) . "' WHERE `customerid`='" . (int)$id . "'");
// $db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `name`='" . $db->escape($name) . "', `firstname`='" . $db->escape($firstname) . "', `company`='" . $db->escape($company) . "', `street`='" . $db->escape($street) . "', `zipcode`='" . $db->escape($zipcode) . "', `city`='" . $db->escape($city) . "', `phone`='" . $db->escape($phone) . "', `fax`='" . $db->escape($fax) . "', `email`='" . $db->escape($email) . "', `customernumber`='" . $db->escape($customernumber) . "', `def_language`='" . $db->escape($def_language) . "', `password` = '" . $password . "', `diskspace`='" . $db->escape($diskspace) . "', `traffic`='" . $db->escape($traffic) . "', `subdomains`='" . $db->escape($subdomains) . "', `emails`='" . $db->escape($emails) . "', `email_accounts` = '" . $db->escape($email_accounts) . "', `email_forwarders`='" . $db->escape($email_forwarders) . "', `ftps`='" . $db->escape($ftps) . "', `tickets`='" . $db->escape($tickets) . "', `mysqls`='" . $db->escape($mysqls) . "', `deactivated`='" . $db->escape($deactivated) . "', `phpenabled`='" . $db->escape($phpenabled) . "', `email_quota`='" . $db->escape($email_quota) . "', `imap`='" . $db->escape($email_imap) . "', `pop3`='" . $db->escape($email_pop3) . "', `aps_packages`='" . (int)$number_of_aps_packages . "', `perlenabled`='" . $db->escape($perlenabled) . "', `email_autoresponder`='" . $db->escape($email_autoresponder) . "' WHERE `customerid`='" . (int)$id . "'");
$db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `name`='" . $db->escape($name) . "', `firstname`='" . $db->escape($firstname) . "', `company`='" . $db->escape($company) . "', `street`='" . $db->escape($street) . "', `zipcode`='" . $db->escape($zipcode) . "', `city`='" . $db->escape($city) . "', `phone`='" . $db->escape($phone) . "', `fax`='" . $db->escape($fax) . "', `email`='" . $db->escape($email) . "', `customernumber`='" . $db->escape($customernumber) . "', `def_language`='" . $db->escape($def_language) . "', `password` = '" . $password . "', `diskspace`='" . $db->escape($diskspace) . "', `traffic`='" . $db->escape($traffic) . "', `subdomains`='" . $db->escape($subdomains) . "', `emails`='" . $db->escape($emails) . "', `email_accounts` = '" . $db->escape($email_accounts) . "', `email_forwarders`='" . $db->escape($email_forwarders) . "', `ftps`='" . $db->escape($ftps) . "', `tickets`='" . $db->escape($tickets) . "', `mysqls`='" . $db->escape($mysqls) . "', `deactivated`='" . $db->escape($deactivated) . "', `phpenabled`='" . $db->escape($phpenabled) . "', `email_quota`='" . $db->escape($email_quota) . "', `imap`='" . $db->escape($email_imap) . "', `pop3`='" . $db->escape($email_pop3) . "', `aps_packages`='" . (int)$number_of_aps_packages . "', `perlenabled`='" . $db->escape($perlenabled) . "', `email_autoresponder`='" . $db->escape($email_autoresponder) . "', `backup_allowed`='" . $db->escape($backup_allowed) . "' WHERE `customerid`='" . (int)$id . "'");
$admin_update_query = "UPDATE `" . TABLE_PANEL_ADMINS . "` SET `customers_used` = `customers_used` ";
if($mysqls != '-1'
@@ -1524,7 +1545,7 @@ if($page == 'customers'
#$deactivated = makeyesno('deactivated', '1', '0', $result['deactivated']);
#$email_imap = makeyesno('email_imap', '1', '0', $result['imap']);
#$email_pop3 = makeyesno('email_pop3', '1', '0', $result['pop3']);
$backup_allowed = makeyesno('backup_allowed', '1', '0', $result['backup_allowed']);
$result = htmlentities_array($result);
$customer_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/customer/formfield.customer_edit.php';

View File

@@ -79,6 +79,7 @@ if(($page == 'settings' || $page == 'overview')
inserttask('1');
inserttask('4');
inserttask('5');
inserttask('9');
standard_success('settingssaved', '', array('filename' => $filename, 'action' => $action, 'page' => $page));
}
}
@@ -119,6 +120,7 @@ elseif($page == 'rebuildconfigs'
inserttask('1');
inserttask('4');
inserttask('5');
inserttask('9');
standard_success('rebuildingconfigs', '', array('filename' => 'admin_index.php'));
}
else

View File

@@ -39,6 +39,25 @@ if($page == 'overview')
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_extras");
eval("echo \"" . getTemplate("extras/extras") . "\";");
}
elseif($page == 'backup')
{
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_extras_backup");
$result = $db->query("SELECT `backup_enabled` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "'");
$row = $db->fetch_array($result);
$backup_enabled = makeyesno('backup_enabled', '1', '0', $row['backup_enabled']);
if(isset($_POST['send']) && $_POST['send'] == 'send'){
$backup_enabled = ($_POST['backup_enabled'] == '1' ? '1' : '0');
$backup_ftp_enabled = ($_POST['backup_ftp_enabled'] == '1' ? '1' : '0');
$db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `backup_enabled`='" . $backup_enabled . "' WHERE `customerid`='" . (int)$userinfo['customerid'] . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
eval("echo \"" . getTemplate("extras/backup") . "\";");
}
elseif($page == 'htpasswds')
{
if($action == '')

View File

@@ -618,7 +618,16 @@ INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('syste
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'report_trafficmax', '90');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('panel', 'default_theme', 'Froxlor');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'validate_domain', '1');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_enabled', '1');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_dir', '#froxlor_backup');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_mysqldump_path', '/usr/bin/mysqldump');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_count', '1');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_bigfile', '1');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_enabled', '0');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_enabled', '0');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_server', '');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_user', '');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_pass', '');
# --------------------------------------------------------
#
@@ -1027,7 +1036,7 @@ INSERT INTO `cronjobs_run` (`id`, `module`, `cronfile`, `interval`, `isactive`,
INSERT INTO `cronjobs_run` (`id`, `module`, `cronfile`, `interval`, `isactive`, `desc_lng_key`) VALUES (6, 'froxlor/ticket', 'cron_used_tickets_reset.php', '1 DAY', '1', 'cron_ticketsreset');
INSERT INTO `cronjobs_run` (`id`, `module`, `cronfile`, `interval`, `isactive`, `desc_lng_key`) VALUES (7, 'froxlor/ticket', 'cron_ticketarchive.php', '1 MONTH', '1', 'cron_ticketarchive');
INSERT INTO `cronjobs_run` (`id`, `module`, `cronfile`, `interval`, `isactive`, `desc_lng_key`) VALUES (8, 'froxlor/reports', 'cron_usage_report.php', '1 DAY', '1', 'cron_usage_report');
INSERT INTO `cronjobs_run` (`id`, `module`, `cronfile`, `interval`, `isactive`, `desc_lng_key`) VALUES (9, 'froxlor/backup', 'cron_backup.php', '1 Day', '1', 'cron_backup');
# --------------------------------------------------------
#

View File

@@ -1483,6 +1483,29 @@ if(isFroxlorVersion('0.9.18'))
updateToVersion('0.9.18.1');
}
if(isFroxlorVersion('0.9.18.1'))
{
showUpdateStep("Updating from 0.9.18.1 to 0.9.18.2");
// adding backup stuff
$db->query("ALTER TABLE `" . TABLE_PANEL_CUSTOMERS . "` ADD `backup_allowed` TINYINT( 1 ) NOT NULL DEFAULT '1'");
$db->query("ALTER TABLE `" . TABLE_PANEL_CUSTOMERS . "` ADD `backup_enabled` TINYINT( 1 ) NOT NULL DEFAULT '0'");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_enabled', '1')");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_dir', '#froxlor_backup')");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_mysqldump_path', '/usr/bin/mysqldump')");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_count', '1')");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_bigfile', '1')");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_enabled', '0')");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_server', '')");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_user', '')");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_pass', '')");
$db->query("INSERT INTO `" . TABLE_PANEL_CRONRUNS . "` (`module`, `cronfile`, `interval`, `isactive`, `desc_lng_key`) VALUES ('froxlor/backup', 'cron_backup.php', '1 Day', '1', 'cron_backup');");
lastStepStatus(0);
updateToVersion('0.9.18.2');
}
if(isFroxlorVersion('0.9.18.1'))
{
showUpdateStep("Updating from 0.9.18.1 to 0.9.19");
@@ -1501,3 +1524,27 @@ if(isFroxlorVersion('0.9.19'))
updateToVersion('0.9.20-svn1');
}
if(isFroxlorVersion('0.9.19'))
{
showUpdateStep("Updating from 0.9.19 to 0.9.20");
// adding backup stuff
$db->query("ALTER TABLE `" . TABLE_PANEL_CUSTOMERS . "` ADD `backup_allowed` TINYINT( 1 ) NOT NULL DEFAULT '1'");
$db->query("ALTER TABLE `" . TABLE_PANEL_CUSTOMERS . "` ADD `backup_enabled` TINYINT( 1 ) NOT NULL DEFAULT '0'");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_enabled', '1')");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_dir', '#froxlor_backup')");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_mysqldump_path', '/usr/bin/mysqldump')");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_count', '1')");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_bigfile', '1')");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_enabled', '0')");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_server', '')");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_user', '')");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_pass', '')");
$db->query("INSERT INTO `" . TABLE_PANEL_CRONRUNS . "` (`module`, `cronfile`, `interval`, `isactive`, `desc_lng_key`) VALUES ('froxlor/backup', 'cron_backup.php', '1 Day', '1', 'cron_backup');");
lastStepStatus(0);
updateToVersion('0.9.20');
}

View File

@@ -243,6 +243,11 @@ return array(
array ('label' => $lng['panel']['yes'], 'value' => '1')
)
),
'backup_allowed' => array(
'label' => $lng['backup_allowed'].'?',
'type' => 'yesno',
'yesno_var' => $backup_allowed
),
'number_of_aps_packages' => array(
'label' => $lng['aps']['numberofapspackages'],
'type' => 'textul',

View File

@@ -252,6 +252,11 @@ return array(
),
'value' => array($result['perlenabled'])
),
'backup_allowed' => array(
'label' => $lng['backup_allowed'].'?',
'type' => 'yesno',
'yesno_var' => $backup_allowed
),
'number_of_aps_packages' => array(
'label' => $lng['aps']['numberofapspackages'],
'type' => 'textul',

View File

@@ -34,7 +34,8 @@ function inserttask($type, $param1 = '', $param2 = '', $param3 = '', $param4 = '
if($type == '1'
|| $type == '3'
|| $type == '4'
|| $type == '5')
|| $type == '5'
|| $type == '9')
{
$db->query('DELETE FROM `' . TABLE_PANEL_TASKS . '` WHERE `type`="' . $type . '"');
$db->query('INSERT INTO `' . TABLE_PANEL_TASKS . '` (`type`) VALUES ("' . $type . '")');

View File

@@ -129,6 +129,11 @@ return array (
'url' => 'customer_extras.php?page=htaccess',
'label' => $lng['menue']['extras']['pathoptions'],
),
array (
'url' => 'customer_extras.php?page=backup',
'label' => $lng['backup'],
'required_resources' => 'backup_allowed',
),
),
),
'traffic' => array (

View File

@@ -1603,3 +1603,20 @@ $lng['traffic']['months']['total'] = 'Total';
$lng['traffic']['details'] = 'Details';
$lng['menue']['traffic']['table'] = 'Traffic';
$lng['error']['admin_domain_emailsystemhostname'] = 'Sorry, the system - hostname may not be used as a customer domain';
$lng['backup'] = 'Backup';
$lng['backup_allowed'] = 'Backup allowed';
$lng['extras']['backup_create'] = 'Create Backup?';
$lng['extras']['backup_info'] = 'Backup will be saved once daily in directory "' . $settings['system']['backup_dir'] . '".';
$lng['extras']['backup_info_sep'] = 'It contains compressed archives of HTML Files and Databases.';
$lng['extras']['backup_info_big'] = 'It contains a compressed archive of HTML Files and Databases.';
$lng['extras']['backup_count_info'] = '<br /><br />Please note that the backup will charge your webspace!';
$lng['serversettings']['backup_count'] = 'Should backup size be subtracted from webspace size?';
$lng['serversettings']['backup_enabled'] = 'Backup activated?';
$lng['serversettings']['backupdir']['description'] = 'Which name should customers backup directory have?';
$lng['serversettings']['mysqldump_path']['description'] = 'Path to mysqldump command?';
$lng['serversettings']['backup_bigfile'] = 'Save backup in 1 big file instead in separeted files for html and databases?';
$lng['serversettings']['backup_ftp_enabled'] = 'FTP Upload activated?';
$lng['serversettings']['backup_ftp_server'] = 'FTP Server:';
$lng['serversettings']['backup_ftp_user'] = 'FTP Username:';
$lng['serversettings']['backup_ftp_pass'] = 'FTP Password:';
$lng['crondesc']['cron_backup'] = 'Backup cronjob';

View File

@@ -1583,3 +1583,20 @@ $lng['traffic']['months']['total'] = 'Gesamt';
$lng['traffic']['details'] = 'Details';
$lng['menue']['traffic']['table'] = '&Uuml;bersicht';
$lng['error']['admin_domain_emailsystemhostname'] = 'Der System - Hostname kann leider nicht als Kundendomain verwendet werden.';
$lng['backup'] = 'Backup';
$lng['backup_allowed'] = 'Backup erlaubt';
$lng['extras']['backup_create'] = 'Backup erstellen?';
$lng['extras']['backup_info'] = 'Das Backup wird einmal t&auml;glich im Ordner "' . $settings['system']['backup_dir'] . '" gespeichert.';
$lng['extras']['backup_info_sep'] = 'Es sind komprimierte Archive von HTML Dateien und Datenbanken enthalten.';
$lng['extras']['backup_info_big'] = 'Es ist ein komprimiertes Archiv von HTML Dateien und Datenbanken enthalten.';
$lng['extras']['backup_count_info'] = '<br /><br />Beachten Sie bitte, dass das Backup den verf&uuml;gbaren Speicherplatz belastet!';
$lng['serversettings']['backup_count'] = 'Soll die Gr&ouml;&amp;e des Backups vom verf&uuml;gbaren Webspace abgezogen werden?';
$lng['serversettings']['backup_enabled'] = 'Backup aktivieren?';
$lng['serversettings']['backup_ftp_enabled'] = 'FTP Upload aktivieren?';
$lng['serversettings']['backup_ftp_server'] = 'FTP Server:';
$lng['serversettings']['backup_ftp_user'] = 'FTP Benutzer:';
$lng['serversettings']['backup_ftp_pass'] = 'FTP Passwort:';
$lng['serversettings']['backupdir']['description'] = 'Welchen Namen soll das Backup Verzeichnis des Kunden haben?';
$lng['serversettings']['mysqldump_path']['description'] = 'Pfad zum mysqldump kommando?';
$lng['serversettings']['backup_count'] = 'Soll die Gr&ouml;&amp;e des Backups vom verf&uuml;gbaren Webspace abgezogen werden?';
$lng['crondesc']['cron_backup'] = 'Backup cronjob';

View File

@@ -0,0 +1,147 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Cron
* @version $Id: cron_backup.php 1 2010-09-15 13:19:45Z monotek $
*/
if(@php_sapi_name() != 'cli'){
die('This script will only work in the shell');
}
openRootDB($debugHandler, $lockfile);
/**
* Backup
*/
if($settings['system']['backup_enabled'] == '1'){
fwrite($debugHandler, 'backup customers started...' . "\n");
$result = $db->query("SELECT customerid, loginname, guid, documentroot, backup_allowed, backup_enabled FROM `" . TABLE_PANEL_CUSTOMERS . "` ORDER BY `customerid` ASC");
while($row = $db->fetch_array($result)){
fwrite($debugHandler, 'backup for ' . $row['loginname'] . ' started...' . "\n");
// create webserver backup directory access protection
$backupprotectfile = $settings['system']['apacheconf_diroptions'] . '50_froxlor_diroption_' . md5($row['documentroot'] . $settings['system']['backup_dir']) . '.conf';
$fh = fopen($backupprotectfile, 'w');
if($settings['system']['webserver'] == 'apache2'){
$filedata = '# ' . basename($backupprotectfile) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" .
'# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n\n" .
'<Directory "' . $row['documentroot'] . $settings['system']['backup_dir'] . '/">' . "\n" .
' deny from all' . "\n" .
'</Directory>' . "\n";
}
elseif($settings['system']['webserver'] == 'lighttpd'){
$filedata = '# ' . basename($backupprotectfile) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" .
'# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n\n" .
'$PHYSICAL["path"] !~ "^' . $row['documentroot'] . $settings['system']['backup_dir'] . '/$" {' . "\n" .
' access.deny-all = "enable"' . "\n" .
'}' . "\n";
}
elseif($settings['system']['webserver'] == 'nginx'){
$filedata = '# ' . basename($backupprotectfile) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" .
'# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n\n" .
'location ' . $row['documentroot'] . $settings['system']['backup_dir'] . ' {' . "\n" .
' deny all;' . "\n" .
' return 403;' . "\n" .
'}' . "\n";
}
fwrite($fh, $filedata);
fclose($fh);
//reload webserver to enable directory protection
safe_exec(escapeshellcmd($settings['system']['apachereload_command']));
// backup
if($row['backup_allowed'] == '1' && $row['backup_enabled'] == '1'){
// get uid & gid from ftp table
$ftp_result = $db->query("SELECT uid, gid FROM `" . TABLE_FTP_USERS . "` WHERE `username` = '" . $db->escape($row['loginname']) . "'");
$ftp_row = mysql_fetch_array($ftp_result);
// create backup dir an set rights
if(!file_exists($row['documentroot'] . $settings['system']['backup_dir'])){
safe_exec('install -d ' . escapeshellarg($row['documentroot']) . escapeshellarg($settings['system']['backup_dir']) . ' -o ' . escapeshellarg($ftp_row['uid']) . ' -g ' . escapeshellarg($ftp_row['gid']) . ' -m ' . '0500');
}
// create customers html backup
safe_exec('tar --exclude=' . escapeshellarg($settings['system']['backup_dir']) . ' -C ' . escapeshellarg($row['documentroot']) . ' -c -z -f ' . escapeshellarg($row['documentroot']) . escapeshellarg($settings['system']['backup_dir']) . '/' . escapeshellarg($row['loginname']) . 'html.tar.gz .');
// get customer dbs
$dbs_result = $db->query("SELECT databasename FROM `" . TABLE_PANEL_DATABASES . "` WHERE `customerid` = '" . $db->escape($row['customerid']) . "'");
while($dbs_row = $db->fetch_array($dbs_result)){
// create customers sql backup
safe_exec(escapeshellarg($settings['system']['backup_mysqldump_path']) . ' --opt --allow-keywords -u ' . $sql_root[0]['user'] . ' -p' . $sql_root[0]['password'] . ' -h ' . $sql_root[0]['host'] . ' ' . escapeshellarg($dbs_row['databasename']) . ' -r ' . escapeshellarg($row['documentroot']) . escapeshellarg($settings['system']['backup_dir']) . '/' . escapeshellarg($dbs_row['databasename']) . '.sql' );
// compress sql backup
safe_exec('tar -C ' . escapeshellarg($row['documentroot']) . escapeshellarg($settings['system']['backup_dir']) . ' -c -z -f ' . escapeshellarg($row['documentroot']) . escapeshellarg($settings['system']['backup_dir']) . '/' . escapeshellarg($dbs_row['databasename']) . '.tar.gz ' . escapeshellarg($dbs_row['databasename']) . '.sql');
// remove uncompresed sql files
safe_exec('rm ' . escapeshellarg($row['documentroot']) . escapeshellarg($settings['system']['backup_dir']) . '/' . escapeshellarg($dbs_row['databasename']) . '.sql');
}
// create 1 big file with html & db
if($settings['system']['backup_bigfile'] == 1){
safe_exec('tar -C ' . escapeshellarg($row['documentroot'] . $settings['system']['backup_dir']) . ' --exclude=' . escapeshellarg($row['loginname']) . '.tar.gz -c -z -f ' . escapeshellarg($row['documentroot'] . $settings['system']['backup_dir']) . '/' . escapeshellarg($row['loginname']) . '.tar.gz .');
// remove separated files
$tmp_files = scandir($row['documentroot'] . $settings['system']['backup_dir']);
foreach ($tmp_files as $tmp_file){
if(preg_match('/.*(html|sql|aps).*\.tar\.gz$/', $tmp_file) && !preg_match('/^' . $row['loginname'] . '\.tar\.gz$/', $tmp_file)){
safe_exec('rm ' . escapeshellarg($row['documentroot']) . escapeshellarg($settings['system']['backup_dir']) . '/' . $tmp_file . '');
}
}
}
// set correct user
if($settings['system']['mod_fcgid'] == 1){
$user = $row['loginname'];
$group = $row['loginname'];
}
else {
$user = $row['guid'];
$group = $row['guid'];
}
// chown & chmod files to prevent manipulation
safe_exec('chown ' . escapeshellarg($user) . ':' . escapeshellarg($group) . ' ' . escapeshellarg($row['documentroot']) . escapeshellarg($settings['system']['backup_dir']) . '/' . '*');
safe_exec('chmod 0400 ' . escapeshellarg($row['documentroot']) . escapeshellarg($settings['system']['backup_dir']) . '/*');
if($settings['system']['backup_ftp_enabled'] == '1'){
// upload backup to customers ftp server
$ftp_files = scandir($row['documentroot'] . $settings['system']['backup_dir']);
foreach ($ftp_files as $ftp_file){
if(preg_match('/.*\.tar\.gz$/', $ftp_file)){
$ftp_con = ftp_connect($settings['system']['backup_ftp_server']);
$ftp_login = ftp_login($ftp_con, $settings['system']['backup_ftp_user'], $settings['system']['backup_ftp_pass']);
ftp_pasv($ftp_con, true);
$ftp_upload = ftp_put($ftp_con, $ftp_file, $row['documentroot'] . $settings['system']['backup_dir'] . "/" . $ftp_file, FTP_BINARY);
}
}
}
fwrite($debugHandler, 'backup for ' . $row['loginname'] . ' finished...' . "\n");
}
// delete old backup data (deletes backup if customer or admin disables backup)
elseif($row['backup_allowed'] == '0' || $row['backup_enabled'] == '0'){
if (file_exists($row['documentroot'] . $settings['system']['backup_dir'] . '/')){
$files = scandir($row['documentroot'] . $settings['system']['backup_dir']);
foreach ($files as $file){
if(preg_match('/.*\.tar\.gz$/', $file)){
safe_exec('rm ' . escapeshellarg($row['documentroot']) . escapeshellarg($settings['system']['backup_dir']) . '/' . $file . '');
}
}
}
}
}
fwrite($debugHandler, 'backup customers finished...' . "\n");
}
?>

View File

@@ -403,6 +403,63 @@ while($row = $db->fetch_array($result_tasks))
}
}
}
/**
* TYPE=9 Create backup dir protection (no download of backups via webserver)
*/
elseif ($row['type'] == '9')
{
fwrite($debugHandler, ' cron_tasks: Task9 started - creating backup dir protection' . "\n");
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task9 started - creating backup dir protection');
$result = $db->query("SELECT documentroot, backup_allowed, backup_enabled FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE 1");
while($row = $db->fetch_array($result)){
if ($row['backup_allowed'] == '1' && $row['backup_enabled'] == '1'){
$backupprotectfile = $settings['system']['apacheconf_diroptions'] . '50_froxlor_diroption_' . md5($row['documentroot'] . $settings['system']['backup_dir']) . '.conf';
$fh = fopen($backupprotectfile, 'w');
if($settings['system']['webserver'] == 'apache2'){
$filedata = '# ' . basename($backupprotectfile) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" .
'# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n\n" .
'<Directory "' . $row['documentroot'] . $settings['system']['backup_dir'] . '/">' . "\n" .
' deny from all' . "\n" .
'</Directory>' . "\n";
}
elseif($settings['system']['webserver'] == 'lighttpd'){
$filedata = '# ' . basename($backupprotectfile) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" .
'# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n\n" .
'$PHYSICAL["path"] !~ "^' . $row['documentroot'] . $settings['system']['backup_dir'] . '/$" {' . "\n" .
' access.deny-all = "enable"' . "\n" .
'}' . "\n";
}
elseif($settings['system']['webserver'] == 'nginx'){
$filedata = '# ' . basename($backupprotectfile) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" .
'# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n\n" .
'location ' . $row['documentroot'] . $settings['system']['backup_dir'] . ' {' . "\n" .
' deny all;' . "\n" .
' return 403;' . "\n" .
'}' . "\n";
}
fwrite($fh, $filedata);
fclose($fh);
}
else{
// deletes backup if customer or admin disables backup because backup protection is not set
if (file_exists($row['documentroot'] . $settings['system']['backup_dir'] . '/')){
$files = scandir($row['documentroot'] . $settings['system']['backup_dir']);
foreach ($files as $file){
if(preg_match('/.*\.tar\.gz$/', $file)){
safe_exec('rm ' . escapeshellarg($row['documentroot']) . escapeshellarg($settings['system']['backup_dir']) . '/' . $file . '');
}
}
}
}
}
}
}
if($db->num_rows($result_tasks) != 0)

View File

@@ -365,6 +365,14 @@ while($row = $db->fetch_array($result))
*/
$diskusage = floatval($webspaceusage + $emailusage + $mysqlusage);
if($settings['system']['backup_count'] == 0 && file_exists($row['documentroot'] . $settings['system']['backup_dir'])){
$backupsize = exec('du -s ' . escapeshellarg($row['documentroot'] . $settings['system']['backup_dir']) . '');
$diskusage = floatval($webspaceusage + $emailusage + $mysqlusage - $backupsize);
}
else{
$diskusage = floatval($webspaceusage + $emailusage + $mysqlusage);
}
$db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `diskspace_used`='" . (float)$current_diskspace['all'] . "', `traffic_used`='" . (float)$sum_month_traffic['all'] . "' WHERE `customerid`='" . (int)$row['customerid'] . "'");
/**

View File

@@ -0,0 +1,26 @@
$header
<form method="post" action="$filename">
<input type="hidden" name="s" value="$s" />
<input type="hidden" name="page" value="$page" />
<input type="hidden" name="action" value="$action" />
<input type="hidden" name="id" value="$id" />
<table cellpadding="5" cellspacing="4" border="0" align="center" class="maintable_60">
<tr>
<td class="maintitle" colspan="2"><b><img src="images/title.gif" alt="" />&nbsp;{$lng['backup']}</b></td>
</tr>
<tr>
<td class="main_field_name">{$lng['extras']['backup_info']}
<if $settings['system']['backup_bigfile'] == 1 >{$lng['extras']['backup_info_big']}</if>
<if $settings['system']['backup_bigfile'] == 0 >{$lng['extras']['backup_info_sep']}</if>
<if $settings['system']['backup_count'] == 1 > {$lng['extras']['backup_count_info']} </if>:</td>
<td class="main_field_display" nowrap="nowrap">{$lng['extras']['backup_create']}&nbsp;$backup_enabled</td>
</tr>
<tr>
<td class="main_field_confirm" colspan="2"><input type="hidden" name="send" value="send" /><input type="submit" class="bottom" value="{$lng['panel']['save']}" /></td>
</tr>
</table>
</form>
<br />
<br />
$footer

View File

@@ -0,0 +1,26 @@
$header
<form method="post" action="$filename">
<input type="hidden" name="s" value="$s" />
<input type="hidden" name="page" value="$page" />
<input type="hidden" name="action" value="$action" />
<input type="hidden" name="id" value="$id" />
<table cellpadding="5" cellspacing="4" border="0" align="center" class="maintable_60">
<tr>
<td class="maintitle" colspan="2"><b><img src="images/title.gif" alt="" />&nbsp;{$lng['backup']}</b></td>
</tr>
<tr>
<td class="main_field_name">{$lng['extras']['backup_info']}
<if $settings['system']['backup_bigfile'] == 1 >{$lng['extras']['backup_info_big']}</if>
<if $settings['system']['backup_bigfile'] == 0 >{$lng['extras']['backup_info_sep']}</if>
<if $settings['system']['backup_count'] == 1 > {$lng['extras']['backup_count_info']} </if>:</td>
<td class="main_field_display" nowrap="nowrap">{$lng['extras']['backup_create']}&nbsp;$backup_enabled</td>
</tr>
<tr>
<td class="main_field_confirm" colspan="2"><input type="hidden" name="send" value="send" /><input type="submit" class="bottom" value="{$lng['panel']['save']}" /></td>
</tr>
</table>
</form>
<br />
<br />
$footer