Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- OUTPUTDIR=./
- DBUSER=root
- DBHOST=localhost
- # Backups all databases using mysqldump to current directory with datestamp in filename
- function backup_all_databases {
- DB_FILE="all-data-`date +"%F-%H%M"`.sql"
- mysqldump -u ${DBUSER} -h ${DBHOST} --all-databases > ${OUTPUTDIR}${DB_FILE}
- if [ -f ${OUTPUTDIR}${DB_FILE} ]; then
- tar -zcvf ${OUTPUTDIR}${DB_FILE}.tar.gz ${OUTPUTDIR}${DB_FILE}
- rm -rf ${OUTPUTDIR}${DB_FILE}
- fi
- }
- backup_all_databases
Add Comment
Please, Sign In to add comment