Created
July 23, 2014 05:18
-
-
Save joneszach/ba7ac9651cddf5146dc7 to your computer and use it in GitHub Desktop.
Simple MySQLdump script for keeping a single compressed sql backup. sloppy, assumptious.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USERNAME=dbuser | |
PASSWORD=examplepassword | |
DBHOST=127.0.0.1 | |
DBNAME=singledbname | |
OPTIONS="--single-transaction --quick" | |
BACKUPDIR="/full/path/to/store/backup" # No trailing slash | |
# we want to make sure our new files are created only readable by owner | |
umask 077 | |
/usr/bin/mysqldump -h $DBHOST -u $USERNAME -p$PASSWORD $OPTIONS $DBNAME | gzip > $BACKUPDIR/$DBNAME.inprogress.sql.gz | |
mv $BACKUPDIR/$DBNAME.inprogress.sql.gz $BACKUPDIR/$DBNAME.latest.sql.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment