Skip to content

Bench Commands

Bench fixtures Command

Generate a .json file containing the data and settings you want to migrate

Pre-requisite defined the fixtures in hook file of the custom app

Command Syntax

bench export-fixtures --site <sitename>

Use Cases

Terminal window
bench export-fixtures --site dev.localhost

Sample Output

A custom_field.json file will be created in the path <custom_app>/<custom_app>/fixtures


Bench backup Command

  • Use this command to take backup of the site.
  • Run this command inside the backend container of your application.

Command Syntax

bench --site <site-name> backup

Options

OptionsDescription
--with-filesBackup along with public and private files

Use Case

1) Without Flag

Terminal window
bench --site lenstest.lmnas.com backup

Sample Output

Terminal window
Backup encryption is turned on. Please note the backup encryption key.
Backup Summary for lenstest.lmnas.com at 2025-05-29 11:18:07.105285
Config : ./lenstest.lmnas.com/private/backups/20250529_111752-lenstest_lmnas_com-site_config_backup-enc.json 282.0B
Database: ./lenstest.lmnas.com/private/backups/20250529_111752-lenstest_lmnas_com-database-enc.sql.gz 40.0MiB
Backup for Site lenstest.lmnas.com has been successfully completed

2) With Flag

Terminal window
bench --site lenstest.lmnas.com backup --with-files

Sample Output

Terminal window
Backup encryption is turned on. Please note the backup encryption key.
Backup Summary for lenstest.lmnas.com at 2025-05-29 11:21:50.643478
Config : ./lenstest.lmnas.com/private/backups/20250529_112132-lenstest_lmnas_com-site_config_backup-enc.json 282.0B
Database: ./lenstest.lmnas.com/private/backups/20250529_112132-lenstest_lmnas_com-database-enc.sql.gz 40.0MiB
Public : ./lenstest.lmnas.com/private/backups/20250529_112132-lenstest_lmnas_com-files-enc.tar 123.1MiB
Private : ./lenstest.lmnas.com/private/backups/20250529_112132-lenstest_lmnas_com-private-files-enc.tar 6.3MiB
Backup for Site lenstest.lmnas.com has been successfully completed with files

Bench restore Command

  • Use this command to restore the site with the backup files.
  • Run this command inside the backend container of your application.

Command Syntax

bench --site <site-name> restore <path/to/backup-files>

Options & Flags

TypeDescription
--forceflagIgnore warnings
--with-public-filesoptionRestores the public files of the site
--with-private-filesoptionRestores the private files of the site
--encryption-keyoptionPass Backup encryption key if the backup file is encrypted (Only use this when you find enc in the backup file names)

Use Case

1) Without force Flag

Terminal window
bench --site lenstest.lmnas.com restore ./sites/lenstest.lmnas.com/private/backups/20250529_020517-lenstest_lmnas_com-database.sql.gz

Sample Output

Terminal window
$ bench --site lenstest.lmnas.com restore ./sites/lenstest.lmnas.com/private/backups/20250529_020517-lenstest_lmnas_com-database.sql.gz
MySQL root password:
Restoring Database for Site lenstest.lmnas.com...
Database backup found at ./sites/lenstest.lmnas.com/private/backups/20250529_020517-lenstest_lmnas_com-database.sql.gz
Extracting...
Database successfully extracted
Installing database...
Rebuilding database lenstest_lmnas_com...
Database restored
Updating DocTypes for lenstest.lmnas.com : [========================================]
Updating patched modules...
Backing up the newly restored database...
Backup complete
Site restored successfully.

2) With force Flag

Terminal window
bench --site lenstest.lmnas.com --force restore \
./sites/lenstest.lmnas.com/private/backups/20250529_020517-lenstest_lmnas_com-database.sql.gz \
--with-public-files ./sites/lenstest.lmnas.com/private/backups/20250529_020517-lenstest_lmnas_com-files.tar \
--with-private-files ./sites/lenstest.lmnas.com/private/backups/20250529_020517-lenstest_lmnas_com-private-files.taz

Sample Output

Terminal window
MySQL root password:
App frappe already installed
*** Scheduler is enabled ***
Site localhost has been restored with files

3) With encrypted backup

Terminal window
bench --site lenstest.lmnas.com --force restore \
./sites/lenstest.lmnas.com/private/backups/20250529_020517-lenstest_lmnas_com-database-enc.sql.gz \
--with-public-files ./sites/lenstest.lmnas.com/private/backups/20250529_020517-lenstest_lmnas_com-files-enc.tar \
--with-private-files ./sites/lenstest.lmnas.com/private/backups/20250529_020517-lenstest_lmnas_com-private-files-enc.tar \
--encrypted-key hgsdajhvfjwtef7363jkhajkfgj

Sample Output

Terminal window
Provide encryption key for decryption. Decrypting using the provided key
MySQL root password:
App frappe already installed
*** Scheduler is enabled ***
Site localhost has been restored with files

Bench migrate Command

  • applies all pending patches and updates the database schema to match the current code.
  • Run this command inside the backend container of your application.

Command Syntax

bench --site <site-name> migrate

Use Case

Terminal window
bench --site lenstest.lmnas.com migrate

Sample Output

Terminal window
Migrating lenstest.lmnas.com
Updating DocTypes for frappe : [========================================] 100%
Updating DocTypes for payments : [========================================] 100%
Updating DocTypes for erpnext : [========================================] 100%
Updating Dashboard for frappe
Updating Dashboard for payments
Updating Dashboard for erpnext
Updating customizations for Address
Updating customizations for Contact
Queued rebuilding of search index for lenstest.lmnas.com

Enabling scheduler in bench

  • Commands to manage the scheduler and background jobs statuses for the sites on your bench.
  • Run this command inside the backend container of your application.

Command Syntax

bench --site <site-name> enable-scheduler

Use Case

Terminal window
bench --site lenstest.lmnas.com enable-scheduler

Sample Output

Terminal window
Enabling scheduler for lenstest.lmnas.com
Scheduler enabled

Disable scheduler in bench

  • Commands to stop the scheduler and background jobs statuses for the sites on your bench.
  • Run this command inside the backend container of your application.

Command Syntax

bench --site <site-name> disable-scheduler

Use Case

Terminal window
bench --site lenstest.lmnas.com disable-scheduler

Sample Output

Terminal window
Disabling scheduler for lenstest.lmnas.com
Scheduler disabled

Enabling server script in Version-15 bench

Note: Starting from version 15, Server Scripts are disabled by default.

Command Syntax

Terminal window
bench set-config -g server_script_enabled 1