| name | bench-commands |
| description | Frappe Bench CLI command reference for site management, app management, development, and production operations. Use when running bench commands, managing sites, migrations, builds, or deployments. |
Bench CLI Commands Reference
Complete reference for the Frappe Bench command-line interface for managing Frappe/ERPNext installations.
When to Use This Skill
- Running bench commands for development
- Managing Frappe sites
- Installing and updating apps
- Running migrations and builds
- Setting up production environments
- Troubleshooting common issues
Bench Directory Structure
frappe-bench/
├── apps/ # Frappe apps
│ ├── frappe/ # Core framework
│ ├── erpnext/ # ERPNext (if installed)
│ └── my_app/ # Custom apps
├── sites/ # Sites directory
│ ├── common_site_config.json
│ ├── apps.txt # List of installed apps
│ └── my_site.local/ # Individual site
│ ├── site_config.json
│ ├── private/
│ └── public/
├── config/ # Configuration files
├── logs/ # Log files
├── env/ # Python virtual environment
└── node_modules/ # Node.js dependencies
Site Management
Create Site
bench new-site mysite.local
bench new-site mysite.local --db-name mysite_db
bench new-site mysite.local --mariadb-root-password mypassword
bench new-site mysite.local --admin-password admin123
bench new-site mysite.local --source_sql /path/to/backup.sql
bench new-site mysite.local --no-mariadb-socket
Use Site
bench use mysite.local
bench --site mysite.local migrate
bench --site all migrate
Site Operations
bench list-sites
bench drop-site mysite.local
bench drop-site mysite.local --force
bench --site mysite.local set-maintenance-mode on
bench --site mysite.local set-maintenance-mode off
bench --site mysite.local disable-scheduler
bench --site mysite.local enable-scheduler
Backup & Restore
bench --site mysite.local backup
bench --site mysite.local backup --with-files
bench --site all backup
bench --site mysite.local restore /path/to/backup.sql.gz
bench --site mysite.local restore /path/to/backup.sql.gz \
--with-private-files /path/to/private.tar \
--with-public-files /path/to/public.tar
App Management
Get Apps
bench get-app https://github.com/frappe/erpnext
bench get-app https://github.com/frappe/erpnext --branch version-14
bench get-app https://github.com/frappe/erpnext --tag v14.0.0
bench get-app /path/to/my_app
bench get-app erpnext --install-all
Install/Uninstall Apps
bench --site mysite.local install-app erpnext
bench --site all install-app my_app
bench --site mysite.local uninstall-app my_app
bench --site mysite.local uninstall-app my_app --yes --force
Create New App
bench new-app my_app
Update Apps
bench update
bench update --no-migrations
bench update --apps erpnext
bench update --no-pull
bench update --no-build
bench update --reset
Remove App
bench remove-app my_app
bench --site mysite.local uninstall-app my_app
bench remove-app my_app
Development Commands
Start Development Server
bench start
bench start --procfile Procfile.dev
bench serve
bench serve --port 8001
Build Assets
bench build
bench build --app my_app
bench build --verbose
bench build --production
bench build --make-copy
bench watch
Migrate
bench --site mysite.local migrate
bench --site all migrate
bench --site mysite.local migrate --app my_app
bench --site mysite.local migrate --skip-failing
Clear Cache
bench --site mysite.local clear-cache
bench --site mysite.local clear-website-cache
bench clear-redis-cache
Console
bench --site mysite.local console
bench --site mysite.local execute myapp.scripts.my_function
bench --site mysite.local execute myapp.scripts.my_function --args='["arg1", "arg2"]'
MariaDB Console
bench --site mysite.local mariadb
bench --site mysite.local mariadb -e "SELECT * FROM tabCustomer LIMIT 5"
Run Tests
bench --site mysite.local run-tests
bench --site mysite.local run-tests --app my_app
bench --site mysite.local run-tests --module my_app.my_module.doctype.my_doctype.test_my_doctype
bench --site mysite.local run-tests --coverage
bench --site mysite.local run-tests --doctype "My DocType"
bench --site mysite.local run-tests --parallel
bench --site mysite.local run-tests --skip-setup
Translation
bench --site mysite.local update-translations
bench --site mysite.local export-translations
bench --site mysite.local import-translations /path/to/translations.csv
Production Setup
Setup Production
sudo bench setup production frappe-user
bench setup supervisor
bench setup systemd
bench setup nginx
bench setup redis
bench setup fail2ban
SSL/Let's Encrypt
sudo bench setup lets-encrypt mysite.local
sudo bench renew-lets-encrypt
Restart Services
sudo supervisorctl restart all
sudo supervisorctl restart frappe-bench-web:*
sudo supervisorctl restart frappe-bench-workers:*
sudo systemctl restart frappe-bench-web
sudo systemctl restart frappe-bench-schedule
sudo supervisorctl status
Scheduler & Workers
Scheduler
bench --site mysite.local enable-scheduler
bench --site mysite.local disable-scheduler
bench --site mysite.local show-scheduler-status
bench --site mysite.local execute frappe.tasks.run_daily
Background Jobs
bench --site mysite.local show-pending-jobs
bench --site mysite.local clear-website-cache
bench worker --queue default
bench worker --queue short
bench worker --queue long
bench --site mysite.local purge-jobs
Configuration
Site Config
bench --site mysite.local show-config
bench --site mysite.local set-config key value
bench --site mysite.local set-config limits '{"users": 10}'
bench set-config key value
bench --site mysite.local remove-config key
Common Configurations
{
"db_name": "mysite_db",
"db_password": "password",
"db_type": "mariadb",
"encryption_key": "xxxxx",
"developer_mode": 0,
"maintenance_mode": 0,
"pause_scheduler": 0,
"mail_server": "smtp.gmail.com",
"mail_port": 587,
"use_tls": 1,
"mail_login": "user@gmail.com",
"mail_password": "password",
"auto_email_id": "noreply@mysite.com",
"mute_emails": 0,
"enable_scheduler": 1,
"limits": {
"users": 10,
"emails": 500,
"space": 5120
}
}
Bench Config
bench config list
bench config set serve_port 8001
bench config set redis_cache_port 13000
bench config set developer_mode 1
bench config set webserver_port 8000
bench config set background_workers 1
Troubleshooting Commands
Logs
tail -f logs/frappe.log
tail -f logs/web.error.log
tail -f logs/worker.error.log
tail -f logs/scheduler.error.log
tail -f sites/mysite.local/logs/frappe.log
Debug
bench --site mysite.local doctor
bench --site mysite.local show-db-size
bench --site mysite.local --db-type mariadb execute \
"SELECT table_name, data_length FROM information_schema.tables WHERE table_schema = 'mysite_db'"
bench --site mysite.local show-scheduler-status
bench --site mysite.local set-admin-password newpassword
bench --site mysite.local add-system-manager user@example.com
Fix Common Issues
bench --site mysite.local build-search-index
bench --site mysite.local reset-perms
bench --site mysite.local clear-locks
bench --site mysite.local reinstall --yes
bench --site mysite.local partial-restore /path/to/backup.sql
Version Management
bench version
bench switch-to-branch version-14 frappe erpnext
bench switch-to-branch develop --upgrade
bench set-bench-version 5.x
Multi-Tenancy
bench config dns_multitenant on
bench --site mysite.local add-domain newdomain.com
bench --site mysite.local remove-domain newdomain.com
sudo certbot certonly --webroot -w /var/www/letsencrypt -d *.mydomain.com
Common Workflows
Fresh Install
pip install frappe-bench
bench init frappe-bench
cd frappe-bench
bench get-app erpnext
bench new-site mysite.local
bench --site mysite.local install-app erpnext
bench start
Daily Development
bench update --no-backup
cd apps/frappe && git pull
cd apps/erpnext && git pull
bench update --no-pull
bench --site mysite.local clear-cache
bench build --app my_app
Deploy Update
cd /home/frappe/frappe-bench
bench --site mysite.local set-maintenance-mode on
bench --site mysite.local backup --with-files
bench update
bench --site mysite.local migrate
bench build --production
bench --site mysite.local clear-cache
sudo supervisorctl restart all
bench --site mysite.local set-maintenance-mode off