Advertisement
Guest User

Untitled

a guest
Apr 26th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. DB_host="localhost"
  4. DB_user=""
  5. DB_pass=""
  6. DB="nzedb"
  7. DIR=$DB
  8. DB_FULL=`mysql --user=$DB_user -p$DB_pass -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema)"`
  9.  
  10. [ -n "$DIR" ] || DIR=.
  11. test -d $DIR || mkdir -p $DIR
  12.  
  13. echo
  14. echo "Dumping tables into separate SQL command files for database '$DB"
  15.  
  16. tbl_count=0
  17.  
  18. for t in $(mysql -NBA -h $DB_host -u $DB_user -p$DB_pass -D $DB -e 'show tables' |grep -v binaries_ |grep -v partrepair_ |grep -v parts_ |grep -v collections_*)
  19. do
  20. # echo "DUMPING TABLE: $t"
  21. mysqldump --opt --single-transaction --quick -h $DB_host -u $DB_user -p$DB_pass --routines $DB $t | gzip --rsyncable > $DIR/$t.sql.gz
  22. (( tbl_count++ ))
  23. done
  24.  
  25.  
  26. echo "$tbl_count tables dumped from database '$DB'"
  27.  
  28. echo
  29. echo "Dump Started on $DB_FULL"
  30.  
  31. for db_full in $DB_FULL; do
  32. echo "$db_full backing up"
  33. mysqldump --opt --single-transaction --quick --user=$DB_user -p$DB_pass --routines --databases $db_full | gzip --rsyncable > "$db_full.gz"
  34. echo "Finished up $db_full"
  35. done
  36.  
  37. echo "Completed mysqldump"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement