1
1
Fork
You've already forked system-cli
0
A simple CLI to manage BookStack instances
PHP 98.7%
Dockerfile 1.3%
Dan Brown 24bbf72f6e
December 2025 updates
- Updated PHP package versions.
- Extracted core logic from DownloadVendorCommand to its own service
- Updated UpdateCommand to use download-vendor logic instead of composer
- Updated init command to download BookStack from
 source.bookstackapp.com instead of GitHub.
- Updated UpdateCommandTest to cover changes
2025年12月20日 15:39:13 +00:00
.forgejo Updated dependancies, license year and .github folder 2025年03月08日 14:53:43 +00:00
src December 2025 updates 2025年12月20日 15:39:13 +00:00
test-data Added strict types, started phpunit testing 2023年03月27日 19:43:19 +01:00
tests December 2025 updates 2025年12月20日 15:39:13 +00:00
.gitignore Updated dependancies, increased min. PHP version 2024年11月07日 16:01:52 +00:00
compile.php Fixed compile consuming more files than desired 2025年03月12日 00:06:48 +00:00
composer.json Updated dependancies, increased min. PHP version 2024年11月07日 16:01:52 +00:00
composer.lock December 2025 updates 2025年12月20日 15:39:13 +00:00
docker-compose.yml Added test case for mysql usage with special chars 2025年05月14日 11:52:12 +01:00
docker-mysql-init.sql Added test case for mysql usage with special chars 2025年05月14日 11:52:12 +01:00
Dockerfile Updated docker setup 2025年03月08日 17:16:35 +00:00
LICENSE Updated dependancies, license year and .github folder 2025年03月08日 14:53:43 +00:00
phpunit.xml Updated dependancies, increased min. PHP version 2024年11月07日 16:01:52 +00:00
readme.md Bumped version and updated readme command list 2025年03月11日 15:51:17 +00:00
run.php December 2025 updates 2025年12月20日 15:39:13 +00:00

BookStack System CLI

A simple command line interface for managing instances of BookStack. Provides the following commands:

  • init - Set up a fresh BookStack installation within a folder.
  • backup - Creates a backup of an existing BookStack installation to a single ZIP file.
  • restore - Restore a backup ZIP into an instance of BookStack.
  • update - Update an existing BookStack installation to the latest version.
  • download-vendor - Download an extract vendor/ files for a BookStack install.

This CLI is intended to be platform abstract, intended for plain installs that follow our scripts/manual instructions. This is intended to work independently of BookStack itself, so it can be used even if a BookStack instance is not available or broken, although it could be distributed with and called upon by the core BookStack codebase.

Development

This project uses composer to manage PHP dependencies. They can be installed as follows:

composer install

This project is intended to be bundled up into a single phar file for portability and separation with BookStack itself. This can be done by running the compile file:

php compile.php

Tests can be ran via PHPUnit within the docker environment as described below. It is not advised to run tests outside of this docker environment since tests are written to an expected pre-configured system environment.

Docker Environment

A docker-compose setup exists to create a clean, contained environment, which is important for this project since the CLI checks and interacts with many system-level elements.

# Build the environment container
docker compose build
# Enter the environment
docker compose run app
# From there you'll be dropped into a bash shell within the project directory.
# You could proceed to install dependencies via composer via:
composer install
# Then you can run tests via:
vendor/bin/phpunit
# To clean-up and delete the environment:
docker compose down -v --remove-orphans

Within the environment a pre-existing BookStack instance can be found at /var/www/bookstack for testing.

Contributing

I welcome issues and PRs but keep in mind that I'd like to keep the feature-set narrow to limit support/maintenance burden. Therefore, I likely won't leave issues open long, or merge PRs, for requests to add new features or for changes that increase the scope of what this script already supports.

Known Issues

mysqldump - Couldn't execute 'FLUSH TABLES'

mysqldump may produce the following:

mysqldump: Couldn't execute 'FLUSH TABLES': Access denied; you need (at least one of) the RELOAD or FLUSH_TABLES privilege(s) for this operation (1227)

This was due to 8.0.32 mysqldump, changing the required permissions, and this should be largely fixed as per 8.0.33. Temporary workaround is to provide the database user RELOAD permissions. For example:

GRANTRELOADON*.*TO'bookstack'@'localhost';

mysql - Restore throws permission error

MySQL during restore can throw the following:

ERROR 1227 (42000) at line 18 in file: '/root/bookstack/restore-temp-1682771620/db.sql': Access denied; you need (at least one of) the SUPER, SYSTEM_VARIABLES_ADMIN or SESSION_VARIABLES_ADMIN privilege(s) for this operation

This is due to mysql adding replication data to the output. We could set --set-gtid-purged=value during dump but does not exist for mariadb. Alternatively, we could maybe filter these SET lines? But need to be targeted and efficient since files dump files may be large.

mysql - Only TCP connections

This assumes a database connection via a TCP connection is being used by BookStack. Socket/other type of connections could technically be used with BookStack but is not something we advise or document within our docs or env options listing, so we make this assumption for simplicity.