Backup mySQL with BASH

10 Oct 2011

Simple BASH script to backup mySQL database and save it encrypted

DATE=$(date +%s)
mysqldump -u root --all-databases --hex-blob --complete-insert -p > backup.sql > $BACKUPFILEZ
gpg --encrypt $BACKUPFILEZ

Note: This script stil needs you to manually enter database password and what public key to use for encryption (this can easily be added to the script). Also I recommend that you save the backups externally (and not in “/backup”), and for this I would recommend “scp”.

blog comments powered by Disqus