Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAGECLOUD-1372: Backup Critical Configuration Files to Recover On-Demand #115

Merged
merged 10 commits into from
Dec 11, 2017
Merged

MAGECLOUD-1372: Backup Critical Configuration Files to Recover On-Demand #115

merged 10 commits into from
Dec 11, 2017

Conversation

BaDos
Copy link
Contributor

@BaDos BaDos commented Dec 8, 2017

Description

After each redeploy will be created backup of configuration files: app/etc/config.php.bak app/etc/env.php.bak

If user removed or broke these files he can restore them using the next command:
./vendor/bin/ece-tools backup:restore

Also user can see available backup files using ./vendor/bin/ece-tools backup:list

Fixed Issues (if relevant)

https://magento2.atlassian.net/browse/MAGECLOUD-1372

Zephyr Tests

https://jira.corp.magento.com/browse/MAGETWO-85289

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • Pull request was approved by architect
  • Pull request was approved by QA member
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Tanks.

*/
protected function execute(InputInterface $input, OutputInterface $output)
{

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


try {
$output->writeln('<comment>The list of backup files:</comment>');
$output->writeln(array_keys($this->backupFilesList->getList()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you should check if file is backup file really exists?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe...

*
* @see \Magento\MagentoCloud\Filesystem\BackupList contains the list of files for restoring
*/
class Restorer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to Restore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

$backupList = $this->backupList->getList();

if ($specificPath) {
if (empty($backupList[$specificPath])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this check to restore() method

Copy link
Contributor Author

@BaDos BaDos Dec 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this we need this check only if a user wants to restore specific file.

/**
* CLI command for restoring Magento configuration files from backup.
*/
class BackupRestore extends Command
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to ../Command/Backup/Restore namespace

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

*
* @param InputInterface $input
* @param OutputInterface $output
* @param string $alias
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Describe what does alias mean

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and better to change the order of arguments. I see that $alias may be not required when you cannot implement method without $file (file name)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* @param OutputInterface $output
* @param string $alias
* @param string $file
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add @return void

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is @return in my locale code :)

} catch (\Exception $exception) {
$this->logger->critical($exception->getMessage());

throw $exception;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the declaration this method should return only LogicException and only when this abstract method is not implemented

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So... we need to fix all our CLI commands...

protected function configure()
{
$this->setName(self::NAME)
->setDescription('Restore important configuration files');
Copy link
Contributor

@NadiyaS NadiyaS Dec 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where may the user take info about which exactly important file will be restored?
As I see this command may be run without name of file, so all files will be restored, so it is important to make user know about what he is doing.
At least you need to forward the user to the command which can provide this information

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

/**
* Command name
*/
const NAME = 'backup:list';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see backup:list and backup:restore. Where is the command which creates these backups?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a process that creates backups after deploy.

@@ -153,6 +153,10 @@ function () use ($root, $config) {
$this->container->make(DeployProcess\CompressStaticContent::class),
$this->container->make(DeployProcess\DisableGoogleAnalytics::class),
$this->container->make(DeployProcess\UnlockCronJobs::class),
/**
* Remove this line after implementation post-deploy hook
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then maybe add todo. And add this point to the ticket with post-deploy or even additional task is better

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will create additional task

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try {
$output->writeln('<comment>The list of backup files:</comment>');
$output->writeln($this->backupFilesList->get() ?: 'There are no files in the backup');
return 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use constants, or don't return anything.

return 0;
} catch (\Exception $exception) {
$this->logger->critical($exception->getMessage());
return 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use constant or throw an exception.

. ' with option --force rewrite your existed files. Do you want to continue [y/N]?',
false
);
$restore = $helper->ask($input, $output, $question);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this into try-catch, ask can throw an exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, fixed

if ($restore) {
$this->restore->run($input, $output);
}
return 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with constant.

$helper = $this->getHelper('question');
$question = new ConfirmationQuestion(
'Command ' . self::NAME
. ' with option --force rewrite your existed files. Do you want to continue [y/N]?',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change the text

... will rewrite ...

@BaDos
Copy link
Contributor Author

BaDos commented Dec 11, 2017

@shiftedreality shiftedreality added Progress: testing in progress PR/issue status and removed Progress: review PR/Issue status labels Dec 11, 2017
@andriyShevtsov
Copy link
Contributor

QA approved

@BaDos BaDos added Progress: accept PR/issue status and removed Progress: testing in progress PR/issue status labels Dec 11, 2017
@shiftedreality shiftedreality merged commit 6fc653a into magento:develop Dec 11, 2017
@shiftedreality shiftedreality deleted the MAGECLOUD-1372 branch December 11, 2017 16:04
magento-devops-reposync-svc pushed a commit that referenced this pull request Jul 18, 2023
)

MCLOUD-10250: update broken onboarding docs link in email template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Progress: accept PR/issue status Release: 2002.0.8 ECE-Tools Release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants