bench backup
The bench backup command creates a backup of a Frappe site. By default, it generates a database dump, compresses it, and stores it in the site’s backup directory. You can also include public and private files, customize backup locations, and back up specific DocTypes.
If a current site is configured, simply running bench backup creates a backup for that site without specifying the --site option.
Command Syntax
bench backup [OPTIONS]
What the Command Does
When executed, the command performs the following tasks:
- Creates a database dump of the selected site.
- Compresses the database backup.
- Saves the backup in the default directory:
sites/{site}/private/backups
Optionally, the command can also include public files, private files, configuration files, or selected DocTypes in the backup.
Command Options
| Option | Description |
|---|---|
--backup-path |
Specify a custom location for all backup files. |
--backup-path-db |
Specify the location for the database backup. |
--backup-path-conf |
Specify the location for the configuration backup. |
--backup-path-files |
Specify the location for public file backups. |
--backup-path-private-files |
Specify the location for private file backups. |
--exclude, -e |
Exclude specific DocTypes from the backup. |
--only, --include, -i |
Back up only the specified DocTypes. |
Available Flags
--ignore-backup-conf— Ignore backup include and exclude settings defined in the site configuration.--with-files— Include public and private files in the backup.--compress— Compress public and private files into.tgzarchives.--verbose— Display detailed output during the backup process.
Examples
1. Create a Backup Including Public and Private Files
bench --site mysite.local backup --with-files
2. Compress File Backups
bench --site mysite.local backup --with-files --compress
The public and private files are compressed into .tgz archives instead of the default .tar format.
3. Save Backups to a Custom Location
bench --site mysite.local backup --backup-path /home/frappe/backups
4. Specify Separate Backup Locations
bench --site mysite.local backup --with-files \
--backup-path-conf /backup/config \
--backup-path-db /backup/database \
--backup-path-files /backup/public \
--backup-path-private-files /backup/private
5. Display Detailed Backup Information
bench --site mysite.local backup --verbose
6. Back Up Only Selected DocTypes
bench --site mysite.local backup \
--only "ToDo,Note,Task,Project,Sales Invoice"
Only the specified DocTypes are included in the database backup.
7. Exclude Specific DocTypes
bench --site mysite.local backup \
--exclude "Error Log,Access Log,Activity Log,Version"
Useful for excluding frequently changing log tables to reduce backup size.
8. Ignore Backup Configuration Settings
bench --site mysite.local backup --ignore-backup-conf
Creates a complete backup without considering any include or exclude rules defined in frappe.conf.backup.*.
If the backup process fails for any reason, Bench automatically deletes any partially created backup files to avoid consuming unnecessary disk space.
Include the --with-files option for complete site backups, especially before upgrades or migrations. Regularly verify your backups by restoring them in a test environment to ensure they can be successfully recovered.