SHARE
TWEET

Untitled

a guest Aug 10th, 2016 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. function iniciarBackup(){
  4.     echo "Iniciando backup..."
  5.  
  6.     MYSQLDUMP="$(which mysqldump)"
  7.     $MYSQLDUMP -u $DBUSER -h $DBHOST -p$DBPASS $DBNAME | gzip > $TIMESTAMP.sql.gz
  8.  
  9.     ssh $USER_SSH@$HOST_SSH "tar -zcf - $HOME" > $TIMESTAMP.backup.tar.gz
  10.     tar -zcf $TIMESTAMP.tar.gz $TIMESTAMP.backup.tar.gz $TIMESTAMP.sql.gz
  11.  
  12.     return 0
  13. }
  14.  
  15. function deletarArquivos(){
  16.     rm "$TIMESTAMP.sql.gz"
  17.     rm "$TIMESTAMP.backup.tar.gz"
  18. }
  19.  
  20.  
  21. iniciarBackup
  22.  
  23. while true ; do
  24.    if [ $? -eq 0 ]; then
  25.      echo "Operação de backup concluída!"
  26.      read -p "Você deseja deletar os arquivos agora? [S/N]" resposta
  27.      case $resposta in
  28.         [Ss]* ) deletarArquivos; break;;
  29.         [Nn]* ) exit;;
  30.         * ) echo "Por favor responda a pergunta! [S/N]";;
  31.     esac
  32.    fi
  33. done
  34.  
  35. echo "Fim do script."
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top