aboutsummaryrefslogtreecommitdiff
path: root/app/backup/backupninja/backupninja-0.9.4.diff
blob: ea3a62bcd93a8086374e03463fc28e3d50c82a5e (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
diff -Naur backupninja-0.9.4.orig/handlers/mysql backupninja-0.9.4/handlers/mysql
--- backupninja-0.9.4.orig/handlers/mysql	2006-10-07 01:45:20.000000000 -0300
+++ backupninja-0.9.4/handlers/mysql	2007-01-18 14:24:46.000000000 -0200
@@ -90,8 +90,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
@@ -99,18 +98,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
@@ -128,12 +134,7 @@
 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
@@ -144,22 +145,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
@@ -282,12 +284,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
 
diff -Naur backupninja-0.9.4.orig/handlers/pgsql backupninja-0.9.4/handlers/pgsql
--- backupninja-0.9.4.orig/handlers/pgsql	2006-10-07 01:45:20.000000000 -0300
+++ backupninja-0.9.4/handlers/pgsql	2007-01-18 14:09:22.000000000 -0200
@@ -64,10 +64,10 @@
 if [ $usevserver = yes ]; then
    pguid=`$VSERVER $vsname exec getent passwd $PGSQLUSER | awk -F: '{print $3}'`
 else
-   pguid=`getent passwd postgres | awk -F: '{print $3}'`
+   pguid=`getent passwd $PGSQLUSER | awk -F: '{print $3}'`
 fi
 [ -n "$pguid" ] || \
-    fatal "No user called postgres`[ $usevserver = no ] || echo \" on vserver $vsname\"`."
+    fatal "No user called $PGSQLUSER`[ $usevserver = no ] || echo \" on vserver $vsname\"`."
 debug "chown $pguid $vroot$backupdir"
 chown $pguid $vroot$backupdir
 debug "chmod 700 $vroot$backupdir"
@@ -77,15 +77,15 @@
 if [ "$databases" == "all" ]; then
     if [ $usevserver = yes ]; then
        if [ "$compress" == "yes" ]; then          
-          execstr="$VSERVER $vsname exec su - postgres -c \"$PGSQLDUMPALL | $GZIP > $backupdir/${vsname}.sql.gz\""
+          execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMPALL | $GZIP > $backupdir/${vsname}.sql.gz\""
        else
-          execstr="$VSERVER $vsname exec su - postgres -c \"$PGSQLDUMPALL > $backupdir/${vsname}.sql\""
+          execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMPALL > $backupdir/${vsname}.sql\""
        fi
     else
        if [ "$compress" == "yes" ]; then
-          execstr="su - postgres -c \"$PGSQLDUMPALL | $GZIP > $backupdir/${localhost}-all.sql.gz\""
+          execstr="su - $PGSQLUSER -c \"$PGSQLDUMPALL | $GZIP > $backupdir/${localhost}-all.sql.gz\""
        else
-	execstr="su - postgres -c \"$PGSQLDUMPALL > $backupdir/${localhost}-all.sql\""
+	execstr="su - $PGSQLUSER -c \"$PGSQLDUMPALL > $backupdir/${localhost}-all.sql\""
        fi
     fi
     debug "$execstr"
@@ -106,15 +106,15 @@
     for db in $databases; do
 	if [ $usevserver = yes ]; then
            if [ "$compress" == "yes" ]; then
-              execstr="$VSERVER $vsname exec su - postgres -c \"$PGSQLDUMP $db | $GZIP > $backupdir/${db}.sql.gz\""
+              execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMP $db | $GZIP > $backupdir/${db}.sql.gz\""
            else
-              execstr="$VSERVER $vsname exec su - postgres -c \"$PGSQLDUMP $db | > $backupdir/${db}.sql\""
+              execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMP $db | > $backupdir/${db}.sql\""
            fi
 	else
            if [ "$compress" == "yes" ]; then
-              execstr="su - postgres -c \"$PGSQLDUMP $db | $GZIP > $backupdir/${db}.sql.gz\""
+              execstr="su - $PGSQLUSER -c \"$PGSQLDUMP $db | $GZIP > $backupdir/${db}.sql.gz\""
            else
-              execstr="su - postgres -c \"$PGSQLDUMP $db > $backupdir/${db}.sql\""
+              execstr="su - $PGSQLUSER -c \"$PGSQLDUMP $db > $backupdir/${db}.sql\""
            fi
 	fi
 	debug "$execstr"
diff -Naur backupninja-0.9.4.orig/src/backupninja.in backupninja-0.9.4/src/backupninja.in
--- backupninja-0.9.4.orig/src/backupninja.in	2006-10-07 01:45:20.000000000 -0300
+++ backupninja-0.9.4/src/backupninja.in	2007-01-18 14:09:22.000000000 -0200
@@ -442,6 +442,7 @@
 getconf MYSQLDUMP /usr/bin/mysqldump
 getconf PGSQLDUMP /usr/bin/pg_dump
 getconf PGSQLDUMPALL /usr/bin/pg_dumpall
+getconf PGSQLUSER postgres
 getconf GZIP /bin/gzip
 getconf RSYNC /usr/bin/rsync
 getconf admingroup root