Restore an environment

If you encounter issues in your environment and do not have a valid snapshot, you can try restoring your environment in one of the following ways:

  • SSH
  • Git


If you have not created a snapshot, but you can access the environment using SSH, follow these steps to restore your environment:

  1. Disable configuration management
  2. Uninstall Magento
  3. Reset the git branch

Performing these steps:

  • Returns your Magento installation to its original state by restoring the database, removing the deployment configuration, and clearing var/ subdirectories.
  • Resets your git branch to a stable state in the past.

Disable configuration management

You must disable configuration management so that it does not automatically apply the previous configuration settings during deployment.

To disable configuration management, make sure that your app/etc/ directory does not contain the config.php file.

To remove the configuration file:

  1. SSH to your environment.
  2. Remove the configuration file:
    • For Magento 2.2:

      rm app/etc/config.php
    • For Magento 2.1:

      rm app/etc/config.local.php

Uninstall Magento

Uninstalling the Magento software drops and restores the database, removes the deployment configuration, and clears var/ subdirectories.

To uninstall the Magento software:

  1. SSH to your environment.
  2. Uninstall the Magento application.

    php bin/magento setup:uninstall
  3. Confirm that Magento was successfully uninstalled.

    The following message displays to confirm a successful uninstallation:

    [SUCCESS]: Magento uninstallation complete.

Reset the git branch

Resetting your branch reverts the code to a stable state in the past.

To reset your branch:

  1. Clone the project to your local development environment. You can find the command in your Project Web Interface:

    Click to copy the git clone command

  2. Review the git history. Use --reverse to display history in reverse chronological order:

    git log --reverse
  3. Choose a commit hash that represents the last known stable state of your code.

    To reset your branch to its original initialized state, find the very first commit that created your branch.

    Select a commit hash in the git console

  4. Use the hard reset option to reset your branch.

    git reset --h <commit_hash>
  5. Push your changes to trigger a redeploy, which reinstalls Magento.

    git push --force <origin> <branch>


If you have not created a snapshot, cannot access your environment using SSH, and your deployment keeps failing, you must complete the steps in the previous section, and then force a redeployment.

Force a redeployment

Make a commit (this might be an empty commit, although we do not recommend it) and push it to the server to trigger redeploy:

git commit --allow-empty -m "<message>" && git push <origin> <branch>

Uninstall failed

If executing the setup:uninstall command fails and cannot be completed, you might need to manually reset the database:

  1. SSH to your environment.
  2. Connect to the database.

    mysql -h database.internal
  3. Drop the main database.

    drop database main;
  4. Create an empty main database.

    create database main;
  5. Delete the following configuration files.

    • config.php
    • config.php.bak
    • env.php
    • env.php.bak

After resetting the database, push your changes to trigger a redeploy and install Magento using the new database. Or run the redeploy command.