2 title = "BookStack System CLI"
7 The BookStack System CLI allows easy running of BookStack infrastructure-level tasks
8 such as backing up, restoring or updating. The CLI is distributed with
9 the BookStack project source code, although the CLI is self-contained and can run independently
10 of a BookStack instance.
12 ***Warning:** The System CLI was added in BookStack v23.05 in an alpha state and currently
13 remains in that non-production state until it has been well tested.
14 Please use the CLI with caution, and ensure you fully & periodically test any processes where the CLI is relied upon.*
22 The CLI is included with the BookStack codebase, so you can usually run it like so:
25 # Go to your BookStack install
29 ./bookstack-system-cli
32 The CLI is built using PHP.
33 Depending on operating system and permissions, you may need to instead run it directly via PHP like so:
36 php ./bookstack-system-cli
39 By default, without any arguments provided, the CLI will list the available commands which are documented [in more detail below](#available-commands).
40 With any command, you can pass a `-h` option to show additional per-command details and options.
46 It's possible to use the CLI without it being part of a BookStack instance. This can be useful if using it to create
47 a new BookStack install instance.
49 You can grab a copy of the CLI from the `release` branch of the [core project GitHub repo](https://github.com/BookStackApp/BookStack/blob/release/bookstack-system-cli).
50 Below is how you might fetch the CLI, and make it globally available on the command line, on a Linux server:
53 # Download the raw CLI file from GitHub
54 curl https://github.com/BookStackApp/BookStack/raw/release/bookstack-system-cli -sLo bookstack-system-cli
56 # Made the CLI executable by default
57 chmod +x bookstack-system-cli
59 # Move into a globally accessible PATH location
60 sudo mv bookstack-system-cli /usr/local/bin/bookstack-system-cli
68 ### Available Commands
72 Backup a BookStack installation to a single compressed ZIP file.
73 By default this will attempt to backup anything that may be expected to be user-generated, or admin edited, within an install.
74 This includes a database dump of everything within the connected BookStack database instance, along with the current `.env` file in use.
75 The backup will also attempt to include a copy of the CLI itself in the backup, so the exact same CLI can be used for restore where required.
77 Note that this won't attempt backup of anything on remote systems, like those uploaded when BookStack is configured to use S3 file storage.
79 If a backup target output ZIP is not provided as a first additional argument, it will be saved to the `storage/backups` folder, relative to
80 the BookStack root installation folder, with a name in the format:
83 bookstack-backup-<year>-<month>-<day>-<time>.zip
86 When successful, the CLI will report the backup ZIP location upon completion.
91 # Create a backup in the default "storage/backups" directory of a BookStack install
92 ./bookstack-system-cli backup
94 # Create a backup, specifying the target output file name and location
95 # as the first additional argument
96 ./bookstack-system-cli backup ~/my-backup.zip
101 - `--no-database` Skip inclusion of a database dump, containing your main BookStack content.
102 - `--no-uploads` Skip backup of any local file or image uploads.
103 - `--no-themes` Skip backup of any custom theme files.
104 - `--app-directory=<path>` Provide a path to the BookStack instance to back up. When not provided, the CLI will attempt to locate the BookStack install based upon current working directory and the location of the CLI itself.
108 Restore the provided ZIP file into an existing BookStack installation.
109 The ZIP file should be one created via the `backup` command, or at least in a compatible format.
111 When ran, the command will attempt to resolve any APP_URL, or database, `.env` changes that might need to be made
112 when the backed-up `.env` file is restored.
117 # Restore the ~/my-backup.zip backup file into the current BookStack instance
118 ./bookstack-system-cli restore ~/my-backup.zip
121 ##### Command Options
123 - `--app-directory=<path>` Provide a path to the BookStack instance to back up. When not provided, the CLI will attempt to locate the BookStack install based upon current working directory and the location of the CLI itself.
127 Update the existing BookStack installation to the latest version.
128 This runs an instance through the standard BookStack [update commands](/docs/admin/updates) to bring it up to the latest release version.
133 # Update the current BookStack instance
134 ./bookstack-system-cli update
137 ##### Command Options
139 - `--app-directory=<path>` Provide a path to the BookStack instance to back up. When not provided, the CLI will attempt to locate the BookStack install based upon current working directory and the location of the CLI itself.
143 Initialize a new BookStack installation in the given folder.
144 This clones down the BookStack project, installs PHP dependencies, creates a fresh `.env` file for editing, then generates a key for the `.env` file.
146 Note that this won't do everything for a new BookStack install, you'll still need to configure your database details then migrate the database, and configure your system's web-server (and any required permissions).
151 # Initialize a new BookStack install in the current folder
152 ./bookstack-system-cli init
154 # Initialize a new BookStack install at the "/var/www/new-bookstack" path
155 ./bookstack-system-cli init /var/www/new-bookstack
160 ### CLI Source Code & Project
162 The CLI is maintained as its own project within the [BookStackApp/system-cli Codeberg project](https://codeberg.org/bookstack/system-cli).
163 There you can find the source code, development details and known issues.