Bench Commands Cheatsheet
Printable Bench CLI Cheatsheet
Grab a A4 size printable cheatsheet of the most important Bench CLI commands [here](/files/Bench Cheatsheet v1.1.pdf). Download, print and put it on your desk!
General Usage
-
bench --version- Show bench version -
bench version- Show version of all apps -
bench src- Show bench repo directory -
bench --help- Show all commands and help -
bench [command] --help- Show help for command -
bench init [bench-name]- Create a new bench (Run from home dir)--python TEXTPath to Python Executable.--ignore-existIgnore if Bench instance exists.--apps_path TEXTpath to json files with apps to install after init--frappe-path TEXTpath to frappe repo--frappe-branch TEXTClone a particular branch of frappe--clone-from TEXTcopy repos from path--clone-without-updatecopy repos from path without update--no-procfilePull changes in all the apps in bench--no-backupsRun migrations for all sites in the bench--no-auto-updateBuild JS and CSS artifacts for the bench--skip-redis-config-generationSkip redis config generation if already specifying the common-site-config file--verboseVerbose output during install
-
bench --site [site-name] COMMAND- Specify site for command -
bench update- Pulls changes for bench-repo and all apps, applies patches, builds JS and CSS, and then migrates.--pullPull changes in all the apps in bench--patchRun migrations for all sites in the bench--buildBuild JS and CSS artifacts for the bench--benchUpdate bench--requirementsUpdate requirements--restart-supervisorrestart supervisor processes after update--no-backupDon't take a backup before update--resetIgnore local changes and update--devEnable developer mode on the new bench and install developer dependencies which are required for running tests.
-
bench restartRestart all bench services -
bench backupCreate a backup of the default site.
Backup will be saved to ~/frappe-bench/sites/{your site}/private/backups/.
-
bench backup-all-sitesBackup all sites--with-filesBackup site with files
-
bench restoreRestore--with-private-filesRestore site with private files (Path to tar file)--with-public-filesRestore site with public files (Path to tar file)
-
bench migrateRun patches, sync schema and rebuild files/translations--rebuild-website TEXTRebuild webpages after migration
-
bench migrate-env [python-version]Will migrate the virtual environment to the desired python version -
bench --site [sitename] set-admin-password [password]Will reset the administrator password -
bench destroy-all-sessionsDestroys all sessions
Config
-
bench config- Change bench configurationauto_update [on/off]Enable/Disable auto update for benchdns_multitenant [on/off]Enable/Disable DNS Multitenancyhttp_timeoutSet http timeoutrestart_supervisor_on_updateEnable/Disable auto restart of supervisorserve_default_siteConfigure nginx to serve the default site onupdate_bench_on_updateEnable/Disable bench updates on running bench...
-
bench setup- Setup components-
auto-updateAdd cronjob for bench auto update -
backupsAdd cronjob for bench backups -
configoverwrite or make config.json -
envSetup virtualenv for bench -
nginxgenerate config for nginx -
procfileSetup Procfile for bench start -
productionsetup bench for production -
redisgenerate config for redis cache -
socketioSetup node deps for socketio server -
sudoersAdd commands to sudoers list for execution... -
supervisorgenerate config for supervisor -
add-domainadd custom domain for site -
firewallsetup firewall and block all ports except 22, 80 and 443 -
ssh-portchange the default ssh connection port -
requirementsUpdate Python and Node packages--nodeUpdate only Node packages--pythonUpdate only Python packages--devUpdate only Python development dependencies.
-
-
bench set-nginx-port [sitename] [port]- Set site's port in Production
Development
-
bench new-app [app-name]Creates a new app -
bench get-app [repo-link]- Downloads an app from a git repository and installs it--branch [branch-name]Fetches specific branch of app
-
bench install-app [app-name]Installs existing app -
bench remove-from-installed-apps [app-name]Remove app from the list of apps -
bench uninstall-app [app-name]Delete app and everything linked to the app (Bench needs to be running) -
bench remove-app [app-name]Remove app from the bench entirely -
bench --site [sitename] --force reinstallReinstall with fresh database (Caution: Will wipe out old database) -
bench new-site [sitename]- Creates a new site--db-nameDatabase name--db-hostCustom database host URL for remote connection--db-portCustom database listening port (eg. port other than the default 3306)--mariadb-root-usernameRoot username for MariaDB--mariadb-root-passwordRoot password for MariaDB--admin-passwordAdministrator password for new site--verboseVerbose--forceForce restore if site/database already exists--source_sqlInitiate database with a SQL file--install-appInstall app after installation`
-
bench use [site]Sets a default site -
bench drop-siteRemoves site from disk and database completely--root-login--root-password
-
bench set-config [key] [value]Adds a key-value pair to site's config file -
bench consoleOpens a IPython console in the bench venv--autoreloadReload changes to code automatically
-
bench executeExecute a method inside any app.- Eg :
bench execute frappe.utils.scheduler.enqueue_scheduler_events
- Eg :
-
bench --site [sitename] mariadbOpens SQL Console -
bench --site [sitename] export-fixtures [--app TEXT]Export the records defined in the app's hooks as JSON files. -
bench run-testsRun tests--appApp Name--doctypeDocType to run tests for--testSpecific Test--moduleRun a particular module that has tests--profileRuns a Python profiler on the test
-
bench disable-productionDisables production environment -
bench serveStart a development web server on0.0.0.0--portStart the web server on a different port (default: 8000)--profileAdd a profiler middleware that prints exactly which backend methods get called, how often and how long it takes.--proxyThe development server may be run behind a proxy, e.g. ngrok / localtunnel--noreloadDisable automatic restarting of the server when files change.--nothreadingDisable handling of concurrent requests using threads. Can lead to unexpected behavior when multiple threads are required (for example during PDF generation).--with-coverageMeasure code coverage and create a reportcoverage.xmlin thesites/folder. Also activates--noreloadand--nothreading.
Scheduler
bench enable-scheduler- Enables Scheduler that will run scheduled tasksbench doctor- Get diagnostic info about background workersbench show-pending-jobs- Get pending jobsbench purge-jobs- Destroy all pending jobs
Data Import
-
bench data-import- Imports Bulk Data from .csv, .xls or .xlsx--fileFile Name--doctypeThe DocType--typeInsert/Update