Backup and Upgrade
Everything your group writes lives in two places (chapter 2): the database and the uploaded files. A backup that covers only one of them is a story you tell yourself. This chapter does the backup properly, says what a restore involves, and then covers the upgrade, which begins — always — with the backup.
The backup: a dump and a folder
The database half is one command, straight from the project's backup documentation:
mysqldump -u bookstack -p bookstack \
> bookstack-backup.sql
The lab ran it against the working install and then checked the result instead of admiring it: a real SQL file, 41 table definitions, and the library's actual contents inside — the pumpkins page and its planted word pluviometer both present in the dump. That check is the difference between a backup and a hope; whatever your schedule, grep your dump for a word you know is in the library.
The files half is the parts of the application folder that are yours:
| Path | Why |
|---|---|
.env |
Your settings — including the APP_KEY a restore will need |
public/uploads |
Uploaded images |
storage/uploads |
Page attachments |
themes |
Only if you customised the look |
tar -czf bookstack-files-backup.tar.gz \
.env public/uploads storage/uploads themes
Store both halves somewhere that is not this server, together, with the date in the name. The lab's dump was 75 KB for a model library; real libraries grow, and the dump grows with them — that growth is normal and not a problem to solve.
The restore, in outline
Documented-only in this guide — the lab made and verified the backup but did not rehearse the restore — and the project's own procedure is clear:
- Install BookStack fresh on the new machine, but do not run the migrate step; the dump brings its own schema.
- Import the dump:
mysql -u bookstack -p bookstack < bookstack-backup.sql - Unpack the files archive back into the application folder.
- Run
php artisan migrate— this brings the restored schema up to the installed version's expectations. - Keep the old
.env'sAPP_KEY. Encrypted values in your data were sealed with it; a new key unseals nothing. If the address changed, updateAPP_URLto match and run the project's URL-update command so links inside pages point home.
Rehearse this on a spare machine while the library is young. The first restore you ever perform should not be the one that matters.
The upgrade: backup, then three commands
BookStack releases often, and the update process is deliberately dull. Back up first — both halves. Then, in the application folder:
git pull origin release
composer install --no-dev
php artisan migrate
Followed, as housekeeping, by:
php artisan cache:clear
php artisan config:clear
php artisan view:clear
The lab ran the maintenance half of this
against its up-to-date install: migrate
correctly reported "Nothing to migrate",
and the cache clears ran clean. A true
version-to-version upgrade is
documented-only here — the lab installed
the current release and had nothing older
to upgrade from — but two of the project's
own upgrade notes deserve repeating:
- Read the version-specific notes
before upgrading. Occasionally a release
changes a requirement; v26.09, for
example, made a valid
APP_KEYmandatory, and an install limping along without one stops at that upgrade. - Requirements move. PHP and database minimums rise over the years (PHP 8.2 and MariaDB 10.6 are today's floor). An upgrade that fails on versions is telling you the platform needs its own upgrade first.
Check: after any upgrade, sign in, open a page with an image, run a search, and — as chapter 8 taught — glance at the library as a restricted user. Five minutes, and the upgrade is proven rather than assumed.