Exemple #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 \Magento\Framework\Archive();
     $source = $archiveManager->unpack($this->getBackupPath(), $this->getBackupsDir());
     $file = new \Magento\Framework\Backup\Filesystem\Iterator\File($source);
     foreach ($file as $statement) {
         $this->getResourceModel()->runCommand($statement);
     }
     @unlink($source);
     $this->_lastOperationSucceed = true;
     return true;
 }
Exemple #2
0
 /**
  * Files rollback implementation via local filesystem
  *
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  *
  * @see AbstractRollback::run()
  */
 public function run()
 {
     $snapshotPath = $this->_snapshot->getBackupPath();
     if (!is_file($snapshotPath) || !is_readable($snapshotPath)) {
         throw new \Magento\Framework\Backup\Exception\CantLoadSnapshot(new \Magento\Framework\Phrase('Can\'t load snapshot archive'));
     }
     $fsHelper = new \Magento\Framework\Backup\Filesystem\Helper();
     $filesInfo = $fsHelper->getInfo($this->_snapshot->getRootDir(), \Magento\Framework\Backup\Filesystem\Helper::INFO_WRITABLE, $this->_snapshot->getIgnorePaths());
     if (!$filesInfo['writable']) {
         throw new \Magento\Framework\Backup\Exception\NotEnoughPermissions(new \Magento\Framework\Phrase('Unable to make rollback because not all files are writable'));
     }
     $archiver = new \Magento\Framework\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 \Magento\Framework\Archive\Tar();
     new \Magento\Framework\Archive\Gz();
     new \Magento\Framework\Archive\Helper\File('');
     new \Magento\Framework\Archive\Helper\File\Gz('');
     $fsHelper->rm($this->_snapshot->getRootDir(), $this->_snapshot->getIgnorePaths());
     $archiver->unpack($snapshotPath, $this->_snapshot->getRootDir());
 }
Exemple #3
0
    /**
     * Unpack snapshot
     *
     * @param string $tmpDir
     * @return void
     */
    protected function _unpackSnapshot($tmpDir)
    {
        $snapshotPath = $this->_snapshot->getBackupPath();

        $archiver = new \Magento\Framework\Archive();
        $archiver->unpack($snapshotPath, $tmpDir);
    }