Database Operations
jdbdump
Export the DDEV database to a SQL dump file. Run from the project folder or from the document root.
Usage
jdbdump [-b] [-t] [-n] [-o] [-v] [-s] [-h]
Options
| Option | Description |
|---|---|
-b |
Store the dump in <BACKUPFOLDER>/databases instead of the document root (BACKUPFOLDER is set in the config file) |
-t |
Add a date/time-stamp to the dump filename (e.g. <projectname>-db.20240315-143022.sql.gz) |
-n |
Do not compress the dump with gzip (produces <projectname>-db.sql instead of <projectname>-db.sql.gz) |
-o |
Overwrite existing dump file without prompting |
-v |
Verbose - show all DDEV output |
-s |
Silent - suppress all messages |
-h |
Display help |
Output
By default the dump is saved in the document root of the project - next to the Joomla files - as:
<projectname>-db.sql.gz- compressed (default)<projectname>-db.sql- uncompressed (with-n)<projectname>-db.<timestamp>.sql.gz- with timestamp (with-t)
With -b, the dump is saved in <BACKUPFOLDER>/databases instead.
For a project without a document root subfolder the document root is the project folder, so the dump simply lands in the project folder. For a project with one (e.g. public) the dump lands in that subfolder, regardless of which of the two folders you ran the script from. That keeps the dump where the site files are, so it is picked up by jdbimp and included in a document-root-only backup (jbackup -r).
If a dump file already exists, you will be asked to confirm before overwriting (unless -o is used).
Examples
Standard compressed dump:
cd ~/Development/Sites/mysite
jdbdump
Uncompressed dump with timestamp:
jdbdump -n -t
Dump to backup folder with timestamp:
jdbdump -b -t
Overwrite existing dump silently:
jdbdump -o -s
jdbdumptable
Dump a single table from the DDEV database to a SQL file. Run from the project folder or from the document root.
Usage
jdbdumptable -t <tablename> [-n] [-v] [-s] [-h]
Options
| Option | Description |
|---|---|
-t <tablename> |
The database table to dump. Required. |
-n |
Do not compress the dump with gzip (produces <tablename>.sql instead of <tablename>.sql.gz) |
-v |
Verbose - show all DDEV output |
-s |
Silent - suppress all messages |
-h |
Display help |
Output
The dump is saved in the document root of the project, the same location jdbdump uses, as:
<tablename>.sql.gz- compressed (default)<tablename>.sql- uncompressed (with-n)
Examples
Dump a single table (compressed):
cd ~/Development/Sites/mysite
jdbdumptable -t jos_content
Dump a table without compression:
jdbdumptable -t jos_users -n
jdbdumpall
Create a database dump of all DDEV Joomla projects found under the ROOTFOLDER. Each dump is stored in <BACKUPFOLDER>/databases with a timestamp in the filename. Run from anywhere.
Usage
jdbdumpall [-n] [-v] [-s] [-h]
Options
| Option | Description |
|---|---|
-n |
Do not compress the dumps with gzip |
-v |
Verbose - show all DDEV output |
-s |
Silent - suppress all messages |
-h |
Display help |
How it works
jdbdumpall scans ROOTFOLDER (up to 2 levels deep) for DDEV projects by looking for their .ddev folder. For each project it resolves the document root from that project's .ddev/config.yaml, skips the project when no configuration.php is found there, and otherwise calls jdbdump -b -t to create a timestamped dump.
Because it always passes -b, the dumps always go to <BACKUPFOLDER>/databases and never into a project folder.
Both ROOTFOLDER and BACKUPFOLDER are configured in the config file.
Output
Each dump is saved in <BACKUPFOLDER>/databases as:
<projectname>-db.<timestamp>.sql.gz- compressed (default)<projectname>-db.<timestamp>.sql- uncompressed (with-n)
Examples
Dump all Joomla projects:
jdbdumpall
Dump all projects without compression:
jdbdumpall -n
jdbimp
Import a SQL dump file into the DDEV database. Run from the project folder or from the document root.
The database you are importing to is not dropped before the import runs.
Usage
jdbimp [-f <dumpfile>] [-d] [-n] [-s] [-h]
Options
| Option | Description |
|---|---|
-f <dumpfile> |
Import a specific file instead of choosing one from a list |
-d |
Delete the dump file after a successful import |
-n |
Do not show the DDEV progress bar during the import |
-s |
Silent - suppress all messages and all DDEV output |
-h |
Display help |
Choosing a dump file
When -f is not specified, jdbimp lists the .sql and .sql.gz files it finds in the document root of the project - the same location jdbdump writes to and where a document-root-only backup unpacks its dump. You then choose which one to import by number.
A file passed with -f is resolved against the folder you are in, so a relative or absolute path to a dump anywhere on disk keeps working.
By default the DDEV progress bar is shown during the import. Use -n to hide it, or -s to suppress all output.
Examples
Auto-detect and import:
cd ~/Development/Sites/mysite
jdbimp
Import a database dump:
jdbimp
Available database dump files:
1. dump.sql
2. update.sql.gz
Enter number of file to import:
Import a specific file:
jdbimp -f backup-2024-03-15.sql.gz
Import a dump from the backup folder and delete it afterwards:
jdbimp -f ~/Development/Backups/databases/mysite-db.20240315-143022.sql.gz -d
Import without the progress bar:
jdbimp -n