Skip to content

Instantly share code, notes, and snippets.

@felipsmartins
Last active January 3, 2019 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felipsmartins/a10ee16893181ce1a0dd74a4b3993a8a to your computer and use it in GitHub Desktop.
Save felipsmartins/a10ee16893181ce1a0dd74a4b3993a8a to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
HOST=127.0.0.1
USER=root
PASSWD=root
OUTPATH=./
# backup de base dados
DATABASES="
database1
database2
database3"
# total databases
echo $DATABASES | wc -w > /tmp/count.txt
total=`cat /tmp/count.txt`
index=1
for DATABASE in $DATABASES; do
echo "[$index/$total] Realizando backup de ${DATABASE} ...";
/usr/bin/mysqldump $DATABASE --user=$USER -p$PASSWD --host=$HOST --result-file="$OUTPATH/${DATABASE}.sql"
index=$(($index+1))
done
echo
echo "Terminado!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment