Bench Commands Cheatsheet
Printable Bench CLI Cheatsheet
Grab a A4 size printable cheatsheet of the most important Bench CLI commands here. Download, print and put it on your desk!
General Usage
bench --version- Show bench versionbench version- Show version of all appsbench src- Show bench repo directorybench --help- Show all commands and helpbench [command] --help- Show help for commandbench 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 commandbench 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
bench restartRestart all bench servicesbench 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 versionbench --site [sitename] set-admin-password [password]Will reset the administrator passwordbench 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 componentsauto-updateAdd cronjob for bench auto updatebackupsAdd cronjob for bench backupsconfigoverwrite or make config.jsonenvSetup virtualenv for benchnginxgenerate config for nginxprocfileSetup Procfile for bench startproductionsetup bench for productionredisgenerate config for redis cachesocketioSetup node deps for socketio serversudoersAdd commands to sudoers list for execution...supervisorgenerate config for supervisoradd-domainadd custom domain for sitefirewallsetup firewall and block all ports except 22, 80 and 443ssh-portchange the default ssh connection portrequirementsUpdate 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 appbench 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 appbench remove-from-installed-apps [app-name]Remove app from the list of appsbench 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 entirelybench --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 sitebench 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 filebench 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 Consolebench --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
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