Local Backups
Local backups are performed via cronjobs configured on a per server basis, depending on the files & databases required.
BookStack Backups
Database backups are performed using the mysqldump command, and using a dedicated 'backup' mysql user, with read only privilege:
##CREATE MySQL Backups User##
CREATE USER 'backup'@'localhost' IDENTIFIED BY 'password';
##GRANT Privilege to Backup User##
GRANT SELECT ON *.* TO 'backup'@'localhost';
##pull in update mysql user privilege
flush privileges;
##Give MySQL default mysqldump user options##
vim /root/.my.cnf
[mysqldump]
user=bookstack
password=password
##restart mysql##
systmctl restart mysql
##Cronjob for backups to run##
crontab -e
0 23 * * * DATE=`date +%y-%m-%d`; mysqldump -u backup bookstack --no-tablespaces | gzip > /bookstack-backups/database/bookstack-$DATE.sql.gz | rsync -a /bookstack-backups/database/bookstack-$DATE.sql.gz [email protected]:/backups/bookstack/database | find /bookstack-backups/database -name "*.gz" -type f -mtime +7 -delete
File level backups are performed using the tar command, the zipped file is then transferred to the remote backup server via rsync:
DATE=`date +%y-%m-%d`;tar -aP -cf /bookstack-backups/file/bookstack_file-$DATE.gz /var/www/BookStack |rsync -a /bookstack-backups/file/bookstack_file-$DATE.gz [email protected]:/backups/bookstack/file | find /bookstack-backups/file -name "*.gz" -type f -mtime +7 -delete
No Comments