Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

Latest commit

 

History

History

dump-and-deploy-db

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Dump and deploy SQL from/to remote servers

This adds custom commands which dump or deploy SQL data to/from databases. As database servers are usually not reachable through the internet, it can tunnel its connection through SSH.

Original intent

This was originally meant as a simple tool to refresh the DDEV database from time to time during feature development with current live data. A fancy interface was built to facilitate adoption with colleagues ;) - the normal workflow would be ddev dump-db my-remote-live-server; ddev deploy-db ddev.

It came in handy during TYPO3 upgrades, too when being able to diff SQL data table by table helps facilitate single update steps. This is a controversial topic, but during upgrades I found it helpful to even git the data/SQL together with the code and thus be able to completely undo steps (even if they have side effects on the data) when necessary.

Installation

Copy the web/ directory into your project's .ddev/commands/web.

Configuration

Without configuration this lets you dump and and deploy the local (called ‹ddev›) database.

In order to add other hosts, see web/targets/README.txt for the config file structure. You basically need SSH and DB connection info. You can use private keys (e.g. via ddev auth ssh) or a password prompt to connect.

Usage

Running ddev deploy-db or ddev dump-db will show the available host configurations and parameters.

ddev dump-db will save the SQL data at ./data/sql/records and ./data/sql/struct.

ddev deploy-db also expects .sql files to be in any of these directories. For the ‹ddev› target this is functionally identical to cat ./data/sql/struct/*.sql ./data/sql/records/*.sql | ddev mysql.

Example

This is what ddev dump-db my-host looks like:

dump-db

Contributed by @jonaseberle