Package: backupninja Followup-For: Bug #305870
Hi, Here is a patch that solves this problem, by using --defaults-file=/etc/mysql/debian.cnf as suggested. Additionally, it means users don't need to specify the database password. One more thing that will 'Just Work' (tm). -- System Information: Debian Release: 3.1 APT prefers testing APT policy: (700, 'testing'), (600, 'unstable') Architecture: i386 (i686) Kernel: Linux 2.6.6-2-686 Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)
--- /var/tmp/mysql 2005-04-17 21:33:00.000000000 +0200 +++ /usr/share/backupninja/mysql 2005-04-29 13:04:36.000000000 +0200 @@ -5,8 +5,6 @@ getconf backupdir /var/backups/mysql getconf databases all getconf compress yes -getconf dbusername -getconf dbpassword getconf dbhost localhost getconf hotcopy no getconf sqldump no @@ -21,45 +19,11 @@ [ "$sqldump" == "no" -o -d $dumpdir ] || mkdir -p $dumpdir [ "$hotcopy" == "no" -o -d $hotdir ] || mkdir -p $hotdir -# create .my.cnf - # (we do this because we don't want to have to specify the password on the command line - # because then anyone would be able to see it with a 'ps aux'. instead, we create a - # temporary ~/.my.cnf in root's home directory). - -if [ "$dbusername" != "" ]; then - home=`grep '^root:' /etc/passwd | awk -F: '{print $6}'` - [ -d $home ] || fatal "Can't find root's home directory ($home)." - mycnf="$home/.my.cnf" - if [ -f $mycnf ]; then - # rename temporarily - 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 -[mysql] -user=$dbusername -password=$dbpassword - -[mysqldump] -user=$dbusername -password=$dbpassword - -[mysqlhotcopy] -user=$dbusername -password=$dbpassword -EOF - umask $oldmask -fi - ## HOT COPY if [ "$hotcopy" == "yes" ]; then if [ "$databases" == "all" ]; then - execstr="$MYSQLHOTCOPY --quiet --allowold --regexp /.\*/./.\*/ $hotdir" + execstr="$MYSQLHOTCOPY --defaults-file=/etc/mysql/debian.cnf --quiet --allowold --regexp /.\*/./.\*/ $hotdir" debug "su $user -c '$execstr'" if [ ! $test ]; then output=`su $user -c "$execstr" 2>&1` @@ -74,7 +38,7 @@ fi else for db in $databases; do - execstr="$MYSQLHOTCOPY --allowold $db $hotdir" + execstr="$MYSQLHOTCOPY --defaults-file=/etc/mysql/debian.cnf --allowold $db $hotdir" debug "su $user -c '$execstr'" if [ ! $test ]; then output=`su $user -c "$execstr" 2>&1` @@ -95,11 +59,11 @@ if [ "$sqldump" == "yes" ]; then if [ "$databases" == "all" ]; then - databases=`echo 'show databases' | su $user -c "$MYSQL" | grep -v Database` + databases=`echo 'show databases' | su $user -c "$MYSQL --defaults-file=/etc/mysql/debian.cnf" | grep -v Database` fi for db in $databases; do - execstr="$MYSQLDUMP --lock-tables --complete-insert --add-drop-table --quick --quote-names $db > $dumpdir/${db}.sql" + execstr="$MYSQLDUMP --defaults-file=/etc/mysql/debian.cnf --lock-tables --complete-insert --add-drop-table --quick --quote-names $db > $dumpdir/${db}.sql" debug "su $user -c '$execstr'" if [ ! $test ]; then output=`su $user -c "$execstr" 2>&1` @@ -120,14 +84,4 @@ fi fi -if [ "$dbusername" != "" ]; then - ## clean up tmp config file - debug "rm $mycnf" - rm $mycnf - if [ -f "$tmpcnf" ]; then - debug "mv $tmpcnf $mycnf" - mv $tmpcnf $mycnf - fi -fi - return 0