This article discusses the possible (and recommended) ways to create a database (DB) dump on Magento Commerce (Cloud) environments.
You only need to use one variant (option) to dump your DB. These options apply to any environment type (Integration, Staging, Production) and any plan (Starter and Pro).
Prerequisite: SSH to your environment
To dump your DB on Magento Commerce (Cloud) with any variant discussed in this article, you must first SSH to your environment.
Whether you choose Option 1 or Option 2 please run the command during off peak hours against a database secondary node.
Option 1: db-dump (ece-tools; recommended)
You may dump your DB using the ECE-Tools command:
This is the recommended and safest option.
Related documentation on DevDocs: Dump your database (ECE-Tools)
Option 2: mysqldump
Do not run this command against the database cluster. The cluster will not differentiate whether it is run against the database primary or against a secondary. If the cluster runs this command against the primary, the database will be unable to execute writes until the dump is completed and could impact performance and site stability.
You may dump your DB using the native MySQL
The entire command might look as follows:
mysqldump -h <host> -u <username> -p<password> --single-transaction <db_name> | gzip > /tmp/<dump_name>.sql.gz
To obtain your DB credentials (host, username, and password), you might call the
MAGENTO_CLOUD_RELATIONSHIPS environment variable:
echo $MAGENTO_CLOUD_RELATIONSHIPS |base64 --d |json_pp