Setup

Bookstack is one of the best selfhosted ‘wiki’ sites and it is dead easy to setup. Bookstack uses a mysql container to store the data and a webcontainer to have the site on. I like to keep my sql containers seperate and se we change the default port from 3306 to 3311. This is just random, but i normally start my sql containers at 3310 and then work my way up.

version: "3"                                                           

services:                                                              
  bookstack_app:                                                       
    container_name: bookstack_app                                      
    image: solidnerd/bookstack:latest                                  
    environment:                                                       
      - DB_HOST=bookstack_db:3306                                      
      - DB_DATABASE=bookstack                                          
      - DB_USERNAME=bookstack                                          
      - DB_PASSWORD=<dbpassword>                                       
    volumes:                                                           
      - ${PWD}/uploads:/var/www/bookstack/public/uploads               
      - ${PWD}/storage-uploads:/var/www/bookstack/public/storage       
    depends_on:                                                        
      - bookstack_db                                                   
    labels:                                                            
      - "traefik.enable=true"                                          
      - "traefik.frontend.rule=Host:bookstack.domain.com"         
  bookstack_db:                                                        
    container_name: bookstack_db                                       
    image: mysql:latest                                                
    ports:                                                             
      - 3311:3306                                                      
    environment:                                                       
      - MYSQL_ROOT_PASSWORD=<rootpassword>                               
      - MYSQL_DATABASE=bookstack                                       
      - MYSQL_USER=bookstack                                           
      - MYSQL_PASSWORD=<dbpassword>                                    
    volumes:                                                           
      - ${PWD}/mysql:/var/lib/mysql                                    
    labels:                                                            
      - "traefik.enable=false"                                         

networks:                                                              
  default:                                                             
      external:                                                        
        name: webproxy 

Backup

Bookstack just has the sql database and an upload and a storage folder. To back them up, i use a modified script from my Portainer post.

#!/bin/bash
NOW=$(date +"%Y%m%d-%H%M")
CURPATH='/home/<username>/Backup/bookstack'
echo $(/bin/mkdir -p "$CURPATH/$NOW")
echo $(/usr/bin/rsync -av --delete /home/<username>/Docker/bookstack/mysql/ "$CURPATH/$NOW")
echo $(/usr/bin/rsync -av --delete /home/<username>/Docker/bookstack/uploads/ "$CURPATH/$NOW")
echo $(/usr/bin/rsync -av --delete /home/<username>/Docker/bookstack/storage-uploads/ "$CURPATH/$NOW")