Skip to content

Instantly share code, notes, and snippets.

@turbopixel
Last active September 26, 2016 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save turbopixel/be6e9199462b4d107ab8b36a709239f3 to your computer and use it in GitHub Desktop.
Save turbopixel/be6e9199462b4d107ab8b36a709239f3 to your computer and use it in GitHub Desktop.
MySQL Dump Cronjob
#!/bin/bash
# MySQL Console Dumper
# author: Nico Hemkes <www.nokes.de>
# date: 26.09.2016
# settings
user="USER"
pw="PASSWORD"
backupDir="/media/backup/"
today=$(date +"%m-%d-%Y")
filename="mysql_dump-$today.sql.gz"
# output start
printf "\n= = = MySQL Console Dumper = = ="
printf "\nstarting ...\n\n"
# dump
mysqldump -u"$user" -p"$pw" -Q --events --ignore-table=mysql.event --all-databases | gzip -9 > $backupDir$filename
# output end
printf "Backup placed at $backupDir$filename\n\n"
printf "done!\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment