Skip to content

Instantly share code, notes, and snippets.

@narwanimonish
Forked from amitavroy/Database automate
Created March 24, 2020 06:01
Show Gist options
  • Save narwanimonish/d64d8d018b9fb69806469f35ca8b6817 to your computer and use it in GitHub Desktop.
Save narwanimonish/d64d8d018b9fb69806469f35ca8b6817 to your computer and use it in GitHub Desktop.
#!/bin/bash
# declare an array called array and define 3 vales
databases=( drupal fresh lasalle_wp_fts )
username=root
password=password
filepath=/home/amitavroy/code/backup
for i in "${databases[@]}"
do
filename=${i}_$(date +"%m%d%Y-%k%M")
mysqldump -u${username} -p${password} ${i} > ${filepath}/${filename}.sql
tar -zcf ${filepath}/${filename}.tar.gz ${filepath}/${filename}.sql
rm ${filepath}/${filename}.sql
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment