Skip to content

Instantly share code, notes, and snippets.

@tieutantan
Created October 10, 2018 03:58
Show Gist options
  • Save tieutantan/c947e66f8f024042f76b2dbe8214d107 to your computer and use it in GitHub Desktop.
Save tieutantan/c947e66f8f024042f76b2dbe8214d107 to your computer and use it in GitHub Desktop.
Shell Script Backup Mysql Database
#!/bin/sh
DUMPFILE=/home/thisisusername/backups/db-`date +%Y-%m-%d-%H-%M`.sql.gz
mysqldump -uthisisusername -p'ZjOGUxPass' -hlocalhost database_name --force --triggers --single-transaction --opt --skip-lock-tables | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | gzip -9 -c > $DUMPFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment