Um die Größe der Backups einer Domain im Interface anzuzeigen, sind nur ein paar minimale Änderungen erforderlich. Die geänderten Files sind hier als Download verfügbar.
In interface/web/sites/lib/lang/en_web_backup_list.lng eine Zeile einfügen:
$wb['filesize_txt'] = 'Filesize';
interface/web/sites/templates/web_backup_list.htm um zwei Zeilen erweitern:
<th class="tbl_col_filename" scope="col"><tmpl_var name="filename_txt"></th>
<th class="tbl_col_filename" scope="col"><tmpl_var name="filesize_txt"></th>
<th class="tbl_col_limit" scope="col">{tmpl_var name='search_limit'}</th>[...]
<td class="tbl_col_filename">{tmpl_var name="filename"}</td>
<td class="tbl_col_filesize">{tmpl_var name="filesize"}</td>
<td class="tbl_col_buttons">
/usr/local/ispconfig/server/cron_daily.php ergänzen (ab Zeile 741):
######################################################################
// 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)];
}
Zeile 806 ändern:
$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) . "')";
wird zu
$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)) . "')";
Zeile 932 wird von:
$sql = "INSERT INTO web_backup (server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (" . $conf['server_id'] . ",$web_id,'mysql','sqlgz',".time() . ",'" . $app->db->quote($db_backup_file) . ".gz')";
zu
$sql = "INSERT INTO web_backup (server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename,filesize) VALUES (" . $conf['server_id'] . ",$web_id,'mysql','sqlgz'," . time() . ",'" . $app->db->quote($db_backup_file) . ".gz','" . formatBytes(filesize($db_backup_dir . '/' . $db_backup_file)) . "')";
Zum Schluss muss nur noch die Tabelle web_backup in der Datenbank erweitert werden (bspw. mit phpMyAdmin).
ALTER TABLE `web_backup` ADD `filesize` VARCHAR(10) NOT NULL AFTER `filename`;
Is this Howto still up to date? Any plans to integrate that feature directly into ISPConfig (e.g. via feature request) or at least release it as a patch in order to be “update save”?
This is already integrated in the next ispconfig-release – but i changed from formatedBytes stored directly in the database to formatedBytes when displaying the data.
You can use ths howtto even with 3.0.5.4p5.
Thanks for the details. So, would you recommend waiting until the update or would it be enough to skip formatBytes(..) in the SQL script and simply move the function to interface/web/sites/templates/web_backup_list.htm in order to be “update save”?
… ah got it: http://git.ispconfig.org/ispconfig/ispconfig3/blob/master/interface/web/sites/backup_stats.php and formatBytes from http://git.ispconfig.org/ispconfig/ispconfig3/blob/master/interface/lib/classes/functions.inc.php, right?
OK, last question, as there isn’t any backup_stats.php: where would I insert the formatBytes(..) in 3.0.5.4p5 for formatting the string when displaying the data?
You can´t use the code for 3.1 with 3.0.5.4 – i think i have some time within this week to update the backport.
Pingback: Patches für ISPConfig 3.0.5.3 | florian @it
Pingback: My Homepage