示例#1
0
 /**
  * Implements Rollback functionality for Db
  *
  * @return bool
  */
 public function rollback()
 {
     set_time_limit(0);
     ignore_user_abort(true);
     $this->_lastOperationSucceed = false;
     $archiveManager = new Mage_Archive();
     $source = $archiveManager->unpack($this->getBackupPath(), $this->getBackupsDir());
     $file = new Mage_Backup_Filesystem_Iterator_File($source);
     foreach ($file as $statement) {
         $this->getResourceModel()->runCommand($statement);
     }
     @unlink($source);
     $this->_lastOperationSucceed = true;
     return true;
 }
 public function rollback()
 {
     set_time_limit(0);
     ignore_user_abort(true);
     $this->_lastOperationSucceed = false;
     $unsecureBaseUrl = Mage::getStoreConfig('web/unsecure/base_url');
     $secureBaseUrl = Mage::getStoreConfig('web/secure/base_url');
     $archiveManager = new Mage_Archive();
     $source = $archiveManager->unpack($this->getBackupPath(), $this->getBackupsDir());
     $file = new Mage_Backup_Filesystem_Iterator_File($source);
     foreach ($file as $statement) {
         $updateStatement = '';
         //if(strpos($statement, '`admin_assert`')){ continue; }
         //if(strpos($statement, '`admin_role`')){ continue; }
         //if(strpos($statement, '`admin_rule`')){ continue; }
         //if(strpos($statement, '`admin_user`')){ continue; }
         //if(strpos($statement, '`adminnotification_inbox`')){ continue; }
         //if(strpos($statement, '`api2_acl_attribute`')){ continue; }
         //if(strpos($statement, '`api2_acl_role`')){ continue; }
         //if(strpos($statement, '`api2_acl_rule`')){ continue; }
         //if(strpos($statement, '`api2_acl_user`')){ continue; }
         //if(strpos($statement, '`api_assert`')){ continue; }
         //if(strpos($statement, '`api_role`')){ continue; }
         //if(strpos($statement, '`api_rule`')){ continue; }
         //if(strpos($statement, '`api_session`')){ continue; }
         //if(strpos($statement, '`api_user`')){ continue; }
         if (strpos($statement, '`core_cache_option`')) {
             continue;
         }
         //if(strpos($statement, '`oauth_consumer`')){ continue; }
         //if(strpos($statement, '`oauth_nonce`')){ continue; }
         //if(strpos($statement, '`oauth_token`')){ continue; }
         if (strpos($statement, '`core_resource`')) {
             continue;
         }
         $this->getResourceModel()->runCommand($statement);
         if (strpos($statement, '`core_config_data`')) {
             if (strpos($statement, 'INSERT INTO `core_config_data`') === 0) {
                 $updateStatement = "UPDATE `core_config_data` set value = '{$unsecureBaseUrl}' where path = 'web/unsecure/base_url';";
                 $updateStatement .= "UPDATE `core_config_data` set value = '{$secureBaseUrl}' where path = 'web/secure/base_url';";
                 $this->getResourceModel()->runCommand($updateStatement);
             }
         }
     }
     @unlink($source);
     $this->_lastOperationSucceed = true;
     return true;
 }
示例#3
0
 /**
  * Files rollback implementation via local filesystem
  *
  * @see Mage_Backup_Filesystem_Rollback_Abstract::run()
  * @throws Mage_Exception
  */
 public function run()
 {
     $snapshotPath = $this->_snapshot->getBackupPath();
     if (!is_file($snapshotPath) || !is_readable($snapshotPath)) {
         throw new Mage_Backup_Exception_CantLoadSnapshot('Cant load snapshot archive');
     }
     $fsHelper = new Mage_Backup_Filesystem_Helper();
     $filesInfo = $fsHelper->getInfo($this->_snapshot->getRootDir(), Mage_Backup_Filesystem_Helper::INFO_WRITABLE, $this->_snapshot->getIgnorePaths());
     if (!$filesInfo['writable']) {
         throw new Mage_Backup_Exception_NotEnoughPermissions('Unable to make rollback because not all files are writable');
     }
     $archiver = new Mage_Archive();
     /**
      * we need these fake initializations because all magento's files in filesystem will be deleted and autoloader
      * wont be able to load classes that we need for unpacking
      */
     new Mage_Archive_Tar();
     new Mage_Archive_Gz();
     new Mage_Archive_Helper_File('');
     new Mage_Archive_Helper_File_Gz('');
     $fsHelper->rm($this->_snapshot->getRootDir(), $this->_snapshot->getIgnorePaths());
     $archiver->unpack($snapshotPath, $this->_snapshot->getRootDir());
 }
示例#4
0
 /**
  * Unpack snapshot
  *
  * @param string $tmpDir
  */
 protected function _unpackSnapshot($tmpDir)
 {
     $snapshotPath = $this->_snapshot->getBackupPath();
     $archiver = new Mage_Archive();
     $archiver->unpack($snapshotPath, $tmpDir);
 }
 public function processFullbackup()
 {
     $folders = $this->_collectBackupFolders();
     if (sizeof($folders) == 0) {
         echo 'No folders to backup<br />';
         return false;
     }
     $target_folder = $this->getBackupFolder();
     foreach ($folders as $folder) {
         $folder = new AitocSupportFolder($folder, $this->getRoot());
         $folder->backup($target_folder);
     }
     $this->_includeArchive();
     $target = $this->getArchiveFile('backup');
     if (file_exists($target)) {
         unlink($target);
     }
     $archive = new Mage_Archive();
     $target = $archive->pack($target_folder, $target, true);
     AitSystem::deleteDir($target_folder);
     $this->_outputFileToBrowser($target, true);
 }
示例#6
0
<?php

require_once 'magento-1.9.2.4/Archive.php';
require_once 'magento-1.9.2.4/Archive/Interface.php';
require_once 'magento-1.9.2.4/Archive/Abstract.php';
require_once 'magento-1.9.2.4/Archive/Gz.php';
require_once 'magento-1.9.2.4/Archive/Bz.php';
require_once 'magento-1.9.2.4/Archive/Tar.php';
require_once 'magento-1.9.2.4/Archive/Helper/File.php';
require_once 'magento-1.9.2.4/Archive/Helper/File/Gz.php';
require_once 'magento-1.9.2.4/Archive/Helper/File/Bz.php';
if (!defined('DS')) {
    define('DS', DIRECTORY_SEPARATOR);
}
if (count($argv) === 3) {
    list(, $dir, $file) = $argv;
    $archive = new Mage_Archive();
    $archive->pack($dir, $file, true);
} else {
    throw new Exception('Invalid number of arguments. Usage: php pack.php [directory to archive] [archive name]');
}