Created
November 19, 2014 05:34
-
-
Save briezler/2dc57b50a9f34d0ecb85 to your computer and use it in GitHub Desktop.
mysql 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
# Script saves TYPO3 Directory inclusive | |
# Database | |
# | |
# @param dbname | |
# @param dbuser | |
# @param dbpassword | |
# @param backupdir | |
# @param backupDir | |
# SET Variables | |
NOW="$(date +"%d-%m-%Y_%H-%M-%S")" | |
WEBROOT="/var/www/" | |
SAVE_DIRECTORY="/opt/backup/" | |
LOGFILE="/var/log/t3backup.log" | |
USER=who | |
DB_USER="" | |
DB_PASS="" | |
DB_NAME="" | |
BACKUPDIR="is sub of WEBROOT VAR" | |
#check if Backupdirectory exists | |
if [ ! -d "$WEBROOT/$BACKUPDIR" ]; then | |
echo "Verzeichnis existiert nicht!" | |
echo "Tried to backup non existent directory;$NOW" >> $LOGFILE | |
exit 2 | |
else | |
mysqldump -u $DB_USER -p$DB_PASS $DB_NAME > "$WEBROOT/$BACKUPDIR/$DB_NAME.$NOW.sql" | >> $LOGFILE | |
if [ "$?" -eq 0 ] | |
then | |
echo "$USER;MySQL Dump $BACKUPDIR/$DB_NAME.$NOW.sql erfolgreich erstellt;$NOW" >> $LOGFILE | |
exit 0 | |
else | |
# mysqldump couldn't be saved/created | |
echo "$USER;MySQL Dump $DB_NAME.$NOW.sql konnte nicht erstellt werden database.err gibt weitere Infos;$NOW" >> LOGFILE | |
exit 2 | |
fi | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment