projects
/
matthijs
/
upstream
/
backupninja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add Chris Nolan to Authors for the maildir directory fix, and add
[matthijs/upstream/backupninja.git]
/
handlers
/
mysql.in
diff --git
a/handlers/mysql.in
b/handlers/mysql.in
index e1e89b0a29ccff24d5c8b025f4ece10d0462a940..3488c511becd6ecd8f247d4f2f476f9303d2fcbd 100644
(file)
--- a/
handlers/mysql.in
+++ b/
handlers/mysql.in
@@
-90,27
+90,33
@@
if [ "$dbusername" != "" -a "$dbpassword" != "" ]
then
if [ $usevserver = yes ]
then
then
if [ $usevserver = yes ]
then
- vhome=`$VSERVER $vsname exec getent passwd "root" | @AWK@ -F: '{print $6}'`
- home="$vroot$vhome"
+ home=`$VSERVER $vsname exec getent passwd "root" | @AWK@ -F: '{print $6}'`
else
home=`getent passwd "root" | @AWK@ -F: '{print $6}'`
fi
[ -d $home ] || fatal "Can't find root's home directory ($home)."
else
home=`getent passwd "root" | @AWK@ -F: '{print $6}'`
fi
[ -d $home ] || fatal "Can't find root's home directory ($home)."
-
+
mycnf="$home/.my.cnf"
mycnf="$home/.my.cnf"
- if [
-f $mycnf
]
+ if [
$usevserver = yes
]
then
then
- # rename temporarily
- tmpcnf="$home/my.cnf.disable"
- debug "mv $mycnf $tmpcnf"
- mv $mycnf $tmpcnf
+ workcnf="$vroot$mycnf"
+ else
+ workcnf="$mycnf"
fi
fi
+ if [ -f $workcnf ]
+ then
+ # rename temporarily
+ tmpcnf="$workcnf.disable"
+ debug "mv $workcnf $tmpcnf"
+ mv $workcnf $tmpcnf
+ fi
+
oldmask=`umask`
umask 077
oldmask=`umask`
umask 077
- cat > $
my
cnf <<EOF
+ cat > $
work
cnf <<EOF
# auto generated backupninja mysql conf
[mysql]
host=$dbhost
# auto generated backupninja mysql conf
[mysql]
host=$dbhost
@@
-126,14
+132,14
@@
password="$dbpassword"
host=$dbhost
user=$dbusername
password="$dbpassword"
host=$dbhost
user=$dbusername
password="$dbpassword"
+
+[mysqladmin]
+host=$dbhost
+user=$dbusername
+password="$dbpassword"
EOF
umask $oldmask
EOF
umask $oldmask
- if [ $usevserver = yes ]
- then
- defaultsfile="--defaults-extra-file=$vhome/.my.cnf"
- else
- defaultsfile="--defaults-extra-file=$mycnf"
- fi
+ defaultsfile="--defaults-extra-file=$mycnf"
fi
# if a user is not set, use $configfile, otherwise use $mycnf
fi
# if a user is not set, use $configfile, otherwise use $mycnf
@@
-144,22
+150,23
@@
else
userset=true;
if [ $usevserver = yes ]
then
userset=true;
if [ $usevserver = yes ]
then
-
v
userhome=`$VSERVER $vsname exec getent passwd "$user" | @AWK@ -F: '{print $6}'`
+ userhome=`$VSERVER $vsname exec getent passwd "$user" | @AWK@ -F: '{print $6}'`
if [ $? -eq 2 ]
then
if [ $? -eq 2 ]
then
-
fatal "User $user not found in /etc/passwd"
+ fatal "User $user not found in /etc/passwd"
fi
fi
- userhome="$vroot$vuserhome"
+ debug "User home set to: $vroot$userhome"
+ [ -f $vroot$userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf"
else
userhome=`getent passwd "$user" | @AWK@ -F: '{print $6}'`
if [ $? -eq 2 ]
then
else
userhome=`getent passwd "$user" | @AWK@ -F: '{print $6}'`
if [ $? -eq 2 ]
then
-
fatal "User $user not found in /etc/passwd"
+ fatal "User $user not found in /etc/passwd"
fi
fi
- fi
-
- debug "User home set to: $userhome"
- [ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf"
+ debug "User home set to: $userhome"
+ [ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf"
+ fi
+
defaultsfile="--defaults-extra-file=$userhome/.my.cnf"
debug "using $defaultsfile"
fi
defaultsfile="--defaults-extra-file=$userhome/.my.cnf"
debug "using $defaultsfile"
fi
@@
-230,14
+237,14
@@
then
then
if [ $usevserver = yes ]
then
then
if [ $usevserver = yes ]
then
- debug 'echo show databases | $VSERVER $vsname exec su $user -c \"$MYSQL $defaultsfile\" | grep -v Database'
- databases=`echo 'show databases' | $VSERVER $vsname exec su $user -c "$MYSQL $defaultsfile" | grep -v Database`
+ debug '
set -o pipefail ;
echo show databases | $VSERVER $vsname exec su $user -c \"$MYSQL $defaultsfile\" | grep -v Database'
+ databases=`
set -o pipefail ;
echo 'show databases' | $VSERVER $vsname exec su $user -c "$MYSQL $defaultsfile" | grep -v Database`
if [ $? -ne 0 ]
then
fatal "Authentication problem, maybe user/password is wrong or mysqld is not running?"
fi
else
if [ $? -ne 0 ]
then
fatal "Authentication problem, maybe user/password is wrong or mysqld is not running?"
fi
else
- databases=$(su $user -c "$MYSQL $defaultsfile -N -B -e 'show databases'" | sed 's/|//g;/\+----/d')
+ databases=$(s
et -o pipefail ; s
u $user -c "$MYSQL $defaultsfile -N -B -e 'show databases'" | sed 's/|//g;/\+----/d')
if [ $? -ne 0 ]
then
fatal "Authentication problem, maybe user/password is wrong or mysqld is not running?"
if [ $? -ne 0 ]
then
fatal "Authentication problem, maybe user/password is wrong or mysqld is not running?"
@@
-272,9
+279,9
@@
then
fatal "mysqld doesn't appear to be running!"
fi
if [ "$compress" == "yes" ]; then
fatal "mysqld doesn't appear to be running!"
fi
if [ "$compress" == "yes" ]; then
- execstr="$VSERVER $vsname exec $DUMP | $GZIP --rsyncable >
$vroot$dumpdir/${db}.sql.gz
"
+ execstr="$VSERVER $vsname exec $DUMP | $GZIP --rsyncable >
'$vroot$dumpdir/${db}.sql.gz'
"
else
else
- execstr="$VSERVER $vsname exec $DUMP -r
$vroot$dumpdir/${db}.sql
"
+ execstr="$VSERVER $vsname exec $DUMP -r
'$vroot$dumpdir/${db}.sql'
"
fi
else
# Test to make sure mysqld is running, if it is not sqldump will not work
fi
else
# Test to make sure mysqld is running, if it is not sqldump will not work
@@
-283,15
+290,15
@@
then
fatal "mysqld doesn't appear to be running!"
fi
if [ "$compress" == "yes" ]; then
fatal "mysqld doesn't appear to be running!"
fi
if [ "$compress" == "yes" ]; then
- execstr="$DUMP | $GZIP --rsyncable >
$dumpdir/${db}.sql.gz
"
+ execstr="$DUMP | $GZIP --rsyncable >
'$dumpdir/${db}.sql.gz'
"
else
else
- execstr="$DUMP -r
$dumpdir/${db}.sql
"
+ execstr="$DUMP -r
'$dumpdir/${db}.sql'
"
fi
fi
debug "su $user -c \"$execstr\""
if [ ! $test ]
then
fi
fi
debug "su $user -c \"$execstr\""
if [ ! $test ]
then
- output=`su $user -c "$execstr" 2>&1`
+ output=`su $user -c "
set -o pipefail ;
$execstr" 2>&1`
code=$?
if [ "$code" == "0" ]
then
code=$?
if [ "$code" == "0" ]
then
@@
-309,12
+316,12
@@
fi
if [ "$dbusername" != "" -a "$dbpassword" != "" ]
then
## clean up tmp config file
if [ "$dbusername" != "" -a "$dbpassword" != "" ]
then
## clean up tmp config file
- debug "rm $
my
cnf"
- rm $
my
cnf
+ debug "rm $
work
cnf"
+ rm $
work
cnf
if [ -f "$tmpcnf" ]
then
if [ -f "$tmpcnf" ]
then
- debug "mv $tmpcnf $
my
cnf"
- mv $tmpcnf $
my
cnf
+ debug "mv $tmpcnf $
work
cnf"
+ mv $tmpcnf $
work
cnf
fi
fi
fi
fi