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 feature does not apply to the Pro environments. The Pro Staging and Production environments receive regular backups for disaster recovery purposes by default, see Pro Backup & Disaster Recovery. 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 your Starter 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 using the Cloud Console:

  1. Log in to the Cloud Console.

  2. Select an environment from the project navigation bar. The environment must be active.

  3. In the Backups view, click Backup. This option is not available for a Pro environment.

    img-md
    w-150
    Backup

To create a snapshot using the magento-cloud CLI:

  1. On your local workstation, change to your project directory.

  2. Check out the environment branch to snapshot.

  3. 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, enter magento-cloud snapshot:create --help.

    Sample response:

    code language-terminal
    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
    
  4. Verify the most recent snapshots.

    code language-bash
    magento-cloud snapshot:list
    

    The list returns information about the snapshot status:

    code language-terminal
    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
TIP
Restoring without a backup:
  • 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:

  1. Log in to the Cloud Console.

  2. Select an environment from the project navigation bar.

  3. In the Backups view, choose a backup from the Stored list. The backup feature does not apply to the Pro environments.

  4. In the

    img-md
    w-32
    More

    (more) menu, click Restore.

  5. Review the Restore from backup information and click Yes, restore.

To restore a snapshot using the Cloud CLI:

  1. On your local workstation, change to your project directory.

  2. Check out the environment branch to restore.

  3. List all available snapshots.

    code language-bash
    magento-cloud snapshot:list
    

    The list returns information about the available snapshots:

    code language-terminal
    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       |
    +---------------------------+----------------------+------------+
    
  4. Restore a snapshot using the snapshot ID from the list.

    code language-bash
    magento-cloud snapshot:restore <snapshot-id>
    

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 git revert 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.

05f2f56e-ac5d-4931-8cdb-764e60e16f26