Created
September 1, 2015 07:54
-
-
Save forkbombe/bc5fdc0db19b912a7d5b to your computer and use it in GitHub Desktop.
Automated backup of MySQL database via cron
This file contains 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/sh | |
USER=$1 | |
PASS=$2 | |
DB=$3 | |
HOST='' | |
DATE=`date +"%Y%m%d"` | |
cd ~/db-daily | |
mysqldump -u $USER -p$PASS -h $HOST $DB | gzip > $DB.sql.gz |
This file contains 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
# Run backup.sh from home directory every day at 3am | |
0 3 * * * bash ~/backup.sh DATABASEUSER DATABASEPASS DATABASENAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment