From 209f8ae15c1b2fb02f38d6ed5f9df3b13292d1d9 Mon Sep 17 00:00:00 2001 From: tbrehm Date: Fri, 19 Apr 2013 09:43:31 +0000 Subject: [PATCH] Add web backup size in backup list. --- install/sql/incremental/upd_0049.sql | 3 +- install/sql/ispconfig3.sql | 13 +++---- .../web/sites/lib/lang/en_web_backup_list.lng | 21 ++++++------ .../web/sites/templates/web_backup_list.htm | 34 ++++++++++--------- server/cron_daily.php | 32 ++++++++++------- 5 files changed, 57 insertions(+), 46 deletions(-) diff --git a/install/sql/incremental/upd_0049.sql b/install/sql/incremental/upd_0049.sql index 55eff842e..d55f0dafa 100644 --- a/install/sql/incremental/upd_0049.sql +++ b/install/sql/incremental/upd_0049.sql @@ -1 +1,2 @@ -ALTER TABLE `client_template` CHANGE `limit_aps` `limit_aps` INT( 11 ) NOT NULL DEFAULT '-1'; \ No newline at end of file +ALTER TABLE `client_template` CHANGE `limit_aps` `limit_aps` INT( 11 ) NOT NULL DEFAULT '-1'; +ALTER TABLE `web_backup` ADD `filesize` VARCHAR(10) NOT NULL AFTER `filename`; diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql index a159ba67e..6eb264abb 100644 --- a/install/sql/ispconfig3.sql +++ b/install/sql/ispconfig3.sql @@ -1628,12 +1628,13 @@ CREATE TABLE `web_backup` ( `server_id` int(10) unsigned NOT NULL, `parent_domain_id` int(10) unsigned NOT NULL, `backup_type` enum('web','mysql') NOT NULL DEFAULT 'web', - `backup_mode` varchar(64) NOT NULL DEFAULT '', - `tstamp` int(10) unsigned NOT NULL, - `filename` varchar(255) NOT NULL, - PRIMARY KEY (`backup_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - + `backup_mode` varchar(64) NOT NULL DEFAULT '', + `tstamp` int(10) unsigned NOT NULL, + `filename` varchar(255) NOT NULL, + `filesize` VARCHAR(10) NOT NULL, + PRIMARY KEY (`backup_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + -- -------------------------------------------------------- -- diff --git a/interface/web/sites/lib/lang/en_web_backup_list.lng b/interface/web/sites/lib/lang/en_web_backup_list.lng index 74bcbd9b7..2b6594468 100644 --- a/interface/web/sites/lib/lang/en_web_backup_list.lng +++ b/interface/web/sites/lib/lang/en_web_backup_list.lng @@ -1,16 +1,17 @@ \ No newline at end of file +$wb['backup_type_mysql'] = 'MySQL Database'; +$wb['backup_type_web'] = 'Website files'; + +?> diff --git a/interface/web/sites/templates/web_backup_list.htm b/interface/web/sites/templates/web_backup_list.htm index 3248812e8..55944730b 100644 --- a/interface/web/sites/templates/web_backup_list.htm +++ b/interface/web/sites/templates/web_backup_list.htm @@ -13,21 +13,23 @@ - - - - - - + + + + + + + - - - - + + + + @@ -40,7 +42,7 @@
{tmpl_var name='search_limit'}
{tmpl_var name='search_limit'}
{tmpl_var name="date"}{tmpl_var name="backup_type"}{tmpl_var name="filename"} -
- +
{tmpl_var name="date"}{tmpl_var name="backup_type"}{tmpl_var name="filename"}{tmpl_var name="filesize"} +
+
- - - - \ No newline at end of file + + + + diff --git a/server/cron_daily.php b/server/cron_daily.php index 1bcb797ad..69c345f82 100644 --- a/server/cron_daily.php +++ b/server/cron_daily.php @@ -766,12 +766,17 @@ if ($app->dbmaster == $app->db) { } -####################################################################################################### -// Create website backups -####################################################################################################### - -$server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); -$backup_dir = $server_config['backup_dir']; +####################################################################################################### +// Create website backups +####################################################################################################### +function formatBytes($size, $precision = 2) { + $base=log($size)/log(1024); + $suffixes=array('','k','M','G','T'); + return round(pow(1024,$base-floor($base)),$precision).$suffixes[floor($base)]; +} + +$server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); +$backup_dir = $server_config['backup_dir']; $backup_mode = $server_config['backup_mode']; if($backup_mode == '') $backup_mode = 'userzip'; @@ -828,13 +833,14 @@ if($backup_dir != '') { chgrp($web_backup_dir.'/'.$web_backup_file, 'root'); chmod($web_backup_dir.'/'.$web_backup_file, 0750); - //* Insert web backup record in database - //$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)."')"; - //$app->dbmaster->datalogInsert('web_backup', $insert_data, 'backup_id'); - $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)."')"; - $app->db->query($sql); - if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql); - + //* Insert web backup record in database + //$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)."')"; + //$app->dbmaster->datalogInsert('web_backup', $insert_data, 'backup_id'); + + $sql = "INSERT INTO web_backup (server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename,filesize) VALUES (".$conf['server_id'].",".$web_id.",'web','".$backup_mode."',".time().",'".$app->db->quote($web_backup_file)."','".formatBytes(filesize($web_backup_dir.'/'.$web_backup_file))."')"; + $app->db->query($sql); + if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql); + //* Remove old backups $backup_copies = intval($rec['backup_copies']); -- GitLab