This page has moved to Adobe Experience League and will be redirected soon.
Restore a DB snapshot from Staging or Production
Restore a DB snapshot from [!DNL Staging] or [!DNL Production]
This article shows how to restore a DB [!DNL snapshot] from [!DNL Staging] or [!DNL Production] on Adobe Commerce on cloud infrastructure.
Affected products and versions
Choose the most appropriate for your case:
Method 1: Transfer the database [!DNL dump] to your local machine and import it
The steps are:
-
Using [!DNL sFTP], navigate to the location where the database [!DNL snapshot] has been placed, usually on the first server/node of your [!DNL cluster] (For example: /mnt/recovery-<recovery_id>
).
-
Copy the database [!DNL dump file] (For example: <cluster ID>.sql.gz
for [!DNL Production] or <cluster ID_stg>.sql.gz
for [!DNL Staging]) to your local computer.
-
Make sure you have set up the [!DNL SSH tunnel] to connect to the database remotely: [!DNL SSH] and [!DNL sFTP]: [!DNL SSH tunneling] in our developer documentation.
-
Connect to the database.
mysql -h <db-host> -P <db-port> -p -u <db-user> <db-name>
-
[!DNL Drop] the database; at the [!DNL MariaDB] prompt, enter:
(For [!DNL Production])
drop database <cluster ID>;
(For [!DNL Staging])
drop database <cluster ID_stg>;
-
Enter the following command to import the [!DNL snapshot]:
(For [!DNL 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 [!DNL 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 [!DNL dump] directly from the server
The steps are:
-
Navigate to the location where the database [!DNL snapshot] has been placed, usually on the first server/node of your [!DNL cluster] (For example: /mnt/recovery-<recovery_id>
).
-
To [!DNL 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>
-
[!DNL Drop] the database; at the [!DNL MariaDB] prompt, enter:
(For [!DNL Production])
drop database <cluster ID>;
(For [!DNL Staging])
drop database <cluster ID_stg>;
-
Enter the following command to import the [!DNL snapshot]:
(For [!DNL Production])
zcat <cluster ID>.sql.gz | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | mysql -h 127.0.0.1 -p -u <db-user> <db-name>
(For [!DNL 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: