Snapshots and backup management

You can perform a manual backup of active Starter and Pro Integration environments at any time using the Snapshots button in the Project Web Interface or using the magento-cloud snapshot:create command.

A 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 snapshots feature does not apply to the Pro Staging and Production 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, snapshots are not automatic. It is your responsibility to manually create a snapshot or set up a cron job to periodically take snapshots of your Starter or Pro Integration environments.

Create a snapshot

You must have an Admin role for the environment.

To create a snapshot using the Project Web Interface:

  1. Log in to the Project Web Interface.
  2. In the left pane, click the name of the environment to back up.
  3. In the top pane, click the Snapshots icon. This option is not available for a Pro Production or Staging environment.
  4. Click Create.

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.

    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:

    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.

    magento-cloud snapshot:list
    

    The list returns information about the snapshot status:

    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

You must have Admin access to the environment. You have up to seven days to restore a snapshot. Restoring a snapshot does not change the code of the current git branch. Restoring a snapshot 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 snapshot:

  • 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 snapshot, see Restore an environment.

To restore a snapshot using the Project Web Interface:

  1. Log in to the Project Web Interface.
  2. In the left pane, click the name of the environment to restore.
  3. In the environment messages, select snapshot from the all types of drop-down list.
  4. Click restore next to the snapshot.
  5. Review the Snapshot restore date and click 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.

    magento-cloud snapshot:list
    

    The list returns information about the available snapshots:

    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.

    magento-cloud snapshot:restore <snapshot-id>
    

Roll back code

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.

On this page