Created
July 18, 2012 13:54
-
-
Save hpatoio/3136349 to your computer and use it in GitHub Desktop.
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 | |
BACKUP="/path/to/temp/dir/$$" | |
DAY=$(date +"%a") | |
### MySQL Setup ### | |
MUSER="root" | |
MPASS="your_root_password" | |
MHOST="localhost" | |
MYSQL="$(which mysql)" | |
MYSQLDUMP="$(which mysqldump)" | |
GZIP="$(which gzip)" | |
### FTP server Setup ### | |
FTPUSER="ftp_username" | |
FTPPASS="ftp_password" | |
FTPHOST="ftp_host" | |
mkdir -p $BACKUP | |
### Start MySQL Backup ### | |
# Get all databases name | |
DBS="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')" | |
for db in $DBS | |
do | |
FILE=$BACKUP/$(date +"%a")-$db.gz | |
$MYSQLDUMP -u $MUSER -h $MHOST -p$MPASS $db | $GZIP -9 > $FILE | |
echo "Saving "$db" to "$FILE | |
done | |
### Dump backup using FTP ### | |
echo "Sending file via FTP" | |
ftp -ni $FTPHOST > /tmp/ftp.worked 2 > /tmp/ftp.failed <yourmail@yourdomain.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment