Ejemplo n.º 1
0
 public function backup()
 {
     if ($this->isLocalBackupEnabled() || $this->isFTPBackupEnabled()) {
         $sourceConfig = DatabaseConfig::getInstanceFromConfigFile();
         $source = new MysqlSource($sourceConfig);
         $fileDest = new File($sourceConfig);
         $dbBackup = new DatabaseBackup($source, $fileDest);
         $dbBackup->backup();
         $this->location->limitBackup();
         $this->zip->addFile($fileDest->getFilePath(), false);
         foreach ($this->folderList as $folder) {
             $path = $this->getFolderPath($folder);
             $folder = $this->addTrailingSlash($folder);
             $this->zip->addDirectory($path, $folder);
         }
         $this->zip->close();
         $this->location->save($this->getBackupFileName());
         if (file_exists($fileDest->getFilePath())) {
             //unlink($fileDest->getFilePath());
         }
     }
 }
Ejemplo n.º 2
0
$source = new MysqlSource($sourceConfig);
if (strtolower($mode) == 'dump') {
    header('Content-type: text/plain; charset=UTF-8');
    $responseDest = new Response($sourceConfig, true);
    $dbBackup = new DatabaseBackup($source, $responseDest);
    $dbBackup->backup();
} else {
    $targetName = $_REQUEST['newDatabaseName'];
    try {
        if (!empty($targetName) && $dbName != $targetName) {
            $rootUserName = $_SESSION['migration_info']['root_username'];
            $rootPassword = $_SESSION['migration_info']['root_password'];
            $destConfig = new DatabaseConfig($hostName, $username, $password, $targetName, 'mysql', $rootUserName, $rootPassword);
            $databaseDest = new Database($destConfig, $createDB, true);
            $dbBackup = new DatabaseBackup($source, $databaseDest);
            $dbBackup->backup();
            $_SESSION['migration_info']['new_dbname'] = $targetName;
            if ($createDB && $databaseDest->isUTF8SupportEnabled()) {
                $_SESSION['config_file_info']['vt_charset'] = "UTF-8";
            } else {
                $_SESSION['config_file_info']['vt_charset'] = "ISO-8859-1";
            }
            echo 'true';
            return;
        }
        echo 'false';
    } catch (DatabaseBackupException $e) {
        echo 'false';
    } catch (Exception $e) {
        echo 'false';
    }
$createDB = $_REQUEST['createDB'];
if (empty($createDB)) {
    $createDB = false;
} else {
    $createDB = true;
}
$backup = new DatabaseBackup($dbconfig['db_type'], $createDB);
$hostName = $dbconfig['db_server'] . $dbconfig['db_port'];
$username = $dbconfig['db_username'];
$password = $dbconfig['db_password'];
$dbName = $dbconfig['db_name'];
$backup->setSourceConfig(new DatabaseConfig($hostName, $username, $password, $dbName));
if (strtolower($mode) == 'dump') {
    header('Content-type: text/plain; charset=UTF-8');
    $backup->enableDownloadMode();
    $backup->backup();
} else {
    $targetName = $_REQUEST['newDatabaseName'];
    try {
        if (!empty($targetName) && $dbName != $targetName) {
            $rootUserName = $_SESSION['migration_info']['root_username'];
            $rootPassword = $_SESSION['migration_info']['root_password'];
            $backup->setDestinationConfig(new DatabaseConfig($hostName, $username, $password, $targetName, $rootUserName, $rootPassword));
            $backup->backup();
            $_SESSION['migration_info']['new_dbname'] = $targetName;
            if ($createDB && $backup->isUTF8SupportEnabled()) {
                $_SESSION['migration_info']['db_utf8_support'] = true;
            }
            echo 'true';
            return;
        }