mirror of
https://github.com/DoTheEvo/selfhosted-apps-docker
synced 2024-11-10 19:10:48 +00:00
update
This commit is contained in:
parent
abd2c15287
commit
c5d93d4ee9
@ -10,7 +10,7 @@ Documentation and notes.
|
|||||||
|
|
||||||
* [Official site](https://www.bookstackapp.com/)
|
* [Official site](https://www.bookstackapp.com/)
|
||||||
* [Github](https://github.com/BookStackApp/BookStack)
|
* [Github](https://github.com/BookStackApp/BookStack)
|
||||||
* [DockerHub image used](https://hub.docker.com/r/linuxserver/bookstack)
|
* [DockerHub](https://hub.docker.com/r/linuxserver/bookstack)
|
||||||
|
|
||||||
### Files and directory structure
|
### Files and directory structure
|
||||||
|
|
||||||
@ -21,7 +21,6 @@ Documentation and notes.
|
|||||||
└── bookstack
|
└── bookstack
|
||||||
├── 🗁 bookstack-data
|
├── 🗁 bookstack-data
|
||||||
├── 🗁 bookstack-data-db
|
├── 🗁 bookstack-data-db
|
||||||
├── 🗁 bookstack-backup
|
|
||||||
├── 🗋 .env
|
├── 🗋 .env
|
||||||
├── 🗋 docker-compose.yml
|
├── 🗋 docker-compose.yml
|
||||||
└── 🗋 bookstack-backup-script.sh
|
└── 🗋 bookstack-backup-script.sh
|
||||||
@ -103,9 +102,9 @@ Documentation and notes.
|
|||||||
MYSQL_PASSWORD=bookstack
|
MYSQL_PASSWORD=bookstack
|
||||||
```
|
```
|
||||||
|
|
||||||
### reverse proxy
|
### Reverse proxy
|
||||||
|
|
||||||
caddy v2 is used,
|
Caddy v2 is used,
|
||||||
details [here](https://github.com/DoTheEvo/Caddy-v2-examples)
|
details [here](https://github.com/DoTheEvo/Caddy-v2-examples)
|
||||||
|
|
||||||
`Caddyfile`
|
`Caddyfile`
|
||||||
@ -121,18 +120,20 @@ Documentation and notes.
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### update
|
![logo](https://i.imgur.com/cN1GUZw.png)
|
||||||
|
|
||||||
* [watchguard]() updates the image automaticly
|
### Update
|
||||||
|
|
||||||
|
* [watchtower](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/watchtower) updates the image automaticly
|
||||||
|
|
||||||
* manual image update</br>
|
* manual image update</br>
|
||||||
`docker-compose pull`</br>
|
`docker-compose pull`</br>
|
||||||
`docker-compose up -d`</br>
|
`docker-compose up -d`</br>
|
||||||
`docker image prune`
|
`docker image prune`
|
||||||
|
|
||||||
### backup and restore
|
### Backup and restore
|
||||||
|
|
||||||
* **backup** using [borgbackup setup](https://github.com/DoTheEvo/docker-selfhosted-projects/tree/master/borg_backup)
|
* **backup** using [borgbackup setup](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/borg_backup)
|
||||||
that makes daily backup of the entire directory
|
that makes daily backup of the entire directory
|
||||||
|
|
||||||
* **restore**</br>
|
* **restore**</br>
|
||||||
@ -143,104 +144,50 @@ Documentation and notes.
|
|||||||
|
|
||||||
### Backup of just user data
|
### Backup of just user data
|
||||||
|
|
||||||
For additional peace of mind.
|
For additional peace of mind,
|
||||||
Having user-data daily exported using the [official procedure.](https://www.bookstackapp.com/docs/admin/backup-restore/)</br>
|
user-data daily exported using the [official procedure.](https://www.bookstackapp.com/docs/admin/backup-restore/)</br>
|
||||||
For bookstack it means database dump and the content of several directories
|
For bookstack it means database dump and backing up several directories containing user uploaded files.
|
||||||
containing user uploaded files.
|
The created backup files are overwriten on every run of the script,
|
||||||
The backup files are overwriten on every run of the script,
|
but borg backup is daily making snapshot of the entire directory.
|
||||||
but borg backup is backing entire directory in to snapshots, so no need for some keeping-last-X consideration.
|
|
||||||
|
|
||||||
* **database backup**</br>
|
* **create a backup script**</br>
|
||||||
script `make_backup.sh` placed in to `bookstack_db` container,
|
placed inside `bookstack` directory on the host
|
||||||
in to `/config` directory that is bind mounted to the host machine.</br>
|
|
||||||
made executable `chmod +x make_backup.sh` inside the container
|
|
||||||
|
|
||||||
- This script creates path `/config/backups-db`</br>
|
`bookstack-backup-script.sh`
|
||||||
- deletes all files in the backup path except 30 newest</br>
|
|
||||||
- creates new mysqldump using env variables passed from `.env` file</br>
|
|
||||||
|
|
||||||
`make_backup.sh`
|
|
||||||
```
|
```
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
# -----------------------------------------------
|
# CREATE DATABASE DUMP, sh -c '...' IS USED OTHERWISE OUTPUT > WOULD TRY TO GO TO THE HOST
|
||||||
NUMB_BACKUPS_TO_KEEP=30
|
docker container exec bookstack_db sh -c 'mysqldump -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE > $MYSQL_DIR/BACKUP.bookstack.database.sql'
|
||||||
BACKUP_PATH=/config/backups-db
|
|
||||||
BACKUP_NAME=$(date +"%s").bookstack.database.backup.sql
|
|
||||||
# -----------------------------------------------
|
|
||||||
|
|
||||||
mkdir -p $BACKUP_PATH
|
# ARCHIVE UPLOADED FILES
|
||||||
|
docker container exec bookstack tar -czPf /config/BACKUP.bookstack.uploaded-files.tar.gz /config/www/
|
||||||
cd $BACKUP_PATH
|
|
||||||
ls -tr | head -n -$NUMB_BACKUPS_TO_KEEP | xargs --no-run-if-empty rm
|
|
||||||
|
|
||||||
mysqldump -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE > $BACKUP_PATH/$BACKUP_NAME
|
|
||||||
```
|
```
|
||||||
|
|
||||||
* **files backup**</br>
|
the script must be executabe - `chmod +x bookstack-backup-script.sh`
|
||||||
script `make_backup.sh` placed in to `bookstack` container,
|
|
||||||
in to `/config` directory that is bind mounted to the host machine.</br>
|
|
||||||
made executable `chmod +x make_backup.sh` inside the container
|
|
||||||
|
|
||||||
- This script creates path `/config/backups-files`</br>
|
* **cronjob** on the host</br>
|
||||||
- deletes all files in the backup path except 30 newest</br>
|
`crontab -e` - add new cron job</br>
|
||||||
- creates new archive containing uploaded files</br>
|
`0 2 * * * /home/bastard/docker/bookstack/bookstack-backup-script.sh` - run it [at 02:00](https://crontab.guru/#0_2_*_*_*)</br>
|
||||||
|
`crontab -l` - list cronjobs
|
||||||
|
|
||||||
`make_backup.sh`
|
### Restore the user data
|
||||||
```
|
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# -----------------------------------------------
|
Assuming clean start, first restore the database before running the app container.
|
||||||
NUMB_BACKUPS_TO_KEEP=30
|
|
||||||
BACKUP_PATH=/config/backups-files
|
|
||||||
BACKUP_NAME=$(date +"%s").bookstack.files.backup.tar.gz
|
|
||||||
# -----------------------------------------------
|
|
||||||
|
|
||||||
mkdir -p $BACKUP_PATH
|
* start only the database container: `docker-compose up -d bookstack_db`
|
||||||
|
* have `BACKUP.bookstack.database.sql` mounted in
|
||||||
cd $BACKUP_PATH
|
* exec in to the container and restore the database</br>
|
||||||
ls -tr | head -n -$NUMB_BACKUPS_TO_KEEP | xargs --no-run-if-empty rm
|
`docker container exec -it bookstack_db /bin/bash`</br>
|
||||||
|
|
||||||
cd /config/www
|
|
||||||
tar -czvf $BACKUP_PATH/$BACKUP_NAME .env uploads files images
|
|
||||||
```
|
|
||||||
|
|
||||||
* **automatic periodic execution of the backup scripts**
|
|
||||||
|
|
||||||
Using cron running on the host machine that will execute scripts inside containers.
|
|
||||||
|
|
||||||
script `cron_job_do_backups.sh` inside `~/docker/bookstack`
|
|
||||||
|
|
||||||
`cron_job_do_backups.sh`
|
|
||||||
```
|
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
docker exec bookstack /config/make_backup.sh
|
|
||||||
docker exec bookstack_db /config/make_backup.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
`chmod +x cron_job_do_backups.sh` on the host machine
|
|
||||||
|
|
||||||
`crontab -e`
|
|
||||||
|
|
||||||
`0 2 * * * /home/bastard/docker/bookstack/cron_job_do_backups.sh`
|
|
||||||
|
|
||||||
### restore official way
|
|
||||||
|
|
||||||
* restore of the database
|
|
||||||
|
|
||||||
copy the backup sql dump file in to the bind mount `bookstack-data-db` directory
|
|
||||||
|
|
||||||
exec in to the container and tell mariadb to restore data from the copied file
|
|
||||||
|
|
||||||
`docker exec -it bookstack_db /bin/bash`</br>
|
|
||||||
`cd /config`</br>
|
`cd /config`</br>
|
||||||
`mysql -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE < 1584566634.bookstack.database.backup.sql`
|
`mysql -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE < BACKUP.bookstack.database.sql`
|
||||||
|
* now start both containers: `docker-compose up -d`
|
||||||
|
* let it run so it creates folder structure
|
||||||
|
* down the containers `docker-compose down`
|
||||||
|
* extract `BACKUP.bookstack.uploaded-files.tar.gz` and place directories `files` and `uploads` where they belong in the mounted volume
|
||||||
|
* start the containers: `docker-compose up -d`
|
||||||
|
* if there was a major version jump, exec in to the container and run `php artisan migrate`</br>
|
||||||
|
`docker container exec -it bookstack /bin/bash`</br>
|
||||||
|
`cd /var/www/html/`</br>
|
||||||
|
`php artisan migrate`
|
||||||
|
|
||||||
* restore of the files
|
|
||||||
|
|
||||||
copy the backup gz.tar archive in to bind mount `bookstack-data/www/` directory</br>
|
|
||||||
|
|
||||||
`docker exec -it bookstack /bin/bash`</br>
|
|
||||||
`cd /config/www`</br>
|
|
||||||
`tar -xvzf 1584566633.bookstack.files.backup.tar.gz`
|
|
||||||
|
Loading…
Reference in New Issue
Block a user