Skip to content

B2SHARE CLI Commands#

The B2SHARE command-line interface (b2share CLI) is a set of commands used to create and manage B2share instance. The B2SHARE CLI is an useful tool that allowes admins to set up and manage communities, records, indexes, etc..

The document will show examples of usefull CLI commands available in the b2share CLI. For additional information check the Invenio v3 documentation.

How to run B2SHARE CLI#

B2SHARE CLI commands can be run inside the b2share running container.

docker compose -f docker-compose.full.yml exec web-api bash # if you are using docker-compose v2
alternatively
docker exec -it <web-api-container-id> bash

Availables CLI commands#

To run the b2share cli, execute in the docker container the following command:

invenio [COMMAND] [OPTIONS] [ARGUMENTS]
The following commands are available at the moment:

  • access : Account commands.
  • alembic : Perform database migrations.
  • b3share : B3Share custom commands.
  • collect : Collect static files.
  • communities : communities management commands.
  • community-extensions : Manage community schema extensions.
  • db : Database commands.
  • domains : Domain commands.
  • files : Files management commands.
  • i18n : i18n commands.
  • identity-cache : Invenio identity cache commands.
  • index : Manage search indices.
  • instance : Instance commands.
  • jobs : Invenio jobs commands.
  • limiter : Flask-Limiter maintenance & utility commands.
  • pid : PID-Store management commands.
  • queues : Manage events queue.
  • rdm : Invenio app rdm commands.
  • rdm-records : InvenioRDM records commands.
  • roles : Role commands.
  • routes : Show the routes for the app.
  • run : Runs a development server.
  • shell : Runs a shell in the app context.
  • stats : Statistics commands.
  • tokens : OAuth2 server token commands.
  • users : User commands.
  • vocabularies : Vocabularies command.
  • webpack : Webpack commands.

b2share access#

All operations below will try to identify the user based on the email address. The user must have logged in into B2SHARE at least once, otherwise the email address will not be found in the database.

Commands:

  allow                    Allow action.
  allow-action-for-role    Allow action for role.
  allow-action-for-user    Allow action for user.
  deny                     Deny actions.
  deny-action-for-role     Deny an action from role.
  deny-action-for-user     Deny an action from a user identified by an...
  list                     List all registered actions.
  remove                   Remove existing action authorization.
  remove-action-from-role  Remove a action for a role.
  remove-action-from-user  Remove a action for a user.
  remove-action-global     Remove global action rule.
  show                     Show all assigned actions.

Assign superuser-access to a user#

invenio access allow -e ${USER_EMAIL} superuser-access

Revoke superadministrator rights#

invenio access remove -e ${USER_EMAIL} superuser-access

List existing rights#

invenio access show -e ${USER_EMAIL}

b2share communities#

Communities management commands.

Commands:

  custom-fields  Communities custom fields commands.
  demo           Create 100 fake communities for demo purposes.
  rebuild-index  Rebuild index.

Community creation and management is done via B2SHARE UI.

b2share index#

Manage search indices.

Commands:

  check    Check search engine version.
  create   Create a new index.
  delete   Delete index by its name.
  destroy  Destroy all indexes.
  init     Initialize registered aliases and mappings.
  list     List indices.
  put      Index input data.
  queue    Manage indexing queue.
  reindex  Reindex all records.
  run      Run bulk record indexing.
  update   Update mappings of existing index.

Detroy and recreate indexes after a database migration#

invenio index destroy --force --yes-i-know
invenio index init --force
invenio index queue init purge

invenio index reindex --yes-i-know
invenio index run

b2share roles#

Commands to manage roles.

Commands:

  add     Add user to role.
  create  Create a role.
  remove  Remove user from role.

Add role to existing user#

Before running the command check if an user exixts. You can do that with the b2share-user cli.

invenio roles add ${USER_EMAIL} ${ROLE_NAME}

schema-extensions#

Schemas management commands.

Commands:

  add                      Add or update a community extension from a...
  check-index              Check active community schema extensions...
  delete                   Delete an existing schema by its identifier.
  get                      Show extension JSON for a community.
  list                     List all stored community extensions.
  migration-guide          Print a guide for schema field-type changes...
  pre-flight               Check a new schema JSON against definition...
  rebuild-extension-index  Delete and recreate ONLY the RDM...
  update                   Force update an existing schema extension.
  validate-all             Validate all stored community schema extensions.
  verify-dump              Show before/after dumper output for sampled...

How to fetch an existing schema#

Generate the schema as json file running:

invenio community-extensions get <community-id>

b2share users#

User management commands. Commands:

  activate    Activate a user.
  create      Create a user.
  deactivate  Deactivate a user.

Create User#

invenio users create --password ${PASSWORD} --active --confirm --username ${USERNAME} ${USER_EMAIL}

Remember to use the --active flag to activate the user immidiately after the creation.

b3share commands#

B3Share custom commands..

Commands:

  run-script  Run a Python script inside the Flask app context with...

  Last update : 11.09.2026

Last review : 11.09.2026