Guest User

Untitled

a guest
Oct 20th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. OUTPUTDIR=./
  4. DBUSER=root
  5. DBHOST=localhost
  6.  
  7. # Backups all databases using mysqldump to current directory with datestamp in filename
  8. function backup_all_databases {
  9. DB_FILE="all-data-`date +"%F-%H%M"`.sql"
  10. mysqldump -u ${DBUSER} -h ${DBHOST} --all-databases > ${OUTPUTDIR}${DB_FILE}
  11. if [ -f ${OUTPUTDIR}${DB_FILE} ]; then
  12. tar -zcvf ${OUTPUTDIR}${DB_FILE}.tar.gz ${OUTPUTDIR}${DB_FILE}
  13. rm -rf ${OUTPUTDIR}${DB_FILE}
  14. fi
  15. }
  16.  
  17. backup_all_databases
Add Comment
Please, Sign In to add comment