Perform a database dump using the
platform CLI tool.
- One or more active Platform.sh projects
- The Platform.sh CLI tool installed locally
- An SSH key configured on the project account
- Known project IDs. (Use
Sometimes it is necessary to do a database dump of a project. This can be especially useful when doing some testing, planning a migration or for recovery purposes.
Platform CLI can be used to backup the database with a single command.
In general, the following command will be used to perform a database dump using the Platform CLI:
Usage: platform db:dump [-f|--file FILE] [-t|--timestamp] [--stdout] [-p|--project PROJECT] [--host HOST] [-e|--environment ENVIRONMENT] [-A|--app APP]
For a single configured database, use the command below:
$ platform db:dump Creating SQL dump file:/Users/my_user/platformsh-enterprise/hiera/mysqldb--main--dump.sql
Running the previous command with multiple databases, choosing a relationship will be prompted by the CLI:
$ platform db:dump Enter a number to choose a relationship:  postgresql (firstname.lastname@example.org)  database (email@example.com)
Dumping the MySQL database (
database, in this case) can be chosen by selecting
database can be chosen directly ahead of time with the CLI with the
$ platform db:dump --relationship database
Further options can be specified, as per the example below:
$ platform db:dump --relationship database -p project_id -e environment_name -A app
To find the platform relationship details, SSS into the environment and run:
$ echo $PLATFORM_RELATIONSHIPS | base64 --decode | json_pp
By default the dump file will be uncompressed. To compress it, use the
-z ) option:
platform db:dump --gzip
This error can sometimes show up, after running the
db dump command. If this happens, try the following:
- Redeploy the environment the user is trying to access.
- The SSH key may be improperly configured. Check with
platform ssh-key:addif necessary.
- Remove the user from the project, then add them back and redeploy the environment.
Database dumps can be easily done by using Platform.sh CLI.