Marius Cramer
2013-10-14 d9bcf68e395d6156645a7974b1a992aa6e6c00aa
server/cron_daily.php
@@ -33,6 +33,7 @@
require(SCRIPT_PATH."/lib/app.inc.php");
set_time_limit(0);
ini_set('error_reporting', E_ALL & ~E_NOTICE);
// make sure server_id is always an int
$conf['server_id'] = intval($conf['server_id']);
@@ -1134,7 +1135,7 @@
               $web_backup_file = 'web'.$web_id.'_'.date('Y-m-d_H-i').'.tar.gz';
               exec('tar pczf '.escapeshellarg($web_backup_dir.'/'.$web_backup_file).' --exclude=backup\* --directory '.escapeshellarg($web_path).' .', $tmp_output, $retval);
            }
            if($retval == 0){
            if($retval == 0 || $backup_mode != 'userzip'){ // tar can return 1 (due to harmless warings) and still create valid backups
               chown($web_backup_dir.'/'.$web_backup_file, 'root');
               chgrp($web_backup_dir.'/'.$web_backup_file, 'root');
               chmod($web_backup_dir.'/'.$web_backup_file, 0750);
@@ -1193,7 +1194,6 @@
            }
            
            $app->system->web_folder_protection($web_path,true);
         }
         /* If backup_interval is set to none and we have a
@@ -1231,7 +1231,8 @@
            $db_id = $rec['database_id'];
            $db_name = $rec['database_name'];
            $db_backup_file = 'db_'.$db_name.'_'.date('Y-m-d_H-i').'.sql';
            $command = "mysqldump -h '".escapeshellcmd($clientdb_host)."' -u '".escapeshellcmd($clientdb_user)."' -p'".escapeshellcmd($clientdb_password)."' -c --add-drop-table --create-options --quick --result-file='".$db_backup_dir.'/'.$db_backup_file."' '".$db_name."'";
            //$command = "mysqldump -h '".escapeshellcmd($clientdb_host)."' -u '".escapeshellcmd($clientdb_user)."' -p'".escapeshellcmd($clientdb_password)."' -c --add-drop-table --create-options --quick --result-file='".$db_backup_dir.'/'.$db_backup_file."' '".$db_name."'";
            $command = "mysqldump -h ".escapeshellarg($clientdb_host)." -u ".escapeshellarg($clientdb_user)." -p".escapeshellarg($clientdb_password)." -c --add-drop-table --create-options --quick --result-file='".$db_backup_dir.'/'.$db_backup_file."' '".$db_name."'";
            exec($command, $tmp_output, $retval);
            //* Compress the backup with gzip
@@ -1294,6 +1295,19 @@
      unset($clientdb_password);
   }
   // remove non-existing backups from database
   $backups = $app->db->queryAllRecords("SELECT * FROM web_backup WHERE server_id = ".$conf['server_id']);
   if(is_array($backups) && !empty($backups)){
      foreach($backups as $backup){
         $backup_file = $backup_dir.'/web'.$backup['parent_domain_id'].'/'.$backup['filename'];
         if(!is_file($backup_file)){
            $sql = "DELETE FROM web_backup WHERE server_id = ".$conf['server_id']." AND parent_domain_id = ".$backup['parent_domain_id']." AND filename = '".$backup['filename']."'";
            $app->db->query($sql);
            if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
         }
      }
   }
}