Created
December 21, 2018 00:41
-
-
Save gchristofferson/6400d13aabcd605c7d312daf115be093 to your computer and use it in GitHub Desktop.
This script will make a backup of the database in the backup directory
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/sh | |
# This script will make a backup of the databases | |
username="<username>" | |
password="<password>" | |
host="<hostname>" | |
dbname="<database name>" | |
current_date=`date +"%Y-%m-%d-%T"` | |
file_name="$dbname""_""$current_date" | |
file_name="${file_name/:/}" | |
file_name="${file_name/:/}.sql" | |
echo $file_name | |
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" | |
if [[ $SCRIPTPATH != "/home/dh_mcbjqv/db_backup" ]] | |
then | |
echo "We are in the wrong directory" | |
echo "$( cd "$(dirname "$0")" ; pwd -P )" | |
echo "changing directories" | |
cd /home/dh_mcbjqv/db_backup | |
else | |
echo "We are in the right directory" | |
fi | |
echo $SCRIPTPATH | |
mysqldump --opt --user=$username --password=$password --host=$host $dbname > $file_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment