Skip to content

Instantly share code, notes, and snippets.

@rafaelstz
Last active August 29, 2015 14:01
Show Gist options
  • Save rafaelstz/922c5b9cdf63ec50a154 to your computer and use it in GitHub Desktop.
Save rafaelstz/922c5b9cdf63ec50a154 to your computer and use it in GitHub Desktop.
Backup do Banco via ShellScript
#
# script by [email protected]
#
echo "Digite seu dns";
read host;
echo "Digite seu user";
read user;
echo "Digite seu pass";
stty -echo
read pass;
echo "Digite a base que deseja executar o backup";
stty echo
read base;
echo "Voce deseja [I]mportar ou [E]xportar";
read typi;
if [ $typi = "E" ]
then
mysqldump -h $host -u $user -p$pass $base > $base"_backup.sql";
if [ -e $base"_backup.sql" ]
then
echo "Seu arquivo foi criado com sucesso em: " `pwd`"/"$base"_backup.sql";
else
echo "Houve algum problema";
fi
else
echo "Digite o caminho completo do seu aquivo SQL";
read filename;
if [ -e $filename ]
then
mysql -h $host -u $user -p$pass $base < $filename;
echo "Import efetuado com sucesso";
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment