27 if (!$this->_objectManager->get(\
Magento\Backup\Helper\Data::class)->isRollbackAllowed()) {
35 $helper = $this->_objectManager->get(\
Magento\Backup\Helper\Data::class);
36 $response = new \Magento\Framework\DataObject();
40 $backup = $this->_backupModelFactory->create(
45 if (!$backup->getTime() || !$backup->exists()) {
49 if (!$backup->getTime()) {
50 throw new \Magento\Framework\Backup\Exception\CantLoadSnapshot(
__(
'Can\'t load snapshot archive'));
53 $type = $backup->getType();
55 $backupManager = $this->_backupFactory->create(
57 )->setBackupExtension(
70 $this->_coreRegistry->register(
'backup_manager', $backupManager);
72 $passwordValid = $this->_objectManager->create(
73 \
Magento\Backup\Model\Backup::class
74 )->validateUserPassword(
78 if (!$passwordValid) {
79 $response->setError(
__(
'Please correct the password.'));
80 $backupManager->setErrorMessage(
__(
'Please correct the password.'));
84 if ($this->
getRequest()->getParam(
'maintenance_mode')) {
85 if (!$this->maintenanceMode->set(
true)) {
88 'You need more permissions to activate maintenance mode right now.' 90 'To complete the rollback, please deselect ' 91 .
'"Put store into maintenance mode" or update your permissions.' 94 $backupManager->setErrorMessage(
95 __(
'Something went wrong while putting your store into maintenance mode.')
101 if (
$type != \
Magento\Framework\Backup\Factory::TYPE_DB) {
104 $backupManager->setRootDir(
$filesystem->getDirectoryRead(DirectoryList::ROOT)->getAbsolutePath())
105 ->addIgnorePaths(
$helper->getRollbackIgnorePaths());
107 if ($this->
getRequest()->getParam(
'use_ftp',
false)) {
108 $backupManager->setUseFtp(
109 $this->
getRequest()->getParam(
'ftp_host',
''),
110 $this->
getRequest()->getParam(
'ftp_user',
''),
111 $this->
getRequest()->getParam(
'ftp_pass',
''),
117 $backupManager->rollback();
122 $adminSession->destroy();
125 }
catch (\
Magento\Framework\Backup\Exception\CantLoadSnapshot $e) {
126 $errorMsg =
__(
'We can\'t find the backup file.');
127 }
catch (\
Magento\Framework\Backup\Exception\FtpConnectionFailed $e) {
128 $errorMsg =
__(
'We can\'t connect to the FTP right now.');
129 }
catch (\
Magento\Framework\Backup\Exception\FtpValidationFailed $e) {
130 $errorMsg =
__(
'Failed to validate FTP.');
131 }
catch (\
Magento\Framework\Backup\Exception\NotEnoughPermissions $e) {
132 $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->info($e->getMessage());
133 $errorMsg =
__(
'You need more permissions to perform a rollback.');
134 }
catch (\Exception $e) {
135 $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->info($e->getMessage());
136 $errorMsg =
__(
'Failed to rollback.');
139 if (!empty($errorMsg)) {
141 $backupManager->setErrorMessage($errorMsg);
144 if ($this->
getRequest()->getParam(
'maintenance_mode')) {
145 $this->maintenanceMode->set(
false);
_redirect($path, $arguments=[])
getUrl($route='', $params=[])
_forward($action, $controller=null, $module=null, array $params=null)