Esempio n. 1
0
$db = new db();
// check and set timeZone to avoid PHP errors
$q = $db->q("SELECT timeZone FROM settings");
$result = mysql_fetch_assoc($q);
$timeZone = $result['timeZone'];
date_default_timezone_set($timeZone);
$today = date("Ymd");
// get each dir in /home/rconfig except, backups, tmp, . and ..
$dirsToBackup = array_diff(scandir($config_app_basedir), array('..', '.', 'backups', 'tmp'));
// then zip each folder to a zip file in the tmp dir
foreach ($dirsToBackup as $k => $v) {
    /**
     * Then create dir backup and ZIP it
     */
    $backupFile = $config_temp_dir . 'backup-' . $v . '-' . $today . '.zip';
    folderBackup('/home/rconfig/' . $v, $backupFile);
}
/**
 *  create SQL backup 
 */
//  backup MySQL DB - vars from ../../../config/config.inc.php
$sqlBackupFile = sqlBackup(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME, $config_temp_dir);
/**
 * Then Zip all  zip files into one
 */
$fullBackupFile = $config_backup_basedir . 'fullBackup-' . $today . '.zip';
/**
 * create array of filenames in /home/tmp dir
 */
$dirhandler = opendir($config_temp_dir);
$nofiles = 0;
Esempio n. 2
0
<?php

include "../../../config/config.inc.php";
include "../../../config/functions.inc.php";
include "../../../classes/db.class.php";
$db = new db();
// check and set timeZone to avoid PHP errors
$q = $db->q("SELECT timeZone FROM settings");
$result = mysql_fetch_assoc($q);
$timeZone = $result['timeZone'];
date_default_timezone_set($timeZone);
$today = date("Ymd");
/**
 * Create Logs backup and ZIP it to tmp dir
 */
$backupFile = $config_syslogBackup_basedir . 'syslogbackup-' . $today . '.zip';
touch($backupFile);
folderBackup($config_log_basedir, $backupFile);
if (file_exists($backupFile)) {
    $response = json_encode(array('success' => true));
} else {
    $response = json_encode(array('failure' => true));
}
echo $response;