Example #1
0
function CommandLineBackup($filename)
{
    global $C, $DB;
    $filename = "{$GLOBALS['BASE_DIR']}/data/" . basename($filename);
    $tables = array();
    IniParse("{$GLOBALS['BASE_DIR']}/includes/tables.php", TRUE, $tables);
    if ($C['mysqldump']) {
        $command = "{$C['mysqldump']} " . "-u" . escapeshellarg($C['db_username']) . " " . "-p" . escapeshellarg($C['db_password']) . " " . "-h" . escapeshellarg($C['db_hostname']) . " " . "--opt " . escapeshellarg($C['db_name']) . " " . join(' ', array_keys($tables)) . " >" . escapeshellarg($filename) . " 2>&1";
        exec($command);
    } else {
        DoBackup($filename, $tables);
    }
    StoreValue('last_backup', time());
}
Example #2
0
function CommandLineBackup($filename)
{
    global $C, $DB;
    if (IsEmptyString($filename)) {
        trigger_error('A filename must be supplied', E_USER_ERROR);
    }
    $filename = "{$GLOBALS['BASE_DIR']}/data/" . basename($filename);
    $tables = array();
    IniParse("{$GLOBALS['BASE_DIR']}/includes/tables.php", TRUE, $tables);
    if (!$C['safe_mode'] && $C['mysqldump']) {
        $command = "{$C['mysqldump']} " . "-u" . escapeshellarg($C['db_username']) . " " . "-p" . escapeshellarg($C['db_password']) . " " . "-h" . escapeshellarg($C['db_hostname']) . " " . "--opt " . escapeshellarg($C['db_name']) . " " . join(' ', array_keys($tables)) . " >" . escapeshellarg($filename) . " 2>&1";
        shell_exec($command);
    } else {
        DoBackup($filename, $tables);
    }
    StoreValue('last_backup', MYSQL_NOW);
    @chmod($filename, 0666);
}
Example #3
0
        
        	}
        */
        /*	
        	$cprops = $props;
        	foreach (array_keys($groups) as $group) {
        	    $cprops['db_group'] = $group;
        	    $lg = new LOGGROUP($cprops);
        	    $zlg = new ZEUSLogGroup($lg);
        	    
        	    $cache = new CACHE($cprops, $zeus);
        	    $cache->Update();
        	}*/
    } catch (ADEIException $e) {
        $e->logInfo("Backup is failed", $reader ? $reader : $req);
        $error = $e->getInfo();
    }
    return $error ? $error : 0;
}
$req = new REQUEST($config);
$list = $req->GetSources();
foreach ($list as $sreq) {
    $opts =& $sreq->GetOptions();
    $backup = $opts->Get('backup');
    if ($backup) {
        $err = DoBackup($sreq, $backup);
        if ($err) {
            echo $sreq->GetLocationString() . ", Error: {$err}\n";
        }
    }
}
Example #4
0
function lxBackupDatabase()
{
    global $DB, $C;
    VerifyAdministrator();
    CheckAccessList();
    $filename = SafeFilename("{$GLOBALS['BASE_DIR']}/data/{$_REQUEST['filename']}", FALSE);
    $tables = array();
    IniParse("{$GLOBALS['BASE_DIR']}/includes/tables.php", TRUE, $tables);
    $GLOBALS['message'] = 'Database backup is in progress, allow a few minutes to complete before downloading the backup file';
    // Run mysqldump in the background
    if ($C['allow_exec'] && !empty($C['mysqldump'])) {
        $command = "{$C['mysqldump']} " . "-u" . escapeshellarg($C['db_username']) . " " . "-p" . escapeshellarg($C['db_password']) . " " . "-h" . escapeshellarg($C['db_hostname']) . " " . "--opt " . escapeshellarg($C['db_name']) . " " . join(' ', array_keys($tables)) . " >" . escapeshellarg($filename) . " 2>&1 &";
        exec($command);
    } else {
        if ($C['allow_exec'] && !empty($C['php_cli'])) {
            exec("{$C['php_cli']} cron.php --backup " . escapeshellarg($filename) . " >/dev/null 2>&1 &");
        } else {
            DoBackup($filename, $tables);
            $GLOBALS['message'] = 'Database backup has been completed';
        }
    }
    StoreValue('last_backup', time());
    lxShDatabaseTools();
}