You will need php (~7.1+) installed on the machine you want to run this script on. You will also need BookStack API credentials (TOKEN_ID & TOKEN_SECRET) at the ready.
This has quickly been thrown together and is not an officially supported part of BookStack.
# Downloading the script
curl https://gist.githubusercontent.com/ssddanbrown/45acb913a7b873240b2d89781e74a7a4/raw/export-books.php > export-books.php
# Setup
# ALTERNATIVELY: Open the script and edit the variables at the top.
export BS_URL=https://bookstack.example.com # Set to be your BookStack base URL
export BS_TOKEN_ID=abc123 # Set to be your API token_id
export BS_TOKEN_SECRET=123abc # Set to be your API token_secret
# Running the script
php export-books.php <format> <output_dir>
# Examples
## Export as plaintext to an existing "out" directory
php export-books.php plaintext ./out
## Export as pdf to the current directory
php export-books.php pdf ./
## Export as HTML to an existing "html" directory
php export-books.php html ./html
Hello everyone,
A few months ago, I set up this method for our BookStack server, and it worked perfectly until recently.
A few days ago, I switched our BookStack server to HTTPS, using a self-signed certificate since we only need internal access.
I have already updated the
BS_URL
in the script accordingly and added our certificate to the trusted certificates on my system. However, when I run the script, I get the following error:% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 2409 100 2409 0 0 158 0 0:00:15 0:00:15 --:--:-- 580 PHP Warning: Module "curl" is already loaded in Unknown on line 0 PHP Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in /home/adminl/Export_BookStack/export-books.php on line 72 PHP Warning: file_get_contents(): Failed to enable crypto in /home/adminl/Export_BookStack/export-books.php on line 72 PHP Warning: file_get_contents(https://bookstack.mvg-online.de/api/books?count=100&offset=0): Failed to open stream: operation failed in /home/adminl/Export_BookStack/export-books.php on line 72 PHP Fatal error: Uncaught TypeError: apiGetJson(): Return value must be of type array, null returned in /home/adminl/Export_BookStack/export-books.php:81 Stack trace: #0 /home/adminl/Export_BookStack/export-books.php(48): apiGetJson() #1 /home/adminl/Export_BookStack/export-books.php(20): getAllBooks() #2 {main} thrown in /home/adminl/Export_BookStack/export-books.php on line 81
Can anyone explain what adjustments I need to make to my BookStack server to get this function working again?