Backup + Migration
❓
IchIhabeinstalled BookStackpervia Dockerinstalliert(wieas indertheAnleitungguide).KannstCouldduyoumirpleasebitteexplainerklären,howwietoichcreateBackups erstellebackups (vollständigefullInhaltssicherung)content backup) so that I can migrate the website if needed, e.g.,sodasstoichanotherdie Website bei Bedarf z.B. zu einem anderen Server/Domain umziehen kann?server/domain?HierHereistisdieBookStack’soffizielleofficialAnleitung 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:
DatenbankDatabase (alleallSeiten,pages,Bücher,books,Nutzer,users,Rechte,permissions,Einstellungensettings …)Dateien/ConfigFiles/config (Uploads,uploads,Anhänge,attachments,.env/APP_KEY,ggf.possiblyThemes/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)
InhaltThestecktcontentim DB-Container,is indeinemtheSetupDBdauerhaftcontainer,unter:and in your setup it’s persisted under:./mariadb(alsasVolumevolume./mariadb:/config)
SaubersterCleanestWegapproach:SQL-DumpSQL dump (portabel,portable,versionstolerant)tolerant across versions)
2) DateienFiles (BookStack-Container-Volume)BookStack container volume)
PersistentePersistentDatendataliegenisbeilocateddir unter:under:./bookstack(alsasVolumevolume./bookstack:/config)
DarinInsindit,insbesondereespeciallywichtig:important:.env(inkl.including APP_KEY!)Uploads/Attachmentsuploads/attachmentsggf.possiblywww/themes/custom/...(deineyourHacks/Module)hacks/modules)
3) Compose/Caddy (fürhelpful denfor Umzug hilfreich)migration)
docker-compose.ymlCaddyfileCaddy-DatenCaddy data optional:./caddy/data&./caddy/config(Zertifikate/State)certificates/state).
NichtNotzwingendstrictlynötigrequired,aberbutspartsometimesmanchmalsavesRe-Issue/Rate-Limits.re-issuing/rate limits.
🗂️ BackupCreate erstellena backup (empfohlenesrecommended Vorgehen)approach)
Annahme:Assumption:Projektprojectliegtis located in/opt/bookstackundanddietheContainercontainersheißenarewienamed as indeineryour YAML:
bookstack-mariadbundandbookstack.
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,saferweilbecausePasswortthenichtpassword won’t end up indershellShell-History landet)history):
LassOmit-p...,weg, dann fragtthenmysqldumpinteraktivwillnachpromptdeminteractivelyPasswort: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
derofneuentheDomainnewzeigtdomainaufpointsdentoneuentheServernew 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äufigcommonbeiwith linuxserver/bookstack)oderor./bookstack/.env(jedependingnachonImage/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..
AchtePaydarauf:attention:DieTheAPP_KEYmussmustdieremainaltethebleibenold one (sonstotherwisegehenencryptedu.a.dataverschlüsseltewillDatenbreak,kaputt,e.g.,z.MFAB. MFA-Secrets)secrets).
2) BookStack-Command:BookStack „command: “Update System URL“URL”
DamitSo Inhalte/Linksthat content/links in derthe DB sauberare umgeschriebenrewritten werden:cleanly:
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 offsitespeichern(another(anderes System/Storage)system/storage). -
Datenbank-DumpDatabase dump +Datei-Archivefile archiveistisamtheportabelsten.most portable. -
WennIfduyou restore to aaufnewereineBookStackneuere BookStack-Versionversionwiederherstellst::-
Restore DB
-
ContainerBringhochcontainers up -
DannThenMigrationrunlaufen lassenmigrations (fallsifnö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:
LiegtIsdeineyour.envunterlocated atbookstack/www/.env?WieWhatheißenaredeineyourContainercontainerswirklichactually named (docker ps-Auszug)output)?WillstDoduyouCaddy-Zertifikatewantmitsicherntooderbacklieberupnicht?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.