Advertisement
ecuageek

Backup MySql All separated DBs

Aug 23rd, 2018
862
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. USER="root"
  4. PASSWORD="Password_Aqui"
  5. UNIDAD_REMOTA=/mnt/nas
  6. DIR_TEMP=/root/respaldomysql/
  7. echo Db Variables OK!
  8. cd $DIR_TEMP
  9. #Empieza a sacar respaldos
  10. databases=`mysql -u $USER -p$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`
  11. for db in $databases; do
  12.     if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != "mysql" ]] && [[ "$db" != _* ]] ; then
  13.         echo "Dumping database: $db"
  14.         mysqldump --defaults-file=/root/.udb.cnf --user $USER --databases $db > `date +%Y%m%d`.$db.sql
  15.         echo Dbs Exportadas!
  16.         gzip $OUTPUT/`date +%Y%m%d`.$db.sql
  17.         echo y Comprimidos!
  18.     fi
  19. done
  20. #TerminaDeHacerRespaldos
  21. mount 192.168.10.29:/volume1/EPMAPASD_BDDS $UNIDAD_REMOTA
  22. echo Unidad montada!
  23. mv *.gz $UNIDAD_REMOTA/SEGPRO/
  24. echo Copiado a unidad remota!
  25. umount $UNIDAD_REMOTA
  26. echo Desmontado!
  27. rm -rf $DIR_TEMP*.gz
  28. echo Carpeta temporal limpia!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement