aboutsummaryrefslogtreecommitdiff
path: root/app/backup/backupninja/backupninja-0.9.6.diff
blob: dc319b12694fc145aeba01cd7051c302d2af9566 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
diff -Naur backupninja-0.9.6.orig/handlers/mysql.in backupninja-0.9.6/handlers/mysql.in
--- backupninja-0.9.6.orig/handlers/mysql.in	2008-06-24 12:55:10.000000000 -0300
+++ backupninja-0.9.6/handlers/mysql.in	2008-09-13 10:23:20.000000000 -0300
@@ -88,8 +88,7 @@
 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
@@ -97,18 +96,25 @@
     [ -d $home ] || fatal "Can't find root's home directory ($home)."
     
     mycnf="$home/.my.cnf"
-    
-    if [ -f $mycnf ]
+
+    if [ $usevserver = yes ]
+    then
+      workcnf="$vroot$mycnf"
+    else
+      workcnf="$mycnf"
+    fi
+
+    if [ -f $workcnf ]
     then
-	# rename temporarily
-	tmpcnf="$home/my.cnf.disable"
-	debug "mv $mycnf $tmpcnf"
-	mv $mycnf $tmpcnf
+      # rename temporarily
+      tmpcnf="$workcnf.disable"
+      debug "mv $workcnf $tmpcnf"
+      mv $workcnf $tmpcnf
     fi
     
     oldmask=`umask`
     umask 077
-    cat > $mycnf <<EOF
+    cat > $workcnf <<EOF
 # auto generated backupninja mysql conf
 [mysql]
 host=$dbhost
@@ -124,14 +130,14 @@
 host=$dbhost
 user=$dbusername
 password="$dbpassword"
+
+[mysqladmin]
+host=$dbhost
+user=$dbusername
+password="$dbpassword"
 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
@@ -142,22 +148,23 @@
 	userset=true;
 	if [ $usevserver = yes ]
 	then
-	    vuserhome=`$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
 	    	fatal "User $user not found in /etc/passwd"
 	    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
 	    	fatal "User $user not found in /etc/passwd"
 	    fi
-       	fi
+	    debug "User home set to: $userhome"
+	    [ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf"
+	fi
 	
-	debug "User home set to: $userhome"
-	[ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf"
 	defaultsfile="--defaults-extra-file=$userhome/.my.cnf"
 	debug "using $defaultsfile"
 fi
@@ -307,12 +314,12 @@
 if [ "$dbusername" != "" -a "$dbpassword" != "" ]
 then
 	## clean up tmp config file
-	debug "rm $mycnf"
-	rm $mycnf
+	debug "rm $workcnf"
+	rm $workcnf
 	if [ -f "$tmpcnf" ]
 	then
-		debug "mv $tmpcnf $mycnf"
-		mv $tmpcnf $mycnf
+		debug "mv $tmpcnf $workcnf"
+		mv $tmpcnf $workcnf
 	fi
 fi