Created
May 26, 2020 09:12
-
-
Save alexwybraniec/baaec7116232b000f0ad03841b88e515 to your computer and use it in GitHub Desktop.
Bash script of backing up multiple dbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
_dbusername="my_backup_username" | |
_dbpassword="my_backup_password" | |
_output="/home/dbbackup/_database_backups" | |
_dow="$(date +'%A')" | |
declare -a arr=("my_db_1" "my_db_2" "my_db_3") | |
for i in "${arr[@]}" | |
do | |
echo "$i" | |
_daily="${i}_${_dow}.sql" | |
rm -f $_daily | |
rm -f ${i}_latest.sql | |
mysqldump --hex-blob -u${_dbusername} -p${_dbpassword} ${i} > ${_output}/${_daily} | |
cp ${_output}/${_daily} ${_output}/${i}_latest.sql | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment