Magento Cloud Database Migration & File Transfer Steps
Step-by-step guide to dump database, transfer files, and import data between Magento Cloud environments.
Important Steps
-
Take Database Dump
magento-cloud db:dumpIt will ask for project ID and environment. Enter both, and the dump file will be created in the current directory.
-
Transfer Dump to Another Environment
magento-cloud scp db.sql.gz remote:pub/media/db.sql.gz -
Get Database Credentials
echo $MAGENTO_CLOUD_RELATIONSHIPS | base64 -d | json_pp -
Connect to Database & Import Dump
mysql -h host -P port -p -u dbuser dbname zcat pub/media/db.sql.gz | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | mysql -h host -P port -p -u dbuser dbname -
Update Base URL in Database
UPDATE core_config_data SET value='http://baseurl/' WHERE path='web/unsecure/base_url'; UPDATE core_config_data SET value='https://baseurl/' WHERE path='web/secure/base_url'; -
Transfer Images to Remote Environment
magento-cloud scp image.zip remote:pub/media/images/
Conclusion
By following these steps, you can successfully migrate database and media files between Magento Cloud environments.