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';
##Cronjob for backups to run
DATE=`date +%y-%m-%d`; mysqldump -u root -p bookstack | 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 +30 -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 +30 -delete