/** * Roll back database * * @param string $rollbackFile * @return void * @throws LocalizedException */ public function dbRollback($rollbackFile) { if (preg_match('/[0-9]_(db)(.*?).(sql)$/', $rollbackFile) !== 1) { throw new LocalizedException(new Phrase('Invalid rollback file.')); } if (!$this->file->isExists($this->backupsDir . '/' . $rollbackFile)) { throw new LocalizedException(new Phrase('The rollback file does not exist.')); } /** @var \Magento\Framework\Backup\Db $dbRollback */ $dbRollback = $this->objectManager->create('Magento\\Framework\\Backup\\Db'); $dbRollback->setRootDir($this->directoryList->getRoot()); $dbRollback->setBackupsDir($this->backupsDir); $dbRollback->setBackupExtension('sql'); $time = explode('_', $rollbackFile); if (count($time) === 3) { $thirdPart = explode('.', $time[2]); $dbRollback->setName($thirdPart[0]); } $dbRollback->setTime($time[0]); $this->log->log('DB rollback is starting...'); $dbRollback->setResourceModel($this->objectManager->create('Magento\\Backup\\Model\\ResourceModel\\Db')); $dbRollback->rollback(); $this->log->log('DB rollback filename: ' . $dbRollback->getBackupFilename()); $this->log->log('DB rollback path: ' . $dbRollback->getBackupPath()); $this->log->logSuccess('DB rollback completed successfully.'); }
/** * Uninstall Magento application * * @return void */ public function uninstall() { $this->log->log('Starting Magento uninstallation:'); $this->cleanCaches(); $this->cleanupDb(); $this->log->log('File system cleanup:'); $messages = $this->cleanupFiles->clearAllFiles(); foreach ($messages as $message) { $this->log->log($message); } $this->deleteDeploymentConfig(); $this->log->logSuccess('Magento uninstallation complete.'); }
/** * Uninstall Magento application * * @return void */ public function uninstall() { $this->log->log('Starting Magento uninstallation:'); try { $this->cleanCaches(); } catch (\Exception $e) { $this->log->log('Can\'t clear cache due to the following error: ' . $e->getMessage() . PHP_EOL . 'To fully clean up your uninstallation, you must manually clear your cache.'); } $this->cleanupDb(); $this->log->log('File system cleanup:'); $messages = $this->cleanupFiles->clearAllFiles(); foreach ($messages as $message) { $this->log->log($message); } $this->deleteDeploymentConfig(); $this->log->logSuccess('Magento uninstallation complete.'); }