Beispiel #1
0
/**
 * Dump the database and save
 */
function dbsc_makeBackup()
{
    ob_start();
    dbsc_mysqldump();
    $sql = ob_get_clean();
    $tempdir = realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'backups';
    if (!file_exists($tempdir)) {
        mkdir($tempdir);
    }
    $filename = $tempdir . DIRECTORY_SEPARATOR . 'db' . date('Ymd.His') . '.sql.gz';
    file_put_contents($filename, gzencode($sql));
    return $filename;
}
Beispiel #2
0
function dbsc_pull()
{
    //dump DB and GZip it
    header('Content-type: application/octet-stream');
    if (isset($_GET['dump'])) {
        if ($_GET['dump'] == 'manual') {
            //manual dump, so include attachment headers
            header('Content-Description: File Transfer');
            header('Content-Disposition: attachment; filename=data.sql');
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate');
            header('Pragma: public');
        }
    }
    dbsc_mysqldump();
    exit;
}