Skip to content

Instantly share code, notes, and snippets.

@danilodorgam
Last active September 6, 2019 21:30
Show Gist options
  • Save danilodorgam/40e5f59d04c23fb019ebc52b39dc02d5 to your computer and use it in GitHub Desktop.
Save danilodorgam/40e5f59d04c23fb019ebc52b39dc02d5 to your computer and use it in GitHub Desktop.
faz backup de todos os bancos de dados (individualmente) em formato .sql
#!/bin/bash
echo "Digite um user de banco de dados valido:"
read USER;
echo "Digite uma senha valida para o user"
read PASSWORD;
databases=`mysql -u $USER -p$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`
for db in $databases; do
if [ "$db" != "information_schema" ] && [ "$db" != "performance_schema" ] && [ "$db" != "mysql" ] && [ "$db" != _* ] ; then
echo "Dumping database: $db"
mysqldump -u $USER -p$PASSWORD --databases $db > `date +%Y%m%d`.$db.sql
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment