Skip to main content

Backup + Migration

IchI habeinstalled BookStack pervia Docker installiert (wieas in derthe Anleitungguide). KannstCould duyou mirplease bitteexplain erklären,how wieto ichcreate Backups erstellebackups (vollständigefull Inhaltssicherung)content backup) so that I can migrate the website if needed, e.g., sodassto ichanother die Website bei Bedarf z.B. zu einem anderen Server/Domain umziehen kann?server/domain? HierHere istis dieBookStack’s offizielleofficial Anleitung von BookStack.guide.

VollständigesFull BookStack-BackupBookStack backup (Docker) – so,so dassthat eina Umzugmove aufto anderenanother Server/Domainserver/domain klapptworks 🧰📦

DuFor brauchst für einea komplette,complete, wiederherstellbarerestorable Sicherungbackup, imyou Wesentlichenessentially need zweitwo Bausteinecomponents:

  1. DatenbankDatabase (alleall Seiten,pages, Bücher,books, Nutzer,users, Rechte,permissions, Einstellungensettings …)
  2. Dateien/ConfigFiles/config (Uploads,uploads, Anhänge,attachments, .env/APP_KEY, ggf.possibly Themes/Module)themes/modules)

DaSince duyou dashave Setupthe wiesetup like in deineryour Anleitung hastguide (/opt/bookstack mitwith docker-compose.yml, Volumesvolumes ./mariadb undand ./bookstack), istthis dasis erfreulichpleasantly simpel.simple.


WasWhat genauexactly mussneeds gesichertto werden?be backed up?

1) DatenbankDatabase (MariaDB)

  • InhaltThe stecktcontent im DB-Container,is in deinemthe SetupDB dauerhaftcontainer, unter:and in your setup it’s persisted under:
    • ./mariadb (alsas Volumevolume ./mariadb:/config)
  • SaubersterCleanest Wegapproach: SQL-DumpSQL dump (portabel,portable, versionstolerant)tolerant across versions)

2) DateienFiles (BookStack-Container-Volume)BookStack container volume)

  • PersistentePersistent Datendata liegenis beilocated dir unter:under:
    • ./bookstack (alsas Volumevolume ./bookstack:/config)
  • DarinIn sindit, insbesondereespecially wichtig:important:
    • .env (inkl.including APP_KEY!)
    • Uploads/Attachmentsuploads/attachments
    • ggf.possibly www/themes/custom/... (deineyour Hacks/Module)hacks/modules)

3) Compose/Caddy (fürhelpful denfor Umzug hilfreich)migration)

  • docker-compose.yml
  • Caddyfile
  • Caddy-DatenCaddy data optional:
    • ./caddy/data & ./caddy/config (Zertifikate/State)certificates/state).
      NichtNot zwingendstrictly nötigrequired, aberbut spartsometimes manchmalsaves Re-Issue/Rate-Limits.re-issuing/rate limits.

🗂️ BackupCreate erstellena backup (empfohlenesrecommended Vorgehen)approach)

Annahme:Assumption: Projektproject liegtis located in /opt/bookstack undand diethe Containercontainers heißenare wienamed as in deineryour YAML:
bookstack-mariadb undand bookstack.

SchrittStep 1: Backup-OrdnerCreate anlegena backup folder

cd /opt/bookstack
mkdir -p backups

SchrittStep 2: DatenbankDump alsthe database as SQL dumpen 💾

docker exec -i bookstack-mariadb \
  mysqldump -u bookstack -pbookstack \
  --single-transaction --routines --triggers \
  bookstack > backups/bookstack-db-$(date +%F).sql

Wichtig:Important: ErsetzeReplace -pbookstack durchwith deinyour echtesreal Passwortpassword (ausfrom MYSQL_PASSWORD).

AlternativAlternative (sicherer,safer weilbecause Passwortthe nichtpassword won’t end up in dershell Shell-History landet)history):
LassOmit -p..., weg, dann fragtthen mysqldump interaktivwill nachprompt deminteractively Passwort:for the password:

docker exec -it bookstack-mariadb mysqldump -u bookstack -p --single-transaction --routines --triggers bookstack > backups/bookstack-db-$(date +%F).sql

SchrittStep 3: Dateien/VolumesArchive archivierenfiles/volumes 📦

tar -czvf backups/bookstack-files-$(date +%F).tar.gz \
  docker-compose.yml Caddyfile \
  bookstack mariadb caddy

WennIf duyou don’t want to back up Caddy, nichtyou mitsicherncan willst,do gehtit auch schlanker:leaner:

tar -czvf backups/bookstack-files-$(date +%F).tar.gz \
  docker-compose.yml Caddyfile \
  bookstack mariadb

