diff options
author | Micah Anderson <micah@riseup.net> | 2005-12-27 17:37:44 +0000 |
---|---|---|
committer | Micah Anderson <micah@riseup.net> | 2005-12-27 17:37:44 +0000 |
commit | 06edbbddc536c3c7e204e54ca7897d9614307fcd (patch) | |
tree | 449c733e825ddc0fec8e72cf293757f8133808d1 /handlers | |
parent | 603c015425c36977b13a73fec79c9fa9e857e358 (diff) | |
download | backupninja-06edbbddc536c3c7e204e54ca7897d9614307fcd.tar.gz backupninja-06edbbddc536c3c7e204e54ca7897d9614307fcd.tar.bz2 |
r219@um: micah | 2005-12-27 10:32:24 -0500
Defaults file is now set correctly for vservers
dbhost is now added to the .my.cnf
Diffstat (limited to 'handlers')
-rw-r--r-- | handlers/mysql | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/handlers/mysql b/handlers/mysql index cb70104..408399d 100644 --- a/handlers/mysql +++ b/handlers/mysql @@ -115,19 +115,21 @@ fi # specify the password on the command line. defaultsfile="" + if [ "$dbusername" != "" -a "$dbpassword" != "" ] then if [ $usevserver ] then - home=`$VSERVER $vsname exec getent passwd "root" | awk -F: '{print $6}'` - home="$vroot$home" - debug "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}'` - debug "Home set to: $home" fi + [ -d $home ] || fatal "Can't find root's home directory ($home)." + mycnf="$home/.my.cnf" + if [ -f $mycnf ] then # rename temporarily @@ -135,27 +137,37 @@ then debug "mv $mycnf $tmpcnf" mv $mycnf $tmpcnf fi + oldmask=`umask` umask 077 cat > $mycnf <<EOF # auto generated backupninja mysql conf [mysql] +host=$dbhost user=$dbusername password="$dbpassword" [mysqldump] +host=$dbhost user=$dbusername password="$dbpassword" [mysqlhotcopy] +host=$dbhost 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 - # if user is set, don't use $mycnf - defaultsfile="--defaults-file=$configfile" + defaultsfile="--defaults-file=$configfile" fi ####################################################################### @@ -223,11 +235,11 @@ 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 ] |