SHARE
TWEET

Untitled

a guest Jun 12th, 2019 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # buat folder /home/bin
  2. # chmod +x script.sh
  3. # export PATH=$PATH:/home/bin
  4. #
  5.  
  6. #!/bin/bash
  7.  
  8. USER="root"
  9. PASSWORD=""
  10. OUTPUT="/var/www/html/backupmysql"
  11.  
  12. #rm "$OUTPUTDIR/*gz" > /dev/null 2>&1
  13.  
  14. databases=`mysql -u $USER -p$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`
  15.  
  16. for db in $databases; do
  17.     if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != "mysql" ]] && [[ "$db" != _* ]] ; then
  18.         echo "Dumping database: $db"
  19.         mysqldump -u $USER -p$PASSWORD --databases $db > $OUTPUT/`date +%Y%m%d`.$db.sql
  20.        # gzip $OUTPUT/`date +%Y%m%d`.$db.sql
  21.     fi
  22. done
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
 
Top