Exemple #1
0
 /**
  * Files rollback implementation via ftp
  *
  * @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');
     }
     $this->_initFtpClient();
     $this->_validateFtp();
     $tmpDir = $this->_createTmpDir();
     $this->_unpackSnapshot($tmpDir);
     $fsHelper = new Mage_Backup_Filesystem_Helper();
     $this->_cleanupFtp();
     $this->_uploadBackupToFtp($tmpDir);
     $fsHelper->rm($tmpDir, array(), true);
 }
Exemple #2
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());
 }