projects
/
matthijs
/
upstream
/
backupninja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r220@um: micah | 2005-12-27 11:12:31 -0500
[matthijs/upstream/backupninja.git]
/
handlers
/
mysql
diff --git
a/handlers/mysql
b/handlers/mysql
index 6fd50562998ed648ea91cfbc2e105e6befecc0fb..20905d56232010748dabff102602b25e273e3db0 100644
(file)
--- a/
handlers/mysql
+++ b/
handlers/mysql
@@
-35,7
+35,7
@@
fi
# If needed, make sure that the specified vserver exists and is running.
if [ $usevserver ]
then
# If needed, make sure that the specified vserver exists and is running.
if [ $usevserver ]
then
-
info
"Examining vserver '$vsname'"
+
debug
"Examining vserver '$vsname'"
# does it exist ?
vroot="$VROOTDIR/$vsname"
[ -d $vroot ] || fatal "vserver '$vsname' does not exist at '$vroot'"
# does it exist ?
vroot="$VROOTDIR/$vsname"
[ -d $vroot ] || fatal "vserver '$vsname' does not exist at '$vroot'"
@@
-60,7
+60,7
@@
else
fatal "User $user not found in /etc/passwd"
fi
userhome="$vroot$userhome"
fatal "User $user not found in /etc/passwd"
fi
userhome="$vroot$userhome"
-
info
"User home set to: $userhome"
+
debug
"User home set to: $userhome"
[ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf"
else
userhome=`getent passwd "$user" | awk -F: '{print $6}'`
[ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf"
else
userhome=`getent passwd "$user" | awk -F: '{print $6}'`
@@
-68,7
+68,7
@@
else
then
fatal "User $user not found in /etc/passwd"
fi
then
fatal "User $user not found in /etc/passwd"
fi
-
info
"User home set to: $userhome"
+
debug
"User home set to: $userhome"
[ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf"
fi
fi
[ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf"
fi
fi
@@
-115,19
+115,21
@@
fi
# specify the password on the command line.
defaultsfile=""
# specify the password on the command line.
defaultsfile=""
+
if [ "$dbusername" != "" -a "$dbpassword" != "" ]
then
if [ $usevserver ]
then
if [ "$dbusername" != "" -a "$dbpassword" != "" ]
then
if [ $usevserver ]
then
- home=`$VSERVER $vsname exec getent passwd "root" | awk -F: '{print $6}'`
- home="$vroot$home"
- info "Home set to: $home"
+ vhome=`$VSERVER $vsname exec getent passwd "root" | awk -F: '{print $6}'`
+ home="$vroot$vhome"
else
home=`getent passwd "root" | awk -F: '{print $6}'`
else
home=`getent passwd "root" | awk -F: '{print $6}'`
- info "Home set to: $home"
fi
fi
+
[ -d $home ] || fatal "Can't find root's home directory ($home)."
[ -d $home ] || fatal "Can't find root's home directory ($home)."
+
mycnf="$home/.my.cnf"
mycnf="$home/.my.cnf"
+
if [ -f $mycnf ]
then
# rename temporarily
if [ -f $mycnf ]
then
# rename temporarily
@@
-135,27
+137,37
@@
then
debug "mv $mycnf $tmpcnf"
mv $mycnf $tmpcnf
fi
debug "mv $mycnf $tmpcnf"
mv $mycnf $tmpcnf
fi
+
oldmask=`umask`
umask 077
cat > $mycnf <<EOF
# auto generated backupninja mysql conf
[mysql]
oldmask=`umask`
umask 077
cat > $mycnf <<EOF
# auto generated backupninja mysql conf
[mysql]
+host=$dbhost
user=$dbusername
password="$dbpassword"
[mysqldump]
user=$dbusername
password="$dbpassword"
[mysqldump]
+host=$dbhost
user=$dbusername
password="$dbpassword"
[mysqlhotcopy]
user=$dbusername
password="$dbpassword"
[mysqlhotcopy]
+host=$dbhost
user=$dbusername
password="$dbpassword"
EOF
umask $oldmask
user=$dbusername
password="$dbpassword"
EOF
umask $oldmask
- defaultsfile="--defaults-file=$mycnf"
+ if [ $usevserver ]
+ then
+ defaultsfile="--defaults-file=$vhome/.my.cnf"
+ else
+ defaultsfile="--defaults-file=$mycnf"
+ fi
+
+# if user is set, don't use $mycnf
elif [ "$userset" == "false" ]; then
elif [ "$userset" == "false" ]; then
- # if user is set, don't use $mycnf
- defaultsfile="--defaults-file=$configfile"
+ defaultsfile="--defaults-file=$configfile"
fi
#######################################################################
fi
#######################################################################
@@
-168,7
+180,8
@@
then
then
if [ $usevserver ]
then
then
if [ $usevserver ]
then
- execstr="$VSERVER $vsname exec $MYSQLHOTCOPY --quiet --allowold --regexp /.\*/./.\*/ $hotdir"
+ info "dbhost: $dbhost"
+ execstr="$VSERVER $vsname exec $MYSQLHOTCOPY -h $dbhost --quiet --allowold --regexp /.\*/./.\*/ $hotdir"
else
execstr="$MYSQLHOTCOPY --quiet --allowold --regexp /.\*/./.\*/ $hotdir"
fi
else
execstr="$MYSQLHOTCOPY --quiet --allowold --regexp /.\*/./.\*/ $hotdir"
fi
@@
-223,11
+236,11
@@
then
then
if [ $usevserver ]
then
then
if [ $usevserver ]
then
-
databases=`echo 'show databases' | $VSERVER $vsname exec su $user -c "$MYSQL $defaultsfile" | grep -v Database`
-
if [ $? -ne 0 ]
-
then
-
fatal "Something unexpected happened, the defaults file may have gone missing or is corrupt"
-
fi
+ databases=`echo 'show databases' | $VSERVER $vsname exec su $user -c "$MYSQL $defaultsfile" | grep -v Database`
+ if [ $? -ne 0 ]
+ then
+ fatal "Something unexpected happened, the defaults file may have gone missing or is corrupt"
+ fi
else
databases=`echo 'show databases' | su $user -c "$MYSQL $defaultsfile" | grep -v Database`
if [ $? -ne 0 ]
else
databases=`echo 'show databases' | su $user -c "$MYSQL $defaultsfile" | grep -v Database`
if [ $? -ne 0 ]