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