Restore a DB snapshot from Staging or Production

This article shows how to restore a DB snapshot from Staging or Production on Adobe Commerce on cloud infrastructure.

Affected products and versions

Choose the most appropriate for your case:

Method 1: Transfer the database dump to your local machine and import it

The steps are:

  1. Using sFTP, navigate to the location where the database snapshot has been placed, usually on the first server/node of your cluster (For example: /mnt/recovery-<recovery_id>).

  2. Copy the database dump file (For example: <cluster ID>.sql.gz for Production or <cluster ID_stg>.sql.gz for Staging) to your local computer.

  3. Make sure you have set up the SSH tunnel to connect to the database remotely: SSH and sFTP: SSH tunneling in our developer documentation.

  4. Connect to the database.

    mysql -h <db-host> -P <db-port> -p -u <db-user> <db-name>
    
  5. Drop the database; at the MariaDB prompt, enter:

    (For Production)

    drop database <cluster ID>;
    

    (For Staging)

    drop database <cluster ID_stg>;
    
  6. Enter the following command to import the snapshot:

    (For Production)

    zcat <cluster ID>.sql.gz | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | mysql -h 127.0.0.1 -P <db-port> -p -u   <db-user> <db-name>
    

    (For Staging)

    zcat <cluster ID_stg>.sql.gz | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | mysql -h 127.0.0.1 -P <db-port> -p -u   <db-user> <db-name>
    

Method 2: Import the database dump directly from the server

The steps are:

  1. Navigate to the location where the database snapshot has been placed, usually on the first server/node of your cluster (For example: /mnt/recovery-<recovery_id>).

  2. To drop and re-create the cloud database, first connect to the database:

    mysql -h 127.0.0.1 -P <db-port> -p -u <db-user> <db-name>
    
  3. Drop the database; at the MariaDB prompt, enter:

    (For Production)

    drop database <cluster ID>;
    

    (For Staging)

    drop database <cluster ID_stg>;
    
  4. Enter the following command to import the snapshot:

    (For Production)

    zcat <cluster ID>.sql.gz | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | mysql -h 127.0.0.1 -p -u <db-user> <db-name>
    

    (For Staging)

    zcat <cluster ID_stg>.sql.gz | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | mysql -h 127.0.0.1 -p -u <db-user> <db-name>
    

In our developer documentation:

On this page