Exemplo n.º 1
0
/* as published by the Free Software Foundation.							*/
/****************************************************************************/
// $Id$
define('AT_INCLUDE_PATH', '../../../include/');
require AT_INCLUDE_PATH . 'vitals.inc.php';
authenticate(AT_PRIV_ADMIN);
$_SESSION['done'] = 0;
require AT_INCLUDE_PATH . '../mods/_core/backups/classes/Backup.class.php';
$Backup = new Backup($db, $_SESSION['course_id']);
if (isset($_POST['cancel'])) {
    $msg->addFeedback('CANCELLED');
    header('Location: index.php');
    exit;
} else {
    if (isset($_POST['upload']) && $Backup->getNumAvailable() < AT_COURSE_BACKUPS) {
        $Backup->upload($_FILES, $_POST['description']);
        $_SESSION['done'] = 1;
        if ($msg->containsErrors()) {
            header('Location: upload.php');
            exit;
        } else {
            $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
            header('Location: index.php');
            exit;
        }
    }
}
require AT_INCLUDE_PATH . 'header.inc.php';
?>

Exemplo n.º 2
0
$project = 'DropboxBackup/1.0';
//optional, if you want to put backups in different folder
$projectFolder = '';
// location of your temp directory
$tmpDir = "/tmp/";
// username for MySQL
$user = "******";
// password for MySQL
$password = "******";
// database name to backup
$dbName = "dbname";
// hostname or IP where database resides
$dbHost = "localhost";
// the zip file will have this prefixed
$prefix = "bu_";
// Create the database backup file
$sqlFile = $tmpDir . $prefix . date('Y_m_d') . ".sql";
$backupFile = $prefix . date('Y_m_d') . ".tgz";
$createBackup = "mysqldump -h " . $dbHost . " -u " . $user . " --password='******' " . $dbName . " > " . $sqlFile;
$createZip = "tar cvzPf {$backupFile} {$sqlFile}";
exec($createBackup);
exec($createZip);
try {
    $bk = new Backup($token, $project, $projectFolder);
    $bk->upload($backupFile);
} catch (Exception $e) {
    die($e->getMessage());
}
// Delete the temporary files
@unlink($sqlFile);
@unlink($backupFile);