Commit 82870d5b by sn

log

1 parent aca53ec1
......@@ -7,3 +7,4 @@ __BASEPATH_EX=$__THIS_DIR
# __PATH_to_mcBash=$__BASEPATH_EX'include/Lib/Tools/mcBash/'
__PATH_to_mcBash=$__BASEPATH_EX
__PATH_to_Temp=$__PATH_to_mcBash'Temp'
__PATH_to_Log=$__PATH_to_mcBash'/log'
\ No newline at end of file
......@@ -6,3 +6,4 @@ __BASEPATH_EX='/home/dev/mcBash/'
# __PATH_to_mcBash=$__BASEPATH_EX'include/Lib/Tools/mcBash/'
__PATH_to_mcBash=$__BASEPATH_EX
__PATH_to_Temp=$__PATH_to_mcBash'Temp'
__PATH_to_Log=$__PATH_to_mcBash'/log'
\ No newline at end of file
......@@ -7,3 +7,4 @@ __BASEPATH_EX=$__THIS_DIR'../'
# __PATH_to_mcBash=$__BASEPATH_EX'include/Lib/Tools/mcBash/'
__PATH_to_mcBash=$__BASEPATH_EX
__PATH_to_Temp=$__PATH_to_mcBash'Temp'
__PATH_to_Log=$__PATH_to_mcBash'/log'
......@@ -9,6 +9,7 @@
. "$__PATH_to_mcBash/include.inc.sh"
execute=1
logfile="$__PATH_to_Log/$1.log"
mc_h1 $0 $1 $2
mc_parameter "1" "1" "$1" "mysql Datenbank (muss vorhanden sein)"
......@@ -16,6 +17,7 @@ mc_parameter "2" "0" "$2" "Datenbankbenutzer (default root)"
mc_parameter "3" "0" "$3" "Datenbankpasswort "
if [ -z $2 ] ; then
user='root'
else
......@@ -32,6 +34,6 @@ fi
DATETIME=$(date +"%Y%m%d_%H%M%S")
BACKUPFILE="mysql.$1.$DATETIME.sql"
mc_bashsu "mysqldump --single-transaction --default-character-set=utf8 -u $user $password $1 > $BACKUPFILE " $execute
mc_bashsu "tar -czf $BACKUPFILE.tar.gz $BACKUPFILE" $execute
mc_bashsu "rm $BACKUPFILE" $execute
mc_bashsu "mysqldump --single-transaction --default-character-set=utf8 -u $user $password $1 > $BACKUPFILE " $execute $logfile
mc_bashsu "tar -czf $BACKUPFILE.tar.gz $BACKUPFILE" $execute $logfile
mc_bashsu "rm $BACKUPFILE" $execute $logfile
#!/bin/bash
#
# @param string $1 string to log
# @param string $2 logfile (FILE exists and is writable)
#
mc_log() {
if [ -w $2 ] ; then
echo "$(date +"%Y%m%d_%H%M%S") $1" >> $2
fi
}
mc_h1() {
echo -e '\n###############'
echo -e "$1"
echo -e '###############'
}
mc_h2() {
echo -e "\n$1"
echo -e '###############'
}
#
# @param string $1 string to print (echo)
# @param string $2 logfile (FILE exists and is writable)
#
mc_e() {
echo -e "\n$1"
mc_log $1 $2
}
#
# Funktion zur Ausgabe von bash Befehlen
# @param string $1 - Parameter wird im bash Format ausgegeben
# @param bool $2 - wenn $2=1 dann wird $1 ausgeführt
# @param string $3 - logfile, wenn dann wird befehl zusaetzlich in logfile geschrieben (FILE exists and is writable)
#
mc_bashsu() {
echo -e "# $1"
......@@ -13,6 +44,9 @@ mc_bashsu() {
eval $1
fi
fi
mc_log $1 $3
}
#
......@@ -32,17 +66,3 @@ mc_mysql () {
mc_bashsu "rmdir mc_mysql_tmp" 1
}
mc_h1() {
echo -e '\n###############'
echo -e "$1"
echo -e '###############'
}
mc_h2() {
echo -e "\n$1"
echo -e '###############'
}
mc_e() {
echo -e "\n$1"
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!