4 5. Backup
René Kreijveld edited this page 2026-08-20 15:15:04 +02:00

Backup

jbackup

Create a full backup of a Joomla site: a database dump plus a compressed archive of all site files. Run from the project folder or from the document root.

Usage

jbackup [-n <name>] [-r] [-b] [-z] [-t] [-o] [-s] [-h]

Options

Option Description
-n <name> Name of the project to back up, looked up as <ROOTFOLDER>/<name>, so this works from anywhere. If omitted, the project you are in is used.
-r Root backup - archive the document root only, so without .ddev
-b Save the backup in <BACKUPFOLDER>/sites
-z Create a .zip archive instead of the default .tgz
-t Add a date/time-stamp to the backup filename
-o Overwrite existing backup file and/or database dump without prompting
-s Silent - suppress all messages
-h Display help

What it does

  1. Exports the database to db.sql.gz in the folder being archived, using ddev export-db
  2. Creates a compressed archive of all files in that folder, including hidden files and folders such as .ddev
  3. Removes the temporary db.sql.gz
  4. Displays the backup path and restore instructions

Full backup or document root only

By default the whole project folder is archived, .ddev included, so the archive holds everything needed to recreate the project.

With -r only the document root is archived. Because .ddev lives one folder higher, in the project folder, it is left out - you get an archive of just the website files and the database dump, which is what you want when moving a site to another server or into a different project. For a project without a document root subfolder the project folder is the document root, so there -r makes no difference.

In both cases the archive itself is written to the project folder (or to <BACKUPFOLDER>/sites with -b), never inside the folder being archived.

Output location

Backups are saved in the project folder unless -b is used. In that case the backup is saved to <BACKUPFOLDER>/sites, with BACKUPFOLDER defined in your configuration:

  • <sitename>.tgz - default
  • <sitename>.zip - with -z
  • <sitename>.20240315.143022.tgz - with -t

Restoring a backup

jbackup prints the exact restore commands for the backup it just made. In general, unpack the archive in the folder it was made from - the project folder for a full backup, the document root for a -r backup.

To restore a .tgz backup:

cd ~/Development/Sites/mysite
tar xzf mysite.tgz

To restore a .zip backup:

cd ~/Development/Sites/mysite
unzip -q -o mysite.zip

After restoring the files, import the database:

jdbimp

The archive contains db.sql.gz, so jdbimp finds it in the list of available dumps.

Examples

Back up the current site:

cd ~/Development/Sites/mysite
jbackup

Back up a named site with a timestamp and zip format and store in the backupfolder:

jbackup -n mysite -b -z -t

Back up the website files only, without .ddev:

cd ~/Development/Sites/mysite
jbackup -r

Back up silently, overwriting any existing backup:

jbackup -n mysite -o -s

jbackupall

Create a full backup of all DDEV Joomla projects. This script scans for all Joomla installations and runs jbackup for each one, saving the backups to the configured backup folder.

Usage

jbackupall [-z] [-t] [-s] [-h]

Options

Option Description
-z Create .zip archives instead of the default .tgz
-t Add a date/time-stamp to the backup filenames
-s Silent - suppress all messages
-h Display help

What it does

  1. Scans the ROOTFOLDER (defined in your configuration, up to 2 levels deep) for DDEV projects by locating their .ddev folders
  2. For each project it resolves the document root from that project's .ddev/config.yaml and skips the project when no configuration.php is found there
  3. Runs jbackup -b for each remaining project, saving all backups to <BACKUPFOLDER>/sites
  4. Passes through any zip (-z), timestamp (-t), and silent (-s) options to each jbackup call

Each backup is a full project backup, .ddev included.

Examples

Back up all Joomla projects:

jbackupall

Back up all projects as zip files with timestamps:

jbackupall -z -t

Back up all projects silently:

jbackupall -s