Course Content
Site commands
Faris Ansari
May 19, 2021

We ran a couple of bench commands with the --site option. These commands are called site commands.

Here are some of the useful site commands.

Python Console

# access the python console
$ bench --site library.test console
Apps in this namespace:
frappe, library_management

In [1]:

MariaDB Console

# access the mariadb console
$ bench --site library.test mariadb
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2333498
Server version: 10.4.13-MariaDB Homebrew

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [_ad03fa1a016ca1c4]>

Database Backup

$ bench --site library.test backup
Backup Summary for library.test at 2020-10-06 23:21:17.277960
Config  : ./library.test/private/backups/20201006_232116-library_test-site_config_backup.json   94.0B
Database: ./library.test/private/backups/20201006_232116-library_test-database.sql.gz           217.4KiB
Backup for Site library.test has been successfully completed

You can see a list of all site commands by running the following command:

$ bench --site library.test --help
Usage: bench frappe [OPTIONS] COMMAND [ARGS]...

  --site TEXT
  --profile    Profile
  --verbose    Verbose
  --force      Force
  --help       Show this message and exit.

  add-system-manager          Add a new system manager to a site
  add-to-email-queue          Add an email to the Email Queue
  add-to-hosts                Add site to hosts
  backup                      Backup
  browse                      Opens the site on web browser
  build                       Minify + concatenate JS and CSS files, build...
  build-message-files         Build message files for translation
  bulk-rename                 Rename multiple records via CSV file
  clear-cache                 Clear cache, doctype cache and defaults
  clear-website-cache         Clear website cache
  console                     Start ipython console for a site
  data-import                 Import documents in bulk from CSV or XLSX...
  destroy-all-sessions        Clear sessions of all users (logs them out)
Create Command
bahaa Abu Shaqra
4 months ago

I need to create a command that has a list Like: bench --site {site-name} add-new-item --item [?,?,?]

how I can do that?

Want to discuss?
Post it here, our mentors will help you out.
Help comand on site
SM Seid Mohammed
6 months ago

bench --site library.test --help

this command won't work to

PP Patricio Peña
3 months ago

It does not work for me either.

EDIT: I managed to get an output similar to the example if I run the following command:

bench frappe --help

I'm not sure what is the difference is between bench and bench frappe.

Want to discuss?
Post it here, our mentors will help you out.