SchrittStep 4: (Optional) IntegritätscheckIntegrity check

ls -lh backups/
head -n 5 backups/bookstack-db-*.sql
tar -tzf backups/bookstack-files-*.tar.gz | head

🔁 Restore (aufon neuema Server)new server)inkl.incl. Domain/URL-Umzugdomain/URL migration

SchrittStep 0: VoraussetzungenPrerequisites

  • Docker + Docker Compose installiertinstalled
  • DNS derof neuenthe Domainnew zeigtdomain aufpoints dento neuenthe Servernew server (fürfor HTTPS via Caddy)

SchrittStep 1: BackupCopy rüberkopierenthe backup over

AufPack on the altenold Serverserver packenor odercopy direkt kopieren:directly:

scp -r /opt/bookstack/backups user@neuer-user@new-server:/opt/bookstack/

SchrittStep 2: DateienRestore wiederherstellenfiles (Compose/Volumes)volumes) 📂

AufOn demthe neuennew Server:server:

cd /opt/bookstack
tar -xvzf backups/bookstack-files-YYYY-MM-DD.tar.gz

(DatumAdjust natürlichthe anpassen.date, of course.)


SchrittStep 3: ContainerStart startencontainers (DB sollshould schonalready laufen)be running) 🐳

cd /opt/bookstack
docker compose up -d mariadb

WarteWait eina paarfew Sekunden,seconds bisuntil MariaDB bereitis ist.ready.


SchrittStep 4: DatenbankImport importierenthe database 🧩

cat backups/bookstack-db-YYYY-MM-DD.sql | \
  docker exec -i bookstack-mariadb mysql -u bookstack -pbookstack bookstack

Wieder:Again: Passwortadjust anpassenthe bzw.password interaktivor nutzen.use interactive mode.


SchrittStep 5: Start BookStack starten

docker compose up -d

🌍 Domain/URL geändert?changed? (sehrvery wichtig!important!)

WennIf duyou aufmove eineto a anderedifferent URL/Domaindomain, umziehst,you musst du:must:

1) Adjust APP_URL imin the .env

In your volume, the .env anpassenis

Intypically deinemlocated Volume liegt die .env typischerweise unter:at:

  • ./bookstack/www/.env (häufigcommon beiwith linuxserver/bookstack)
  • oderor ./bookstack/.env (jedepending nachon Image/Setup)image/setup)

SucheFind sieit so:like this:

find /opt/bookstack/bookstack -maxdepth 3 -name ".env" -print

DannThen set APP_URL=https://neue-new-domain.tld setzen..

AchtePay darauf:attention: DieThe APP_KEY mussmust dieremain altethe bleibenold one (sonstotherwise gehenencrypted u.a.data verschlüsseltewill Datenbreak, kaputt,e.g., z.MFA B. MFA-Secrets)secrets).

2) BookStack-Command:BookStack command: “Update System URL“URL”

docker exec -it bookstack php /app/www/artisan bookstack:update-url https://alte-old-domain.tld https://neue-new-domain.tld

(FallsIf derthe Pfadpath imin Containerthe anderscontainer ist,is funktioniertdifferent, oftthis auch:often also works: php artisan ... ausfrom /app/www.)


🧠 PraktischePractical Hinweisenotes (damit’so it’s wirklichtruly „umzugsicher“ ist)“migration-safe”)

  • Always store Backup immerbackups offsite speichern(another (anderes System/Storage)system/storage).

  • Datenbank-DumpDatabase dump + Datei-Archivefile archive istis amthe portabelsten.most portable.

  • WennIf duyou restore to a aufnewer eineBookStack neuere BookStack-Versionversion wiederherstellst::

    1. Restore DB

    2. ContainerBring hochcontainers up

    3. DannThen Migrationrun laufen lassenmigrations (fallsif nötig)needed):

      docker exec -it bookstack php /app/www/artisan migrate --force
      

WennIf duyou willst:want: IchI’ll machemake diryou eina „1-Kommando-Backup-Skript““one-command backup script” 🧾

SagJust mirtell kurz:me briefly:

  • LiegtIs deineyour .env unterlocated at bookstack/www/.env?
  • WieWhat heißenare deineyour Containercontainers wirklichactually named (docker ps-Auszug) output)?
  • WillstDo duyou Caddy-Zertifikatewant mitsichernto oderback lieberup nicht?Caddy certificates or preferably not?

DannThen gebeI’ll ichgive diryou eina kleinessmall Skriptscript inkl.including Rotationrotation (z.e.g., B.“keep „haltethe die letztenlast 7 Backups“backups”) undand optionalemoptional Uploadupload zuto S3/Hetzner Storage Box.