Skip to content

Commit 209f8ae

Browse files
committed
Add web backup size in backup list.
1 parent 3f478f7 commit 209f8ae

File tree

5 files changed

+57
-46
lines changed

5 files changed

+57
-46
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
ALTER TABLE `client_template` CHANGE `limit_aps` `limit_aps` INT( 11 ) NOT NULL DEFAULT '-1';
1+
ALTER TABLE `client_template` CHANGE `limit_aps` `limit_aps` INT( 11 ) NOT NULL DEFAULT '-1';
2+
ALTER TABLE `web_backup` ADD `filesize` VARCHAR(10) NOT NULL AFTER `filename`;

install/sql/ispconfig3.sql

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,12 +1628,13 @@ CREATE TABLE `web_backup` (
16281628
`server_id` int(10) unsigned NOT NULL,
16291629
`parent_domain_id` int(10) unsigned NOT NULL,
16301630
`backup_type` enum('web','mysql') NOT NULL DEFAULT 'web',
1631-
`backup_mode` varchar(64) NOT NULL DEFAULT '',
1632-
`tstamp` int(10) unsigned NOT NULL,
1633-
`filename` varchar(255) NOT NULL,
1634-
PRIMARY KEY (`backup_id`)
1635-
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
1636-
1631+
`backup_mode` varchar(64) NOT NULL DEFAULT '',
1632+
`tstamp` int(10) unsigned NOT NULL,
1633+
`filename` varchar(255) NOT NULL,
1634+
`filesize` VARCHAR(10) NOT NULL,
1635+
PRIMARY KEY (`backup_id`)
1636+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
1637+
16371638
-- --------------------------------------------------------
16381639

16391640
--
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<?php
22
$wb['list_head_txt'] = 'Existing backups';
3-
$wb['date_txt'] = 'Date';
4-
$wb['backup_type_txt'] = 'Type';
5-
$wb['filename_txt'] = 'Backup file';
6-
$wb['restore_backup_txt'] = 'Restore';
7-
$wb['download_backup_txt'] = 'Download';
8-
$wb['download_info_txt'] = 'The backup file will be available for download in the backup folder of the website in a few minutes.';
3+
$wb['date_txt'] = 'Date';
4+
$wb['backup_type_txt'] = 'Type';
5+
$wb['filename_txt'] = 'Backup file';
6+
$wb['filesize_txt'] = 'Filesize';
7+
$wb['restore_backup_txt'] = 'Restore';
8+
$wb['download_backup_txt'] = 'Download';
9+
$wb['download_info_txt'] = 'The backup file will be available for download in the backup folder of the website in a few minutes.';
910
$wb['restore_info_txt'] = 'Restore of the backup has been started. This action takes several minutes to be completed.';
1011
$wb['restore_confirm_txt'] = 'Restoring will overwrite existing files in your website. Do you really want to restore this backup?';
1112
$wb['download_pending_txt'] = 'There is already a pending backup download job.';
1213
$wb['restore_pending_txt'] = 'There is already a pending backup restore job.';
13-
$wb['backup_type_mysql'] = 'MySQL Database';
14-
$wb['backup_type_web'] = 'Website files';
15-
16-
?>
14+
$wb['backup_type_mysql'] = 'MySQL Database';
15+
$wb['backup_type_web'] = 'Website files';
16+
17+
?>

interface/web/sites/templates/web_backup_list.htm

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,23 @@ <h3><tmpl_var name="list_head_txt"></h3>
1313
<table class="list">
1414
<thead>
1515
<tr class="caption">
16-
<th class="tbl_col_date" scope="col"><tmpl_var name="date_txt"></th>
17-
<th class="tbl_col_date" scope="col"><tmpl_var name="backup_type_txt"></th>
18-
<th class="tbl_col_filename" scope="col"><tmpl_var name="filename_txt"></th>
19-
<th class="tbl_col_limit" scope="col">{tmpl_var name='search_limit'}</th>
20-
</tr>
21-
</thead>
16+
<th class="tbl_col_date" scope="col"><tmpl_var name="date_txt"></th>
17+
<th class="tbl_col_date" scope="col"><tmpl_var name="backup_type_txt"></th>
18+
<th class="tbl_col_filename" scope="col"><tmpl_var name="filename_txt"></th>
19+
<th class="tbl_col_filename" scope="col"><tmpl_var name="filesize_txt"></th>
20+
<th class="tbl_col_limit" scope="col">{tmpl_var name='search_limit'}</th>
21+
</tr>
22+
</thead>
2223
<tbody>
2324
<tmpl_loop name="records">
2425
<tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
25-
<td class="tbl_col_date">{tmpl_var name="date"}</td>
26-
<td class="tbl_col_date">{tmpl_var name="backup_type"}</td>
27-
<td class="tbl_col_filename">{tmpl_var name="filename"}</td>
28-
<td class="tbl_col_buttons">
29-
<div class="buttons">
30-
<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>
26+
<td class="tbl_col_date">{tmpl_var name="date"}</td>
27+
<td class="tbl_col_date">{tmpl_var name="backup_type"}</td>
28+
<td class="tbl_col_filename">{tmpl_var name="filename"}</td>
29+
<td class="tbl_col_filesize">{tmpl_var name="filesize"}</td>
30+
<td class="tbl_col_buttons">
31+
<div class="buttons">
32+
<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>
3133
<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>
3234
</div>
3335
</td>
@@ -40,7 +42,7 @@ <h3><tmpl_var name="list_head_txt"></h3>
4042
</tmpl_unless>
4143
</tbody>
4244
</table>
43-
</fieldset>
44-
</div>
45-
46-
</div>
45+
</fieldset>
46+
</div>
47+
48+
</div>

server/cron_daily.php

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -766,12 +766,17 @@ function setConfigVar( $filename, $varName, $varValue ) {
766766

767767
}
768768

769-
#######################################################################################################
770-
// Create website backups
771-
#######################################################################################################
772-
773-
$server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
774-
$backup_dir = $server_config['backup_dir'];
769+
#######################################################################################################
770+
// Create website backups
771+
#######################################################################################################
772+
function formatBytes($size, $precision = 2) {
773+
$base=log($size)/log(1024);
774+
$suffixes=array('','k','M','G','T');
775+
return round(pow(1024,$base-floor($base)),$precision).$suffixes[floor($base)];
776+
}
777+
778+
$server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
779+
$backup_dir = $server_config['backup_dir'];
775780
$backup_mode = $server_config['backup_mode'];
776781
if($backup_mode == '') $backup_mode = 'userzip';
777782

@@ -828,13 +833,14 @@ function setConfigVar( $filename, $varName, $varValue ) {
828833
chgrp($web_backup_dir.'/'.$web_backup_file, 'root');
829834
chmod($web_backup_dir.'/'.$web_backup_file, 0750);
830835

831-
//* Insert web backup record in database
832-
//$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)."')";
833-
//$app->dbmaster->datalogInsert('web_backup', $insert_data, 'backup_id');
834-
$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)."')";
835-
$app->db->query($sql);
836-
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
837-
836+
//* Insert web backup record in database
837+
//$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)."')";
838+
//$app->dbmaster->datalogInsert('web_backup', $insert_data, 'backup_id');
839+
840+
$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))."')";
841+
$app->db->query($sql);
842+
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
843+
838844
//* Remove old backups
839845
$backup_copies = intval($rec['backup_copies']);
840846

0 commit comments

Comments
 (0)