Backup management
You can perform a manual backup of active Starter environments at any time using the Backup button in the Cloud Console or using the magento-cloud snapshot:create
command.
A backup or snapshot is a complete backup of environment data that includes all persistent data from running services (MySQL database) and any files stored on the mounted volumes (var, pub/media, app/etc). The snapshot does not include code, since the code is already stored in the Git-based repository. You cannot download a copy of a snapshot.
The backup/snapshot feature does not apply to the Pro Staging and Production environments, which receive regular backups for disaster recovery purposes by default. Refer to Pro Backup & Disaster Recovery for more information. Unlike the automatic live backups on the Pro Staging and Production environments, backups are not automatic. It is your responsibility to manually create a backup or set up a cron job to periodically create a backup of your Starter or Pro integration environments.
Create a manual backup
You can create a manual backup of any active Starter environment and integration Pro environment from the Cloud Console or create a snapshot from the Cloud CLI. You must have an Admin role for the environment.
To create a backup of any Starter environment using the Cloud Console:
-
Log in to the .
-
Select an environment from the project navigation bar. The environment must be active.
-
In the Backups view, click Backup. This option is not available for a Pro environment.
{width="150"}
To create a backup of an integration environment using the Cloud Console:
- Log in to the .
- Select an integration/development environment from the project navigation bar. The environment must be active.
- Select the Backup option in the top-right menu. This option is available for both Starter and Pro environments.
- Click the Yes button.
To create a snapshot using the magento-cloud
CLI:
-
On your local workstation, change to your project directory.
-
Check out the environment branch to snapshot.
-
Create the snapshot.
code language-bash magento-cloud snapshot:create --live
Alternatively, you can use the
magento-cloud backup
short command. The--live
option leaves the environment running to avoid downtime. For a full list of options, entermagento-cloud snapshot:create --help
.Sample response:
code language-none Creating a snapshot of develop-branch Waiting for the activity ID (User created a backup of develop-branch): Creating backup of develop-branch Created backup my-snapshot [============================] 45 secs (complete) Activity ID succeeded Snapshot name: my-snapshot
-
Verify the most recent snapshots.
code language-bash magento-cloud snapshot:list
The list returns information about the snapshot status:
code language-none Snapshots on the project (project-id), environment develop-branch (type: development): +---------------------------+----------------------+------------+ | Created | Snapshot ID | Restorable | +---------------------------+----------------------+------------+ | 2023-03-08T17:07:01+00:00 | my-snapshot | true | +---------------------------+----------------------+------------+
Restore a manual backup
You must have Admin access to the environment. You have up to seven days to restore a manual backup. Restoring a backup does not change the code of the current git branch. Restoring a backup in this manner does not apply to Pro staging and production environments; see Pro Backup & Disaster Recovery.
Restoration times vary depending on the size of your database:
- large database (200+ GB) can take 5 hours
- medium database (150 GB) can take 2 1/2 hours
- small database (60 GB) can take 1 hour
- To roll back to previous code or remove added extensions in an environment, see Roll back code.
- To restore an unstable environment that does not have a backup, see Restore an environment.
To restore a backup using the Cloud Console:
-
Log in to the .
-
Select an environment from the project navigation bar.
-
In the Backups view, choose a backup from the Stored list. The backup feature does not apply to the Pro environments.
-
In the
{width="32"}
(more) menu, click Restore.
-
Review the Restore from backup information and click Yes, restore.
To restore a snapshot using the Cloud CLI:
-
On your local workstation, change to your project directory.
-
Check out the environment branch to restore.
-
List all available snapshots.
code language-bash magento-cloud snapshot:list
The list returns information about the available snapshots:
code language-none Snapshots on the project (project-id), environment develop-branch (type: development): +---------------------------+----------------------+------------+ | Created | Snapshot ID | Restorable | +---------------------------+----------------------+------------+ | 2023-03-08T17:07:01+00:00 | my-snapshot | true | +---------------------------+----------------------+------------+
-
Restore a snapshot using the snapshot ID from the list.
code language-bash magento-cloud snapshot:restore <snapshot-id>
Restore a Disaster Recovery Snapshot
To restore the Disaster Recovery Snapshot in Pro Staging and Production environments, Import the database dump directly from the server.
Roll back code
Backups and snapshots do not include a copy of your code. Your code is already stored in the Git-based repository, so you can use Git-based commands to roll back (or revert) code. For example, use git log --oneline
to scroll through previous commits; then use to restore code from a specific commit.
Also, you can choose to store code in an inactive branch. Use git commands to create a branch instead of using magento-cloud
commands. See about Git commands in the Cloud CLI topic.