Skip to content
Snippets Groups Projects
Commit 84d86d05 authored by micah's avatar micah :speech_balloon:
Browse files

r211@um: micah | 2005-12-27 09:09:54 -0500

 Added some vserver handling to determine correct home directory, also
 enhanced error handling
parent 8b441b16
No related branches found
No related tags found
No related merge requests found
...@@ -63,7 +63,7 @@ then ...@@ -63,7 +63,7 @@ then
fi fi
fi fi
# create backup dirs, the vroot variable will be empty if no vsname was specified # create backup dirs, vroot variable will be empty if no vsname was specified
# and will proceed to operate on the host # and will proceed to operate on the host
[ -d $vroot$backupdir ] || mkdir -p $vroot$backupdir [ -d $vroot$backupdir ] || mkdir -p $vroot$backupdir
[ -d $vroot$backupdir ] || fatal "Backup directory '$vroot$backupdir'" [ -d $vroot$backupdir ] || fatal "Backup directory '$vroot$backupdir'"
...@@ -97,19 +97,25 @@ fi ...@@ -97,19 +97,25 @@ fi
# specify the password on the command line. # specify the password on the command line.
defaultsfile="" defaultsfile=""
if [ "$dbusername" != "" -a "$dbpassword" != "" ]; then if [ "$dbusername" != "" -a "$dbpassword" != "" ]
home=`getent passwd "root" | awk -F: '{print $6}'` then
[ -d $home ] || fatal "Can't find root's home directory ($home)." if [ $usevserver ]
mycnf="$home/.my.cnf" then
if [ -f $mycnf ]; then home=`$VSERVER $vsname exec getent passwd "root" | awk -F: '{print $6}'`
# rename temporarily else
tmpcnf="$home/my.cnf.disable" home=`getent passwd "root" | awk -F: '{print $6}'`
debug "mv $mycnf $tmpcnf" fi
mv $mycnf $tmpcnf [ -d $home ] || fatal "Can't find root's home directory ($home)."
fi mycnf="$home/.my.cnf"
oldmask=`umask` if [ -f $mycnf ]; then
umask 077 # rename temporarily
cat > $mycnf <<EOF tmpcnf="$home/my.cnf.disable"
debug "mv $mycnf $tmpcnf"
mv $mycnf $tmpcnf
fi
oldmask=`umask`
umask 077
cat > $mycnf <<EOF
# auto generated backupninja mysql conf # auto generated backupninja mysql conf
[mysql] [mysql]
user=$dbusername user=$dbusername
...@@ -185,8 +191,16 @@ if [ "$sqldump" == "yes" ]; then ...@@ -185,8 +191,16 @@ if [ "$sqldump" == "yes" ]; then
if [ $usevserver ] if [ $usevserver ]
then then
databases=`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`
if [ $? -ne 0 ]
then
fatal "Something unexpected happened, the defaults file may have gone missing or is corrupt"
fi
else else
databases=`echo 'show databases' | su $user -c "$MYSQL $defaultsfile" | grep -v Database` databases=`echo 'show databases' | 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
fi fi
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment