BookStack Backup
Here's a script for backing up everything you need in the event you want to rebuild the jail and bring the existing BookStack data to the new jail.
It takes no arguments. You simply set the correct variables inside, and it just works™. Here's how:
- It checks whether the root backup directory exists. If it doesn't, it creates it.
- It checks whether the subdirectory (based on the date) exists. If it doesn't, it creates it.
- It
cd
's to where you'll temporarily store the database dump (after making sure it exists). - It dumps the database into a file of the name you specify (which isn't important).
- It
cd
's to the subdirectory where the backup files will be saved. - It checks whether the dump file already exists (in case you already backed up today).
- If you didn't already back up today, it moves the db dump there.
- If you did already back up, it prepends a count to the file name first, as to not overwrite the previous.
- Next, it
cd
's into the BookStack directory andtar
s the remaining files and directories. - Lastly, it copies the
tar
ed file to the backup subdirectory.
Before implementing this script, we need to set up the backup directory.
zfs create -o compress=lz4 -o atime=off zroot/data/backups
zfs create -o compress=lz4 -o atime=off zroot/data/backups/bookstack