Skip to content

Instantly share code, notes, and snippets.

@seieric
Created March 24, 2020 00:04
Show Gist options
  • Save seieric/71d124195d66eaaf2ebb4666ce9e4ec9 to your computer and use it in GitHub Desktop.
Save seieric/71d124195d66eaaf2ebb4666ce9e4ec9 to your computer and use it in GitHub Desktop.
MySQL backup script
#!/bin/sh
databases=("aaaaaaaaa" "xxxxxxx")
passwords=("qwerty" "asdfgh")
i=0
for database in ${databases[@]}
do
time=`date +%Y%m%d%H%M%S`
output_path="/home/user/_db_dump/mysql.${database}.${time}.dump"
/usr/bin/mysqldump ${database} -u ${database} --password=${passwords[i]} > ${output_path}
let i++
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment