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

  1. Take Database Dump
    magento-cloud db:dump

    It will ask for project ID and environment. Enter both, and the dump file will be created in the current directory.

  2. Transfer Dump to Another Environment
    magento-cloud scp db.sql.gz remote:pub/media/db.sql.gz
  3. Get Database Credentials
    echo $MAGENTO_CLOUD_RELATIONSHIPS | base64 -d | json_pp
  4. 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
            
  5. 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';
            
  6. 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.