Last active
August 29, 2015 14:10
-
-
Save ahmadshah/efa68e75b0c26f08ea93 to your computer and use it in GitHub Desktop.
MySQL full backup
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/bash | |
#Database Connection | |
DBUSER="" | |
DBPASSWORD="" | |
DBNAME="" | |
#Location to save | |
BACKUPDIR="/opt/backup/database" | |
BACKUPPATH=$(date +"%m-%Y") | |
DATE=$(date +"%Y-%m-%d") | |
if [[ ! -d $BACKUPDIR/$BACKUPPATH ]]; then | |
mkdir -p $BACKUPDIR/$BACKUPPATH | |
fi | |
mysqldump --user=$DBUSER --password=$DBPASSWORD $DBNAME | bzip2 > $BACKUPDIR/$BACKUPPATH/$DBNAME-$DATE.sql.bz2 | |
echo "$DBNAME-$DATE successfully backup" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment