Bookstack-Backup/bookstack-backup.sh

27 lines
737 B
Bash

#!/bin/bash
date=$(date +"%d-%m-%Y@%H-%M")
# Settings
backup_path=/backups/BookStack/
rclone_backup_path=systems-sharepoint:Systems/Backups/BookStack/
mysql_user=root
mysql_pass=YOURPASSWORDHERE
cd $backup_path
mkdir database
# Dump the MariaDB database
mysqldump -u=$mysql_user -p=$mysql_pass bookstackdb > $backup_path/database/bookstack_db.sql
# Compress the SQL dump and the BookStack files
tar zcvf bookstack_backup_$date.tar.gz $backup_path/database /var/www/BookStack
# Delete temporary .sql
rm -rf $backup_path/database/bookstack_db.sql
# Delete backups older than 7 days
find $backup_path -type f -mtime +7 -name '*.gz' -delete
# Add your desired rclone options below
rclone sync $backup_path*.tar.gz $rclone_backup_path