3 description = "BookStack command-line actions"
8 BookStack has some command line actions that can help with maintenance and common operations. There are also many commands available from the underlying Laravel framework. To list all available commands you can simply run `php artisan` from your BookStack install folder. Custom BookStack commands are all under the 'bookstack' namespace.
10 Below is a listing of the BookStack specific commands. For any you can provide a `-h` option to list details and options for the command.
14 ### Create an Admin User
16 Create a new admin user via the command line. Can offer a good last resort if you ever get locked out the system.
17 Will use the details provided as options otherwise will request them interactively.
21 php artisan bookstack:create-admin
23 # Non-interactive usage example
24 php artisan bookstack:create-admin --email="
[email protected]" --name="Bazza" --password="hunter2"
26 # Defining "External Authentication ID" instead of password for LDAP/SAML2/OIDC environments
27 php artisan bookstack:create-admin --email="
[email protected]" --name="Bazza" --external-auth-id="bbooker"
30 ### Copy Shelf Permission
32 By default shelf permissions will not auto-cascade since a book can be in many shelves.
33 This command will copy the permissions of a shelf to all child books.
34 This can be done for a single shelf or for all shelves in the system:
38 php artisan bookstack:copy-shelf-permissions --all
40 # Run for a single shelf
41 php artisan bookstack:copy-shelf-permissions --slug=my_shelf_slug
46 BookStack will store absolute URL paths for some content, such as images, in the database.
47 If you change your base URL for BookStack this can be problematic.
48 This command will essentially run a find & replace operation on all relevant tables in the database.
49 Be sure to take a database backup for running this command.
52 # Searches for <oldUrl> and replaces it with <newUrl>
53 php artisan bookstack:update-url <oldUrl> <newUrl>
56 php artisan bookstack:update-url http://docs.example.com https://demo.bookstackapp.com
59 ### Reset User MFA Methods
61 This will reset/clear any existing multi-factor-authentication methods for the given user. If MFA
62 is enforced for one of their roles they'll be prompted to reconfigure MFA upon next login.
69 php artisan bookstack:reset-mfa --id=5
72 ### Delete All Activity History
74 This will clear all tracked activities in the system. Note: Some areas of the interface rely on this data, including the Audit Log and any "Recent Activity" lists.
77 php artisan bookstack:clear-activity
80 ### Delete Page Revisions
82 By default this deletes all page revisions apart from page update drafts which share the same system.
83 A `-a` flag can be used to also delete these update drafts.
86 # Delete just the page revisions
87 php artisan bookstack:clear-revisions
89 # Delete all page revisions from the system including update drafts
90 php artisan bookstack:clear-revisions -a
95 Delete tracked content views from the system. These are primarily used to populate any "Recently Used" lists.
98 php artisan bookstack:clear-views
101 ### Cleanup Unused Images
103 Searches and removes images that are not used in page content.
104 While this can be done in the "Maintenance" section of the interface, running this via the command-line is often safer to avoid timeouts.
107 php artisan bookstack:cleanup-images
110 ### Regenerate the Search Index
112 BookStack uses a custom database-based search index system for efficient
113 querying within the system. The command below re-builds this search index.
114 This does not usually need to be manually ran, but it can be useful if manually inserting pages into the system or to pick-up BookStack indexing changes.
117 php artisan bookstack:regenerate-search
120 ### Regenerate Access Permissions
122 BookStack pre-calculates and stores certain access permissions in the database
123 so that access can be calculated in a performant manner.
124 The below command will regenerate these permissions.
125 This is primarily used in development but can be useful if manually adding content via the database.
128 php artisan bookstack:regenerate-permissions
131 ### Regenerate Reference Index
133 BookStack stores references between content within the system to track how
134 content is interlinked. Such references are generally managed by BookStack
135 upon certain actions, such as when saving a page, but in some cases the
136 below command may help to re-index these references.
137 This can be useful upon upgrade of old content, or when manually adding content via the database.
140 php artisan bookstack:regenerate-references
143 ### Regenerate Comment Content
145 Comments are created and stored in Markdown but also rendered to HTML on save.
146 This command will regenerate the stored HTML content for all comments using the original Markdown content.
149 php artisan bookstack:regenerate-comment-content
154 Delete all users from the system that are not original "admin" or system-level users.
157 php artisan bookstack:delete-users
160 ### Generate UTF8mb4 SQL Upgrade Commands
162 Generates out the SQL which can be used to upgrade the database to UTF8mb4.
163 See [UTF8mb4/Emoji Support](/docs/admin/ut8mb4-support/) for further details.
166 php artisan bookstack:db-utf8mb4