Advertisement
Guest User

Untitled

a guest
May 20th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #!/bin/bash
  2. #Author: Luca Limardo
  3. #Purpose: Backup Mysql
  4. #Date: 2014-02-19
  5.  
  6. DBUSER="user"
  7. DBPASS="password"
  8. BKPDIR=/path
  9. NOW=$(date +%Y-%m-%d)
  10. DAY=$(date +%a)
  11. TMP=bkp.mysql.$NOW.$DAY
  12.  
  13. DATABASES=$(/usr/bin/mysql --user=$DBUSER --password=$DBPASS -e "SHOW DATABASES;" | tr -d "| " | grep -v Database)
  14.  
  15. rm -rf $BKPDIR/*.$DAY
  16. mkdir $BKPDIR/$TMP
  17.  
  18. for DB in $DATABASES
  19. do
  20. /usr/bin/mysqldump --force --opt --user=$DBUSER --password=$DBPASS --databases $DB > $BKPDIR/$TMP/$DB.sql
  21. echo $DB
  22. done
  23.  
  24. wait
  25.  
  26. tar -czf $BKPDIR/bkp.mysql.$NOW.$DAY.tar.gz $BKPDIR/$TMP/*.sql
  27. #echo "Zip"
  28.  
  29. wait
  30.  
  31. rm -rf $BKPDIR/$TMP
  32. #echo "Rimuovo"
  33.  
  34. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement