Bench Restore Command
The bench restore command restores a Frappe site from an existing database backup. It can also restore the site’s public and private files, allowing you to recover a previous site state after data loss, migration, or server recovery.
At minimum, a database backup file is required to perform a restore. Public and private file archives can be restored optionally.
Usage
Use the following command to restore a site from a database backup.
bench restore [OPTIONS] SQL_FILE_PATH
How the Restore Command Works
When executed, Bench restores the specified site’s database using the provided backup file. If supplied, it also restores the site’s public and private files from their respective backup archives.
If Bench detects that the backup belongs to an older Frappe version than the current installation, it displays a downgrade warning before continuing.
Downgrading a Frappe site is not officially supported. Only continue if you fully understand the potential risks.
Supported Backup Files
- Database:
.sqlor.sql.gz - Public Files:
.taror.tgz - Private Files:
.taror.tgz
Restoring only public or private files without a database backup is not supported.
SQL_FILE_PATH Argument
The required SQL_FILE_PATH argument specifies the location of the database backup file.
The path can be:
- Relative to the Bench directory
- Relative to the
sitesdirectory - An absolute file path
Using an absolute file path is generally more reliable, especially when restoring backups from external storage locations.
Available Options
| Option | Description |
|---|---|
--db-root-username |
Specify the MariaDB or PostgreSQL root username. |
--db-root-password |
Specify the database root password. |
--db-name |
Create or restore the site using a custom database name. |
--admin-password |
Reset the Administrator password after restoration. |
--install-app |
Install an additional app after the restore completes. |
--with-public-files |
Restore public files from a backup archive. |
--with-private-files |
Restore private files from a backup archive. |
Available Flag
| Flag | Purpose |
|---|---|
--force |
Ignore downgrade warnings and continue with the restore. |
Using the --force option is not recommended unless you are certain the backup is compatible with the current environment.
Examples
Restore a Site with Public and Private Files
bench --site {site} restore {path/to/database/file}
--with-public-files {path/to/public/archive}
--with-private-files {path/to/private/archive}
This restores the database together with both public and private file backups.
Skip Database Root Password Prompt
bench --site {site} restore {path/to/database/file}
--db-root-username {db-user}
--db-root-password {db-pass}
Provide database credentials directly to avoid interactive prompts.
Install an App After Restoration
bench --site {site} restore {path/to/database/file}
--install-app {app}
The specified application is installed immediately after the restore process finishes.
Restore Using a Custom Database Name
bench --site {site} restore {path/to/database/file}
--db-name {custom-db-name}
This creates or restores the site using a custom database name.
Reset the Administrator Password
bench --site {site} restore {path/to/database/file}
--admin-password {admin-pass}
The Administrator account password is updated immediately after the site is restored.