Created
June 19, 2013 11:36
-
-
Save naxIO/5813620 to your computer and use it in GitHub Desktop.
Simple mysql dump shell script, that uses the actual date for the file. Works with crontab! (Date escaped). Note that there is no space between the -p and the password.
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 | |
NOW=`/bin/date +"%m%d%Y-%H%M%S"` | |
if [[ "$?" != "0" ]]; then | |
NOW="UNKNOWN_DATE" | |
fi | |
mysqldump -h hostname -u username -pPassword databasename > /opt/databasebackup/$NOW.sql | |
if [[ "$?" != "0" ]]; then | |
echo "$0: backup failed with error code $?" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment