Reset environment on Adobe Commerce on cloud infrastructure
This article shows different scenarios of rolling back an environment on Adobe Commerce on cloud infrastructure.
Choose the most appropriate for your case:
- If you have planned activity (planned deployment or upgrade) - Scenario 1: Planned activity).
- If you have a valid snapshot - Scenario 2: Restore a snapshot.
- If you have a stable build, but no valid snapshot - Scenario 3: No snapshot, build stable (SSH connection available).
- If the build is broken and you have no valid snapshot - Scenario 4: No snapshot; build broken (no SSH connection).
Scenario 1: Planned activity
With a planned deployment or upgrade, the easiest and recommended Rollback would be for the merchant, as part of your preparations, to do the following:
Five days prior to the upgrade/deployment activities:
- Check the size of the current Database.
- Check that you have enough disk space on
/data/exports
to hold a Database Dump. If you do not have enough disk space, then either remove unwanted data, or create a support case and request for the disk to be expanded.
On the day of the changes:
- Place the website into Maintenance Mode.
Read more about Enable or disable Maintenance Mode in our user guide, and Maintenance Mode options for upgrade in our upgrade guide. - Disable cron jobs. Read more about disabling cron jobs in our crons properties guide.
- Take a local Database Dump.
If a Rollback is required:
- If Applications such as MariaDB was upgraded as part of this planned activity, have that application reinstalled to a previous version first.
- Rollback the Database using the local Database Dump, and import this back into MariaDB.
- Rollback the code via Git to a previous working version.
Using Snapshots is not the recommended way for upgrade/planned activity rollbacks/restores, as it takes much longer to retrieve the data compared to a local Database Dump, as taken above in Step 2 of the If a Rollback is required section.
Snapshots are not held on the node/server, they are held on a separate storage block, and since that data has to be transmitted from the block storage over the network to a new disk, it takes time in the process. That new disk is then mounted onto the node ready for retrieval/import onto the original disk connected to the node/server.
When you compare this to importing a local Database Dump, the data is already retrievable on the node/server, so a lot of time is saved as only a Database Import is required.
Scenario 2: Restore a snapshot
Read: Restore a snapshot on Adobe Commerce on cloud infrastructure in our developer documentation.
Read: Create a snapshot in our developer documentation.
Scenario 3: No snapshot, build stable (SSH connection available)
This section shows how to reset an environment when you have not created a snapshot but can access the environment via SSH.
The steps are:
- Disable Configuration Management.
- Uninstall the Adobe Commerce software.
- Reset the git branch.
After performing these steps:
- Your Adobe Commerce installation returns to its Vanilla state (database restored; deployment configuration removed; directories under
var
cleared). - Your git branch is reset to the desired state in the past.
Read the detailed steps below.
Step 0 (Prerequisite): Remove config.php to disable Configuration Management
We need to 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, follow these steps:
- SSH to your environment.
- Remove the configuration file:
rm app/etc/config.php
Read more about Configuration Management:
- Reduce deployment downtime on Adobe Commerce on cloud infrastructure in our support knowledge base.
- Configuration management for store settings in our developer documentation.
Step 1: Uninstall the Adobe Commerce software with setup:uninstall command
Uninstalling the Adobe Commerce software drops and restores the database, removes the deployment configuration, and clears directories under var
.
Read: Uninstall the Adobe Commerce software in our developer documentation.
To uninstall the Adobe Commerce software, follow these steps:
- SSH to your environment.
- Execute
setup:uninstall
:bin/magento setup:uninstall
- Confirm uninstall.
The following message displays to confirm a successful uninstallation:
[SUCCESS]: Magento uninstallation complete.
This means we have reverted our Adobe Commerce installation (including DB) to its authentic (Vanilla) state.
Step 2: Reset the git branch
With git reset, we revert the code to the desired state in the past.
- Clone the environment to your local development environment. You may copy the command in the Cloud Console:
- Access the commits history. Use
--reverse
to display history in reverse order for more convenience:git log --reverse
- Select the commit hash on which you’ve been good. To reset code to its authentic state (Vanilla), find the very first commit that created your branch (environment).
- Apply hard git reset:
git reset --h <commit_hash>
- Push changes to server:
git push --force <origin> <branch>
After performing these steps, our git branch gets reset and the entire git changelog is clear. The last git push triggers the redeploy to apply all changes and re-install Adobe Commerce.
Scenario 4: No snapshot; build broken (no SSH connection)
This section shows how to reset an environment when it is in a critical state: the deployment procedure cannot succeed in building a working application, thus making the SSH connection unavailable.
In this scenario, you must first restore the working state of your Adobe Commerce application using git reset, then uninstall the Adobe Commerce software (to drop and restore the database, remove the deployment configuration, etc.). The scenario involves the same steps as in Scenario 3, but the order of steps is different and there is an additional step – force redeploy. The steps are:
After performing these steps, you will have the same results as in Scenario 3.
Step 4: Force redeploy
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>
If setup:uninstall fails, reset database manually
If executing the setup:uninstall
command fails with an error and cannot be completed, we may clear the DB manually with these steps:
- SSH to your environment.
- Connect to the MySQL DB:
mysql -h database.internal
(For Pro environments see: Set up MySQL service). - Drop the
main
DB :drop database main;
- Create an empty
main
DB:create database main;
- Delete the following configuration files:
config.php
,config.php.bak
,env.php
,env.php.bak
After resetting the DB, make a git push to the environment to trigger redeploy and install Adobe Commerce to a newly created DB. Or run the redeploy command.