Commit 209f8ae1 authored by tbrehm's avatar tbrehm
Browse files

Add web backup size in backup list.

parent 3f478f7b
ALTER TABLE `client_template` CHANGE `limit_aps` `limit_aps` INT( 11 ) NOT NULL DEFAULT '-1'; ALTER TABLE `client_template` CHANGE `limit_aps` `limit_aps` INT( 11 ) NOT NULL DEFAULT '-1';
\ No newline at end of file ALTER TABLE `web_backup` ADD `filesize` VARCHAR(10) NOT NULL AFTER `filename`;
...@@ -1628,12 +1628,13 @@ CREATE TABLE `web_backup` ( ...@@ -1628,12 +1628,13 @@ CREATE TABLE `web_backup` (
`server_id` int(10) unsigned NOT NULL, `server_id` int(10) unsigned NOT NULL,
`parent_domain_id` int(10) unsigned NOT NULL, `parent_domain_id` int(10) unsigned NOT NULL,
`backup_type` enum('web','mysql') NOT NULL DEFAULT 'web', `backup_type` enum('web','mysql') NOT NULL DEFAULT 'web',
`backup_mode` varchar(64) NOT NULL DEFAULT '', `backup_mode` varchar(64) NOT NULL DEFAULT '',
`tstamp` int(10) unsigned NOT NULL, `tstamp` int(10) unsigned NOT NULL,
`filename` varchar(255) NOT NULL, `filename` varchar(255) NOT NULL,
PRIMARY KEY (`backup_id`) `filesize` VARCHAR(10) NOT NULL,
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; PRIMARY KEY (`backup_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
......
<?php <?php
$wb['list_head_txt'] = 'Existing backups'; $wb['list_head_txt'] = 'Existing backups';
$wb['date_txt'] = 'Date'; $wb['date_txt'] = 'Date';
$wb['backup_type_txt'] = 'Type'; $wb['backup_type_txt'] = 'Type';
$wb['filename_txt'] = 'Backup file'; $wb['filename_txt'] = 'Backup file';
$wb['restore_backup_txt'] = 'Restore'; $wb['filesize_txt'] = 'Filesize';
$wb['download_backup_txt'] = 'Download'; $wb['restore_backup_txt'] = 'Restore';
$wb['download_info_txt'] = 'The backup file will be available for download in the backup folder of the website in a few minutes.'; $wb['download_backup_txt'] = 'Download';
$wb['download_info_txt'] = 'The backup file will be available for download in the backup folder of the website in a few minutes.';
$wb['restore_info_txt'] = 'Restore of the backup has been started. This action takes several minutes to be completed.'; $wb['restore_info_txt'] = 'Restore of the backup has been started. This action takes several minutes to be completed.';
$wb['restore_confirm_txt'] = 'Restoring will overwrite existing files in your website. Do you really want to restore this backup?'; $wb['restore_confirm_txt'] = 'Restoring will overwrite existing files in your website. Do you really want to restore this backup?';
$wb['download_pending_txt'] = 'There is already a pending backup download job.'; $wb['download_pending_txt'] = 'There is already a pending backup download job.';
$wb['restore_pending_txt'] = 'There is already a pending backup restore job.'; $wb['restore_pending_txt'] = 'There is already a pending backup restore job.';
$wb['backup_type_mysql'] = 'MySQL Database'; $wb['backup_type_mysql'] = 'MySQL Database';
$wb['backup_type_web'] = 'Website files'; $wb['backup_type_web'] = 'Website files';
?> ?>
\ No newline at end of file
...@@ -13,21 +13,23 @@ ...@@ -13,21 +13,23 @@
<table class="list"> <table class="list">
<thead> <thead>
<tr class="caption"> <tr class="caption">
<th class="tbl_col_date" scope="col"><tmpl_var name="date_txt"></th> <th class="tbl_col_date" scope="col"><tmpl_var name="date_txt"></th>
<th class="tbl_col_date" scope="col"><tmpl_var name="backup_type_txt"></th> <th class="tbl_col_date" scope="col"><tmpl_var name="backup_type_txt"></th>
<th class="tbl_col_filename" scope="col"><tmpl_var name="filename_txt"></th> <th class="tbl_col_filename" scope="col"><tmpl_var name="filename_txt"></th>
<th class="tbl_col_limit" scope="col">{tmpl_var name='search_limit'}</th> <th class="tbl_col_filename" scope="col"><tmpl_var name="filesize_txt"></th>
</tr> <th class="tbl_col_limit" scope="col">{tmpl_var name='search_limit'}</th>
</thead> </tr>
</thead>
<tbody> <tbody>
<tmpl_loop name="records"> <tmpl_loop name="records">
<tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>"> <tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
<td class="tbl_col_date">{tmpl_var name="date"}</td> <td class="tbl_col_date">{tmpl_var name="date"}</td>
<td class="tbl_col_date">{tmpl_var name="backup_type"}</td> <td class="tbl_col_date">{tmpl_var name="backup_type"}</td>
<td class="tbl_col_filename">{tmpl_var name="filename"}</td> <td class="tbl_col_filename">{tmpl_var name="filename"}</td>
<td class="tbl_col_buttons"> <td class="tbl_col_filesize">{tmpl_var name="filesize"}</td>
<div class="buttons"> <td class="tbl_col_buttons">
<button class="button iconstxt icoRestore" type="button" onclick="confirm_action('sites/web_domain_edit.php?id={tmpl_var name='parent_id'}&next_tab=backup&backup_action=restore&backup_id={tmpl_var name='backup_id'}','{tmpl_var name='restore_confirm_txt'}');"><span>{tmpl_var name="restore_backup_txt"}</span></button> <div class="buttons">
<button class="button iconstxt icoRestore" type="button" onclick="confirm_action('sites/web_domain_edit.php?id={tmpl_var name='parent_id'}&next_tab=backup&backup_action=restore&backup_id={tmpl_var name='backup_id'}','{tmpl_var name='restore_confirm_txt'}');"><span>{tmpl_var name="restore_backup_txt"}</span></button>
<button class="button iconstxt icoDownload" type="button" onclick="loadContent('sites/web_domain_edit.php?id={tmpl_var name='parent_id'}&next_tab=backup&backup_action=download&backup_id={tmpl_var name='backup_id'}');"><span>{tmpl_var name="download_backup_txt"}</span></button> <button class="button iconstxt icoDownload" type="button" onclick="loadContent('sites/web_domain_edit.php?id={tmpl_var name='parent_id'}&next_tab=backup&backup_action=download&backup_id={tmpl_var name='backup_id'}');"><span>{tmpl_var name="download_backup_txt"}</span></button>
</div> </div>
</td> </td>
...@@ -40,7 +42,7 @@ ...@@ -40,7 +42,7 @@
</tmpl_unless> </tmpl_unless>
</tbody> </tbody>
</table> </table>
</fieldset> </fieldset>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -766,12 +766,17 @@ if ($app->dbmaster == $app->db) { ...@@ -766,12 +766,17 @@ if ($app->dbmaster == $app->db) {
} }
####################################################################################################### #######################################################################################################
// Create website backups // Create website backups
####################################################################################################### #######################################################################################################
function formatBytes($size, $precision = 2) {
$server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); $base=log($size)/log(1024);
$backup_dir = $server_config['backup_dir']; $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']; $backup_mode = $server_config['backup_mode'];
if($backup_mode == '') $backup_mode = 'userzip'; if($backup_mode == '') $backup_mode = 'userzip';
...@@ -828,13 +833,14 @@ if($backup_dir != '') { ...@@ -828,13 +833,14 @@ if($backup_dir != '') {
chgrp($web_backup_dir.'/'.$web_backup_file, 'root'); chgrp($web_backup_dir.'/'.$web_backup_file, 'root');
chmod($web_backup_dir.'/'.$web_backup_file, 0750); chmod($web_backup_dir.'/'.$web_backup_file, 0750);
//* Insert web backup record in database //* 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)."')"; //$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'); //$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); $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))."')";
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql); $app->db->query($sql);
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
//* Remove old backups //* Remove old backups
$backup_copies = intval($rec['backup_copies']); $backup_copies = intval($rec['backup_copies']);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment