/mysqlhourlybackup

Simple bash script to take an hourly encrypted backup.

Primary LanguageShellGNU General Public License v3.0GPL-3.0

Simple bash script to take an encrypted mysql backup hourly.

Installation.

$ cp mysqlhourlybackup.sh /usr/local/bin && chmod +x /usr/local/bin/mysqlhourlybackup.sh

Edit the variables

nano /usr/local/bin/mysqlhourlybackup.sh
  • set MYSQL_USER
  • set MYSQL_PASSWORD
  • set MYSQL_HOST
  • set ENCRYPTPASSWORD

Open Crontab and setup new hourly job.

crontab -e

00 * * * * /usr/local/bin/mysqlhourlybackup.sh >/dev/null 2>&1

Details on how to unencrypt the backups.

openssl enc -aes-256-cbc -d -in *dbname.enc* -out database.gz -pass pass:*encryptionpassword*  && gunzip -c database.gz > *dbname.sql*