You can create a copy of your database using the ece-tools db-dump
command without capturing all environment data from services and mounts. By default, this command creates backups in the /app/var/dump-main
directory for all database connections that are specified in the environment configuration. The DB dump operation switches the application to maintenance mode, stops consumer queue processes, and disables cron jobs before the dump begins.
Consider the following guidelines for DB dump:
var/log/cloud.log
).var/dbdump.lock
file to prevent the command from running on more than one node.You can choose to back up multiple databases by appending the database names to the command. The following example backs up two databases: main
and sales
:
php vendor/bin/ece-tools db-dump -- main sales
Use the php vendor/bin/ece-tools db-dump --help
command for more options.
To create a database dump in the Staging or Production environment:
Use SSH to log in or create a tunnel to connect to the remote environment that contains the database to copy.
List the environment relationships and note the database login information.
echo $MAGENTO_CLOUD_RELATIONSHIPS | base64 -d | json_pp
or
php -r 'print_r(json_decode(base64_decode($_ENV["MAGENTO_CLOUD_RELATIONSHIPS"]))->database);'
Create a backup of the database. To choose a target directory for the DB dump, use the --dump-directory
option.
php vendor/bin/ece-tools db-dump -- main
Sample response:
The db-dump operation switches the site to maintenance mode, stops all active cron jobs and consumer queue processes, and disables cron jobs before starting the dump process.
Your site will not receive any traffic until the operation completes.
Do you wish to proceed with this process? (y/N)? y
2020-01-28 16:38:08] INFO: Starting backup.
[2020-01-28 16:38:08] NOTICE: Enabling Maintenance mode
[2020-01-28 16:38:10] INFO: Trying to kill running cron jobs and consumers processes
[2020-01-28 16:38:10] INFO: Running Magento cron and consumers processes were not found.
[2020-01-28 16:38:10] INFO: Waiting for lock on db dump.
[2020-01-28 16:38:10] INFO: Start creation DB dump for main database...
[2020-01-28 16:38:10] INFO: Finished DB dump for main database, it can be found here: /tmp/qxmtlseakof6y/dump-main-1580229490.sql.gz
[2020-01-28 16:38:10] INFO: Backup completed.
[2020-01-28 16:38:11] NOTICE: Maintenance mode is disabled.
The db-dump
command creates a dump-<timestamp>.sql.gz
archive file in the remote project directory.
If you want to push this data to a specific environment, see Migrate data and static files.