Bookstack-Backup/bookstack-backup.sh

26 lines
666 B
Bash
Raw Normal View History

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 00:47:47 +00:00
2021-05-07 01:02:00 +00:00
# Dump the MariaDB database
2021-05-07 01:05:56 +00:00
mysqldump -u $mysql_user -p $mysql_pass bookstack > bookstack_db.sql
2021-05-07 01:02:00 +00:00
# Compress the SQL dump and the BookStack files
tar cvf bookstack_backup_$date.tar.gz bookstack_backup.sql /var/www/BookStack
# Delete temporary .sql
rm -rf bookstack_db.sql
# 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:05:56 +00:00
rclone sync $backup_path $rclone_backup_path