Skip to main content

BookStack - Upgrade unter Debian 13 (Trixie)

Vorbereitung

Vor einem Upgrade wird ein Backup der Datenbank und einiger Dateien empfohlen. Die Schritte dazu finden sich hier.

Upgrade

DiesesDas ScriptUpdate erstellterfolgt Backups,im löschtInstalaltionsverzeichnis das/var/www/bookstack:

BookStack

Update Verzeichnis,des klont die aktuelle Version und stellt die benötigten Dateien und deren Berechtigungen wieder her.repository:

catgit >pull /root/upgrade-boockstak-on-debian-13.shorigin <<release
EOF
echo
"THIS
SCRIPT

Installation ISder NOTPHP CONSIDEREDAbhängigkeiten:

OFFICIALLY
composer SUPPORTED!"install echo--no-dev
"This

 

 

Update der Datenbank:

php artisan migrate
Optional more efficient upgrade a BookStack instance on a allready running Debian 13commands (Trixie)In server."Beta) echo

 "This

script

 does

not
ensure
system
security." echo "This script

is
a
modification

from
the
install
script
found
at"
echo

 "https://codeberg.org/bookstack/devops/src/branch/main/scripts/installation-debian-13.sh"

#
Get

 date

& Time SCRIPTTIME=$(date +%s) # Generate a path for a log file to output into for debugging LOGPATH=$(realpath "bookstack_install_$SCRIPTTIME.log") # The directory to install BookStack into BOOKSTACK_DIR="/var/www/bookstack" # Prevent interactive prompts in applications export DEBIAN_FRONTEND=noninteractive # Echo out an error message to the command line and exit the program # Also logs the message to the log file function error_out() { echo "ERROR: $1" | tee -a "$LOGPATH" 1>&2 exit 1 } # Echo out an information message to both the command line and log file function info_msg() { echo "$1" | tee -a "$LOGPATH" } # Run some checks before installation function run_pre_install_checks() { # Check we're running as root and exit if not if [[ $EUID -gt 0 ]] then error_out "This script must be ran with root/sudo privileges" fi } # Backup of database & files function run_bookstack_backups () { mysqldump -u root bookstack > bookstack-database-backup-$SCRIPTTIME.sql || exit cd /var/www/bookstack || exit tar -czvf /root/bookstack-files-backup-$SCRIPTTIME.tar.gz .env public/uploads storage/uploads themes || exit } # Remove old BookStack directory function run_bookstack_removal() { cd /var/www || exit rm bookstack -R } # Download BookStack function run_bookstack_download() { cd /var/www || exit
git clonepull https://github.com/BookStackApp/BookStack.git --branchorigin release
--single-branch bookstack
}

# Install BookStack composer dependencies
function run_download_bookstack_vendor_files() {
  cd "$BOOKSTACK_DIR" || exit
  php ./bookstack-system-cli download-vendor
}php #artisan Restoremigrate
BooStack files from backup
function run_restore_files () {
  cd "$BOOKSTACK_DIR" || exit
  tar -xvzf /root/bookstack-files-backup-$SCRIPTTIME.tar.gz
}

# Set file and folder permissions
# Sets current user as owner user and www-data as owner group then
# provides group write access only to required directories.
# Hides the `.env` file so it's not visible to other users on the system.
function run_set_application_file_permissions() {
  cd "$BOOKSTACK_DIR" || exit
  chown -R www-data:www-data ./
  chmod -R 755 ./
  chmod -R 775 bootstrap/cache public/uploads storage
  chmod 640 .env

  # Tell git to ignore permission changes
  git config core.fileMode false
}

info_msg "This script logs full output to $LOGPATH which may help upon issues."
sleep 1

run_pre_install_checks
#run_prompt_for_domain_if_required
#info_msg ""
#info_msg "Installing using the domain or IP \"$DOMAIN\""
#info_msg ""
#sleep 1
info_msg "[1/6] Backup BookStack database and files from ${BOOKSTACK_DIR}..."
run_bookstack_backups >> "$LOGPATH" 2>&1

info_msg "[2/6] Remove BookStack from ${BOOKSTACK_DIR}..."
run_bookstack_removal >> "$LOGPATH" 2>&1

info_msg "[3/6] Downloading BookStack to ${BOOKSTACK_DIR}..."
run_bookstack_download >> "$LOGPATH" 2>&1

info_msg "[4/6] Downloading PHP dependency files..."
run_download_bookstack_vendor_files >> "$LOGPATH" 2>&1

info_msg "[5/6] Restore files from backup..."
run_restore_files >> "$LOGPATH" 2>&1

info_msg "[6/6] Setting BookStack file & folder permissions..."
run_set_application_file_permissions >> "$LOGPATH" 2>&1

info_msg "----------------------------------------------------------------"
info_msg "Setup finished, your BookStack instance should now be upgraded!"
info_msg "----------------------------------------------------------------"

EOF

In addition, Clearing the system caches is also recommended:

php artisan cache:clear
php artisan config:clear
php artisan view:clear

When running update commands, your command line user will need permission to handle the required files and folders in the BookStack installation folder. You can find more details about required filesystem permissions here.