Add backup size to web backups

Discussion in 'Developers' Forum' started by florian030, Apr 12, 2013.

  1. florian030

    florian030 Well-Known Member HowtoForge Supporter

    I made some changes to display the size of each web-backup in the interface.

    The modified files are available for download here. I`ll send my patch to Till next week so it might be available in the SVN.

    Add one line to interface/web/sites/lib/lang/en_web_backup_list.lng:
    Code:
    $wb['filesize_txt'] = 'Filesize';
    Extend interface/web/sites/templates/web_backup_list.htm by two lines:
    Code:
    <th class="tbl_col_filename" scope="col"><tmpl_var name="filename_txt"></th>
    [B]<th class="tbl_col_filename" scope="col"><tmpl_var name="filesize_txt"></th>[/B]
    <th class="tbl_col_limit" scope="col">{tmpl_var name='search_limit'}</th>
    
    [...]
    
    <td class="tbl_col_filename">{tmpl_var name="filename"}</td>
    [B]<td class="tbl_col_filesize">{tmpl_var name="filesize"}</td>[/B]
    <td class="tbl_col_buttons">
    Make some changes to /usr/local/ispconfig/server/cron_daily.php (line 741):

    Code:
    ######################################################################
    // Create website backups
    ######################################################################
    [B]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)];
    }[/B]
    And change line 806:
    Code:
    $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)."')";
    to
    Code:
    $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)) . "')";
    Finally in the database the table web_backup must be expanded (i.e. with phpMyAdmin).
    Code:
    ALTER TABLE `web_backup` ADD `filesize` VARCHAR(10) NOT NULL AFTER `filename;`
     
  2. florian030

    florian030 Well-Known Member HowtoForge Supporter

    change line 932 from:
    Code:
    $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')";
    to

    Code:
    $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))."')";
    
     
    Last edited: Apr 17, 2013

Share This Page