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 This **will not** change the `APP_URL` option set in your configuration. If changing your BookStack URL, you will also need to change that `.env` file option to match your new instance URL.
61 ### Reset User MFA Methods
63 This will reset/clear any existing multi-factor-authentication methods for the given user. If MFA
64 is enforced for one of their roles they'll be prompted to reconfigure MFA upon next login.
71 php artisan bookstack:reset-mfa --id=5
74 ### Refresh User Avatars
76 This will re-fetch avatar images for users in the system.
77 By default avatars are fetched from [Gravatar](https://gravatar.com/) unless an alternative avatar system [has been configured](/docs/admin/other-config/#custom-user-avatar-fetching).
79 *Note: This will **not** load avatars from any connected authentication system.*
82 # Refresh avatar for just the user of the given email
84 # Or the user of the given id
85 php artisan bookstack:refresh-avatar --id=101
87 # Refresh avatars for all users without avatars already assigned
88 php artisan bookstack:refresh-avatar --users-without-avatars
90 # Refresh avatars for all users in the system
91 php artisan bookstack:refresh-avatar --all
94 ### Delete All Activity History
96 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.
99 php artisan bookstack:clear-activity
102 ### Delete Page Revisions
104 By default this deletes all page revisions apart from page update drafts which share the same system.
105 A `-a` flag can be used to also delete these update drafts.
108 # Delete just the page revisions
109 php artisan bookstack:clear-revisions
111 # Delete all page revisions from the system including update drafts
112 php artisan bookstack:clear-revisions -a
115 ### Delete Page Views
117 Delete tracked content views from the system. These are primarily used to populate any "Recently Used" lists.
120 php artisan bookstack:clear-views
123 ### Cleanup Unused Images
125 Searches and removes images that are not used in page content.
126 While this can be done in the "Maintenance" section of the interface, running this via the command-line is often safer to avoid timeouts.
129 php artisan bookstack:cleanup-images
132 ### Regenerate the Search Index
134 BookStack uses a custom database-based search index system for efficient
135 querying within the system. The command below re-builds this search index.
136 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.
139 php artisan bookstack:regenerate-search
142 ### Regenerate Access Permissions
144 BookStack pre-calculates and stores certain access permissions in the database
145 so that access can be calculated in a performant manner.
146 The below command will regenerate these permissions.
147 This is primarily used in development but can be useful if manually adding content via the database.
150 php artisan bookstack:regenerate-permissions
153 ### Regenerate Reference Index
155 BookStack stores references between content within the system to track how
156 content is interlinked. Such references are generally managed by BookStack
157 upon certain actions, such as when saving a page, but in some cases the
158 below command may help to re-index these references.
159 This can be useful upon upgrade of old content, or when manually adding content via the database.
162 php artisan bookstack:regenerate-references
167 Assigns and runs the specified [sort rule](/docs/user/organising-content/#sort-rules) to the specified content in batch.
168 Running the command without any arguments will list the existing sort rules
169 in the system as an easy method to get their IDs.
170 A flag is required to specific which content to assign the rule to. The available options
171 are shown in the examples below.
175 php artisan bookstack:assign-sort-rule <sort_rule_id> <assignment-flag>
177 # Assign sort rule 4 to all books
178 php artisan bookstack:assign-sort-rule 4 --all-books
180 # Assign sort rule 19 to all books which don't already have a sort rule assigned
181 php artisan bookstack:assign-sort-rule 19 --books-without-sort
183 # Assign sort rule 2 to books which already have sort rule 7 assigned
184 # This is useful to switch the sort rule of many books
185 php artisan bookstack:assign-sort-rule 2 --books-with-sort=7
187 # List out available sort rules
188 php artisan bookstack:assign-sort-rule
193 Delete all users from the system that are not original "admin" or system-level users.
196 php artisan bookstack:delete-users
199 ### Generate UTF8mb4 SQL Upgrade Commands
201 Generates out the SQL which can be used to upgrade the database to UTF8mb4.
202 See [UTF8mb4/Emoji Support](/docs/admin/ut8mb4-support/) for further details.
205 php artisan bookstack:db-utf8mb4