Quick simple script for automated database dumps

Anurag Bhatia
I tried looking for script for database dumps but most of them are way too complex then a simple solution one can implement. Thus, I wrote a quick simple 1 page (infact few lines) bash script for database dumps. Here’s the code: #!/bin/bash #Script for MySQL automated dumps dbhost=DB-HOSTNAME-HERE dbusername=DB-USERNAME-HERE dbpassword=DB-PASSWORD-HERE # Enter database names here dbname=( database1 database2 database3 ) for i in "${dbname[@]}" do timestamp=backup_`date +%F.%T` output=$i+$timestamp mysqldump -h $dbhost -u $dbusername -p$dbpassword -C $i | bzip2 -c > /backups/MySQL-automated/$output done To use this script, simply add names of database inside brackets in front of “dbname” like