From 4ecaae94054c4eb919ddbd45904d834383a09558 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 22 May 2009 14:50:52 +0200 Subject: Make all indentation consistent. Previously, there were many indentation styles in use: Real tabs, 2, 3 or 4 spaces, mixing these within the same file, function or even within a single line. This commit changes all bash scripts in the handlers, src and lib dirs to use consistent indentation: three spaces are now used everywhere. Other files (e.g. Makefiles) are left untouched. Additionally, this commit removes all trailing whitespace. --- handlers/mysql.in | 380 +++++++++++++++++++++++++++--------------------------- 1 file changed, 190 insertions(+), 190 deletions(-) (limited to 'handlers/mysql.in') diff --git a/handlers/mysql.in b/handlers/mysql.in index e34b16d..a4a3667 100644 --- a/handlers/mysql.in +++ b/handlers/mysql.in @@ -47,9 +47,9 @@ fi ignore='' for i in $ignores $nodata; do - ignore="$ignore --ignore-table=$i" + ignore="$ignore --ignore-table=$i" done - + # create backup dirs, $vroot will be empty if no vsname was specified # and we will instead proceed to operate on the host [ -d $vroot$backupdir ] || mkdir -p $vroot$backupdir @@ -59,11 +59,11 @@ dumpdir="$backupdir/sqldump" if [ $usevserver = yes ] then - [ "$sqldump" == "no" -o -d $vroot$dumpdir ] || $VSERVER $vsname exec mkdir -p $dumpdir - [ "$hotcopy" == "no" -o -d $vroot$hotdir ] || $VSERVER $vsname exec mkdir -p $hotdir + [ "$sqldump" == "no" -o -d $vroot$dumpdir ] || $VSERVER $vsname exec mkdir -p $dumpdir + [ "$hotcopy" == "no" -o -d $vroot$hotdir ] || $VSERVER $vsname exec mkdir -p $hotdir else - [ "$sqldump" == "no" -o -d $dumpdir ] || mkdir -p $dumpdir - [ "$hotcopy" == "no" -o -d $hotdir ] || mkdir -p $hotdir + [ "$sqldump" == "no" -o -d $dumpdir ] || mkdir -p $dumpdir + [ "$hotcopy" == "no" -o -d $hotdir ] || mkdir -p $hotdir fi ####################################################################### @@ -87,29 +87,29 @@ defaultsfile="" if [ "$dbusername" != "" -a "$dbpassword" != "" ] then - if [ $usevserver = yes ] - then - vhome=`$VSERVER $vsname exec getent passwd "root" | @AWK@ -F: '{print $6}'` - home="$vroot$vhome" - else - home=`getent passwd "root" | @AWK@ -F: '{print $6}'` - fi + if [ $usevserver = yes ] + then + vhome=`$VSERVER $vsname exec getent passwd "root" | @AWK@ -F: '{print $6}'` + home="$vroot$vhome" + else + home=`getent passwd "root" | @AWK@ -F: '{print $6}'` + fi + + [ -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 - [ -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 < $mycnf <&1` - code=$? - if [ "$code" == "0" ] - then - debug $output - info "Successfully finished hotcopy of all mysql databases" - else - warning $output - warning "Failed to hotcopy all mysql databases" - fi - fi - else - for db in $databases - do - if [ $usevserver = yes ] - then - execstr="$VSERVER $vsname exec $MYSQLHOTCOPY --allowold $db $hotdir" - else - execstr="$MYSQLHOTCOPY --allowold $db $hotdir" - fi - debug 'su $user -c \"$execstr\"' - if [ ! $test ] - then - output=`su $user -c "$execstr" 2>&1` - code=$? - if [ "$code" == "0" ] - then - debug $output - info "Successfully finished hotcopy of mysql database $db" - else - warning $output - warning "Failed to hotcopy mysql database $db" - fi - fi - done - fi + info "Initializing hotcopy method" + if [ "$databases" == "all" ] + then + if [ $usevserver = yes ] + then + info "dbhost: $dbhost" + execstr="$VSERVER $vsname exec $MYSQLHOTCOPY -h $dbhost --quiet --allowold --regexp /.\*/./.\*/ $hotdir" + else + execstr="$MYSQLHOTCOPY --quiet --allowold --regexp /.\*/./.\*/ $hotdir" + fi + debug "su $user -c \"$execstr\"" + if [ ! $test ] + then + output=`su $user -c "$execstr" 2>&1` + code=$? + if [ "$code" == "0" ] + then + debug $output + info "Successfully finished hotcopy of all mysql databases" + else + warning $output + warning "Failed to hotcopy all mysql databases" + fi + fi + else + for db in $databases + do + if [ $usevserver = yes ] + then + execstr="$VSERVER $vsname exec $MYSQLHOTCOPY --allowold $db $hotdir" + else + execstr="$MYSQLHOTCOPY --allowold $db $hotdir" + fi + debug 'su $user -c \"$execstr\"' + if [ ! $test ] + then + output=`su $user -c "$execstr" 2>&1` + code=$? + if [ "$code" == "0" ] + then + debug $output + info "Successfully finished hotcopy of mysql database $db" + else + warning $output + warning "Failed to hotcopy mysql database $db" + fi + fi + done + fi fi ########################################################################## @@ -224,97 +224,97 @@ fi if [ "$sqldump" == "yes" ] then - info "Initializing SQL dump method" - if [ "$databases" == "all" ] - then - if [ $usevserver = yes ] - then - debug '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 "Authentication problem, maybe user/password is wrong or mysqld is not running?" - fi - else - databases=$(su $user -c "$MYSQL $defaultsfile -N -B -e 'show databases'" | sed 's/|//g;/\+----/d') - if [ $? -ne 0 ] - then - fatal "Authentication problem, maybe user/password is wrong or mysqld is not running?" - fi - fi - fi + info "Initializing SQL dump method" + if [ "$databases" == "all" ] + then + if [ $usevserver = yes ] + then + debug '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 "Authentication problem, maybe user/password is wrong or mysqld is not running?" + fi + else + databases=$(su $user -c "$MYSQL $defaultsfile -N -B -e 'show databases'" | sed 's/|//g;/\+----/d') + if [ $? -ne 0 ] + then + fatal "Authentication problem, maybe user/password is wrong or mysqld is not running?" + fi + fi + fi - for db in $databases - do - DUMP_BASE="$MYSQLDUMP $defaultsfile $sqldumpoptions" + for db in $databases + do + DUMP_BASE="$MYSQLDUMP $defaultsfile $sqldumpoptions" - # Dumping structure and data - DUMP="$DUMP_BASE $ignore $db" + # Dumping structure and data + DUMP="$DUMP_BASE $ignore $db" - # If requested, dump only the table structure for this database - if echo "$nodata" | grep -E '(^|[[:space:]])'"$db\." >/dev/null - then - # Get the structure of the tables, without data - DUMP_STRUCT="$DUMP_BASE --no-data $db" - for qualified_table in $nodata - do - table=$( expr match "$qualified_table" "$db\.\([^\w]*\)" ) - DUMP_STRUCT="$DUMP_STRUCT $table" - done - DUMP="( $DUMP; $DUMP_STRUCT )" - fi - if [ $usevserver = yes ] - then - # Test to make sure mysqld is running, if it is not sqldump will not work - $VSERVER $vsname exec su $user -c "$MYSQLADMIN $defaultsfile ping 2>&1 >/dev/null" - if [ $? -ne 0 ]; then - fatal "mysqld doesn't appear to be running!" - fi - if [ "$compress" == "yes" ]; then - execstr="$VSERVER $vsname exec $DUMP | $GZIP > $vroot$dumpdir/${db}.sql.gz" - else - execstr="$VSERVER $vsname exec $DUMP -r $vroot$dumpdir/${db}.sql" - fi - else - # Test to make sure mysqld is running, if it is not sqldump will not work - su $user -c "$MYSQLADMIN $defaultsfile ping 2>&1 >/dev/null" - if [ $? -ne 0 ]; then - fatal "mysqld doesn't appear to be running!" - fi - if [ "$compress" == "yes" ]; then - execstr="$DUMP | $GZIP > $dumpdir/${db}.sql.gz" - else - execstr="$DUMP -r $dumpdir/${db}.sql" - fi - fi - debug "su $user -c \"$execstr\"" - if [ ! $test ] - then - output=`su $user -c "$execstr" 2>&1` - code=$? - if [ "$code" == "0" ] - then - debug $output - info "Successfully finished dump of mysql database $db" - else - warning $output - warning "Failed to dump mysql databases $db" - fi - fi - done + # If requested, dump only the table structure for this database + if echo "$nodata" | grep -E '(^|[[:space:]])'"$db\." >/dev/null + then + # Get the structure of the tables, without data + DUMP_STRUCT="$DUMP_BASE --no-data $db" + for qualified_table in $nodata + do + table=$( expr match "$qualified_table" "$db\.\([^\w]*\)" ) + DUMP_STRUCT="$DUMP_STRUCT $table" + done + DUMP="( $DUMP; $DUMP_STRUCT )" + fi + if [ $usevserver = yes ] + then + # Test to make sure mysqld is running, if it is not sqldump will not work + $VSERVER $vsname exec su $user -c "$MYSQLADMIN $defaultsfile ping 2>&1 >/dev/null" + if [ $? -ne 0 ]; then + fatal "mysqld doesn't appear to be running!" + fi + if [ "$compress" == "yes" ]; then + execstr="$VSERVER $vsname exec $DUMP | $GZIP > $vroot$dumpdir/${db}.sql.gz" + else + execstr="$VSERVER $vsname exec $DUMP -r $vroot$dumpdir/${db}.sql" + fi + else + # Test to make sure mysqld is running, if it is not sqldump will not work + su $user -c "$MYSQLADMIN $defaultsfile ping 2>&1 >/dev/null" + if [ $? -ne 0 ]; then + fatal "mysqld doesn't appear to be running!" + fi + if [ "$compress" == "yes" ]; then + execstr="$DUMP | $GZIP > $dumpdir/${db}.sql.gz" + else + execstr="$DUMP -r $dumpdir/${db}.sql" + fi + fi + debug "su $user -c \"$execstr\"" + if [ ! $test ] + then + output=`su $user -c "$execstr" 2>&1` + code=$? + if [ "$code" == "0" ] + then + debug $output + info "Successfully finished dump of mysql database $db" + else + warning $output + warning "Failed to dump mysql databases $db" + fi + fi + done fi # clean up tmp config file if [ "$dbusername" != "" -a "$dbpassword" != "" ] then - ## clean up tmp config file - debug "rm $mycnf" - rm $mycnf - if [ -f "$tmpcnf" ] - then - debug "mv $tmpcnf $mycnf" - mv $tmpcnf $mycnf - fi + ## 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 -- cgit v1.2.3 From 78884142e7cdaaf3e1f5571b1f28d2ea5a520b30 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 22 May 2009 15:27:09 +0200 Subject: Add a vim modeline with indentation settings. The modelines added match the emacs lines already present and also set the filetype to sh (just like the emacs lines). --- handlers/dup.helper.in | 1 + handlers/dup.in | 1 + handlers/ldap.helper.in | 1 + handlers/ldap.in | 1 + handlers/maildir.in | 1 + handlers/makecd.helper.in | 1 + handlers/makecd.in | 1 + handlers/mysql.helper.in | 1 + handlers/mysql.in | 1 + handlers/pgsql.helper.in | 1 + handlers/pgsql.in | 1 + handlers/rdiff.helper.in | 1 + handlers/rdiff.in | 1 + handlers/rsync.in | 2 ++ handlers/sh.in | 1 + handlers/svn.in | 1 + handlers/sys.helper.in | 1 + handlers/sys.in | 1 + handlers/tar.helper.in | 1 + handlers/tar.in | 1 + handlers/trac.in | 1 + handlers/wget | 2 ++ lib/easydialog.in | 1 + lib/tools.in | 1 + lib/vserver.in | 1 + src/backupninja.in | 1 + src/ninjahelper.in | 1 + src/ninjareport.in | 1 + 28 files changed, 30 insertions(+) (limited to 'handlers/mysql.in') diff --git a/handlers/dup.helper.in b/handlers/dup.helper.in index 86745c8..3c08a2f 100644 --- a/handlers/dup.helper.in +++ b/handlers/dup.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS dup:incremental_encrypted_remote_filesystem_backup" diff --git a/handlers/dup.in b/handlers/dup.in index 60a4ce9..aed6030 100644 --- a/handlers/dup.in +++ b/handlers/dup.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # duplicity script for backupninja # requires duplicity diff --git a/handlers/ldap.helper.in b/handlers/ldap.helper.in index 4870ae4..4154cc6 100644 --- a/handlers/ldap.helper.in +++ b/handlers/ldap.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS ldap:ldap_database_backup" diff --git a/handlers/ldap.in b/handlers/ldap.in index 0b0166e..5f402c7 100644 --- a/handlers/ldap.in +++ b/handlers/ldap.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # openldap backup handler script for backupninja # diff --git a/handlers/maildir.in b/handlers/maildir.in index e88619d..ab72ce1 100644 --- a/handlers/maildir.in +++ b/handlers/maildir.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: ############################################################### # diff --git a/handlers/makecd.helper.in b/handlers/makecd.helper.in index c8a6762..ad0c4aa 100644 --- a/handlers/makecd.helper.in +++ b/handlers/makecd.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS makecd:makecd_backup" wizardname="makecd action wizard" diff --git a/handlers/makecd.in b/handlers/makecd.in index 78e5454..d44bba3 100644 --- a/handlers/makecd.in +++ b/handlers/makecd.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # burncd handler script for backupninja # diff --git a/handlers/mysql.helper.in b/handlers/mysql.helper.in index fb9f11d..997f73c 100644 --- a/handlers/mysql.helper.in +++ b/handlers/mysql.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS mysql:mysql_database_backup" diff --git a/handlers/mysql.in b/handlers/mysql.in index a4a3667..88ffb1a 100644 --- a/handlers/mysql.in +++ b/handlers/mysql.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # mysql handler script for backupninja # diff --git a/handlers/pgsql.helper.in b/handlers/pgsql.helper.in index 48bf047..ff1cfd4 100644 --- a/handlers/pgsql.helper.in +++ b/handlers/pgsql.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS pgsql:postgresql_database_backup" diff --git a/handlers/pgsql.in b/handlers/pgsql.in index b7e4262..ff5f7ba 100644 --- a/handlers/pgsql.in +++ b/handlers/pgsql.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # PostgreSQL handler script for backupninja # diff --git a/handlers/rdiff.helper.in b/handlers/rdiff.helper.in index c673723..83f2fb5 100644 --- a/handlers/rdiff.helper.in +++ b/handlers/rdiff.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS rdiff:incremental_remote_filesystem_backup" diff --git a/handlers/rdiff.in b/handlers/rdiff.in index 51da1cc..f59d56a 100644 --- a/handlers/rdiff.in +++ b/handlers/rdiff.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # rdiff-backup handler script for backupninja # requires rdiff-backup diff --git a/handlers/rsync.in b/handlers/rsync.in index 9e5e4f9..072f2a6 100644 --- a/handlers/rsync.in +++ b/handlers/rsync.in @@ -1,3 +1,5 @@ +# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # backupninja handler to do incremental backups using # rsync and hardlinks, based on diff --git a/handlers/sh.in b/handlers/sh.in index 4edfd9a..b070f3b 100644 --- a/handlers/sh.in +++ b/handlers/sh.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # shell script handler for backupninja # runs the file /etc/backup.d/scriptname.sh diff --git a/handlers/svn.in b/handlers/svn.in index 97d1701..5e5531a 100644 --- a/handlers/svn.in +++ b/handlers/svn.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # this handler will backup subversion repostitories. # diff --git a/handlers/sys.helper.in b/handlers/sys.helper.in index c823712..8a2fb07 100644 --- a/handlers/sys.helper.in +++ b/handlers/sys.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS sys:general_hardware_and_system_info" diff --git a/handlers/sys.in b/handlers/sys.in index 2ab5871..69751ed 100755 --- a/handlers/sys.in +++ b/handlers/sys.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # this handler will save various reports of vital system information. # by default, all the reports are saved in /var/backups. diff --git a/handlers/tar.helper.in b/handlers/tar.helper.in index 2665382..cdbe03a 100644 --- a/handlers/tar.helper.in +++ b/handlers/tar.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS tar:tar_backup" diff --git a/handlers/tar.in b/handlers/tar.in index 0a762ce..b4f8c58 100644 --- a/handlers/tar.in +++ b/handlers/tar.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # tar handler script for backupninja diff --git a/handlers/trac.in b/handlers/trac.in index f387d42..018bffd 100644 --- a/handlers/trac.in +++ b/handlers/trac.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # this handler will backup trac environments (based on the svn handler) # diff --git a/handlers/wget b/handlers/wget index 0c363eb..ebb391e 100644 --- a/handlers/wget +++ b/handlers/wget @@ -1,3 +1,5 @@ +# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # backupninja handler to do incremental backups using # wget and hardlinks, based on rsync handler diff --git a/lib/easydialog.in b/lib/easydialog.in index a0495a7..c41e6f7 100644 --- a/lib/easydialog.in +++ b/lib/easydialog.in @@ -1,5 +1,6 @@ #!@BASH@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # copyright 2002 lmoore@tump.com under the terms of the GNU LGPL. # additions 2005 collective@riseup.net diff --git a/lib/tools.in b/lib/tools.in index 0d368b8..929826b 100644 --- a/lib/tools.in +++ b/lib/tools.in @@ -1,5 +1,6 @@ #!@BASH@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # This file contains functions shared between ninjahelper and backupninja. diff --git a/lib/vserver.in b/lib/vserver.in index cc96a71..b356b2b 100644 --- a/lib/vserver.in +++ b/lib/vserver.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: ##################################################### ## VSERVERS RELATED FUNCTIONS FOR NINJAHELPER diff --git a/src/backupninja.in b/src/backupninja.in index ca5074c..a158715 100755 --- a/src/backupninja.in +++ b/src/backupninja.in @@ -1,5 +1,6 @@ #!@BASH@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # |\_ # B A C K U P N I N J A /()/ diff --git a/src/ninjahelper.in b/src/ninjahelper.in index 7bbef1f..2a7faa9 100755 --- a/src/ninjahelper.in +++ b/src/ninjahelper.in @@ -1,5 +1,6 @@ #!@BASH@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: #################################################### ## Functions diff --git a/src/ninjareport.in b/src/ninjareport.in index 56a7209..4bc244e 100755 --- a/src/ninjareport.in +++ b/src/ninjareport.in @@ -1,5 +1,6 @@ #!@BASH@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # # Ninjareport - generate a single simple report for a lot of hosts -- cgit v1.2.3 From f9672647177f771270f40a858fb94283ff1ebcdf Mon Sep 17 00:00:00 2001 From: intrigeri Date: Thu, 19 Nov 2009 20:27:46 +0100 Subject: ldap, mysql, pgsql: use gzip's --rsyncable option --- ChangeLog | 5 +++++ handlers/ldap.in | 2 +- handlers/mysql.in | 4 ++-- handlers/pgsql.in | 8 ++++---- 4 files changed, 12 insertions(+), 7 deletions(-) (limited to 'handlers/mysql.in') diff --git a/ChangeLog b/ChangeLog index c91ca38..4a4a3b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,8 @@ version 0.9.7 -- UNRELEASED file or in a given backup action file. Thanks Tuomas Jormola for the preliminary patch (Closes: #511299) handler changes + ldap: + . Use gzip's --rsyncable option. maildir: . fix location of deleted_on file . add missing destid_file options to ssh connections @@ -20,6 +22,9 @@ version 0.9.7 -- UNRELEASED does not prevent mysqldump to work. . Fix the error message displayed when mysqld is not running: mysqladmin ping indeed returns 0 when authentication fails. + . Use gzip's --rsyncable option. + pgsql: + . Use gzip's --rsyncable option. sys: . New luksheaders option (default=disabled) to backup the Luks header of every Luks device. diff --git a/handlers/ldap.in b/handlers/ldap.in index 5f402c7..853cefb 100644 --- a/handlers/ldap.in +++ b/handlers/ldap.in @@ -86,7 +86,7 @@ if [ "$ldif" == "yes" ]; then fi if [ "$compress" == "yes" ]; then - execstr="$execstr | $GZIP > $dumpdir/$dbsuffix.ldif.gz" + execstr="$execstr | $GZIP --rsyncable > $dumpdir/$dbsuffix.ldif.gz" else execstr="$execstr > $dumpdir/$dbsuffix.ldif" fi diff --git a/handlers/mysql.in b/handlers/mysql.in index 88ffb1a..e1e89b0 100644 --- a/handlers/mysql.in +++ b/handlers/mysql.in @@ -272,7 +272,7 @@ then fatal "mysqld doesn't appear to be running!" fi if [ "$compress" == "yes" ]; then - execstr="$VSERVER $vsname exec $DUMP | $GZIP > $vroot$dumpdir/${db}.sql.gz" + execstr="$VSERVER $vsname exec $DUMP | $GZIP --rsyncable > $vroot$dumpdir/${db}.sql.gz" else execstr="$VSERVER $vsname exec $DUMP -r $vroot$dumpdir/${db}.sql" fi @@ -283,7 +283,7 @@ then fatal "mysqld doesn't appear to be running!" fi if [ "$compress" == "yes" ]; then - execstr="$DUMP | $GZIP > $dumpdir/${db}.sql.gz" + execstr="$DUMP | $GZIP --rsyncable > $dumpdir/${db}.sql.gz" else execstr="$DUMP -r $dumpdir/${db}.sql" fi diff --git a/handlers/pgsql.in b/handlers/pgsql.in index ff5f7ba..a7e3ec2 100644 --- a/handlers/pgsql.in +++ b/handlers/pgsql.in @@ -75,13 +75,13 @@ chmod 700 $vroot$backupdir if [ "$databases" == "all" ]; then if [ $usevserver = yes ]; then if [ "$compress" == "yes" ]; then - execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMPALL | $GZIP > $backupdir/${vsname}.sql.gz\"" + execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMPALL | $GZIP --rsyncable > $backupdir/${vsname}.sql.gz\"" else execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMPALL > $backupdir/${vsname}.sql\"" fi else if [ "$compress" == "yes" ]; then - execstr="su - $PGSQLUSER -c \"$PGSQLDUMPALL | $GZIP > $backupdir/${localhost}-all.sql.gz\"" + execstr="su - $PGSQLUSER -c \"$PGSQLDUMPALL | $GZIP --rsyncable > $backupdir/${localhost}-all.sql.gz\"" else execstr="su - $PGSQLUSER -c \"$PGSQLDUMPALL > $backupdir/${localhost}-all.sql\"" fi @@ -104,13 +104,13 @@ else for db in $databases; do if [ $usevserver = yes ]; then if [ "$compress" == "yes" ]; then - execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMP $db | $GZIP > $backupdir/${db}.sql.gz\"" + execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMP $db | $GZIP --rsyncable > $backupdir/${db}.sql.gz\"" else execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMP $db | > $backupdir/${db}.sql\"" fi else if [ "$compress" == "yes" ]; then - execstr="su - $PGSQLUSER -c \"$PGSQLDUMP $db | $GZIP > $backupdir/${db}.sql.gz\"" + execstr="su - $PGSQLUSER -c \"$PGSQLDUMP $db | $GZIP --rsyncable > $backupdir/${db}.sql.gz\"" else execstr="su - $PGSQLUSER -c \"$PGSQLDUMP $db > $backupdir/${db}.sql\"" fi -- cgit v1.2.3 From f4ab3148f175f8ac415b01fea61d14a80f4de969 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Fri, 25 Dec 2009 02:33:13 +0100 Subject: mysql, pgsql: Quote output filenames ... to support shell meta-characters in database names. Closes Redmine bug #617. --- ChangeLog | 4 ++++ NEWS | 9 +++++++++ handlers/mysql.in | 8 ++++---- handlers/pgsql.in | 16 ++++++++-------- 4 files changed, 25 insertions(+), 12 deletions(-) (limited to 'handlers/mysql.in') diff --git a/ChangeLog b/ChangeLog index 9a6ccaa..97d4353 100644 --- a/ChangeLog +++ b/ChangeLog @@ -26,8 +26,12 @@ version 0.9.7 -- UNRELEASED . Fix the error message displayed when mysqld is not running: mysqladmin ping indeed returns 0 when authentication fails. . Use gzip's --rsyncable option. + . Quote output filenames to support shell meta-characters in + database names. pgsql: . Use gzip's --rsyncable option. + . Quote output filenames to support shell meta-characters in + database names. sys: . New luksheaders option (default=disabled) to backup the Luks header of every Luks device. diff --git a/NEWS b/NEWS index 361cf3c..ef8592e 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,12 @@ +backupninja (0.9.7-1) UNRELEASED + + * mysql: output filenames to support shell meta-characters in + database names. This change was not heavily tested, please + report any breakage. + * pgsql: output filenames to support shell meta-characters in + database names. This change was not heavily tested, please + report any breakage. + backupninja (0.9.4-1) UNRELEASED * duplicity: Old (pre-0.9.4) example.dup file used to give false diff --git a/handlers/mysql.in b/handlers/mysql.in index e1e89b0..0aa3abb 100644 --- a/handlers/mysql.in +++ b/handlers/mysql.in @@ -272,9 +272,9 @@ then fatal "mysqld doesn't appear to be running!" fi if [ "$compress" == "yes" ]; then - execstr="$VSERVER $vsname exec $DUMP | $GZIP --rsyncable > $vroot$dumpdir/${db}.sql.gz" + execstr="$VSERVER $vsname exec $DUMP | $GZIP --rsyncable > '$vroot$dumpdir/${db}.sql.gz'" else - execstr="$VSERVER $vsname exec $DUMP -r $vroot$dumpdir/${db}.sql" + execstr="$VSERVER $vsname exec $DUMP -r '$vroot$dumpdir/${db}.sql'" fi else # Test to make sure mysqld is running, if it is not sqldump will not work @@ -283,9 +283,9 @@ then fatal "mysqld doesn't appear to be running!" fi if [ "$compress" == "yes" ]; then - execstr="$DUMP | $GZIP --rsyncable > $dumpdir/${db}.sql.gz" + execstr="$DUMP | $GZIP --rsyncable > '$dumpdir/${db}.sql.gz'" else - execstr="$DUMP -r $dumpdir/${db}.sql" + execstr="$DUMP -r '$dumpdir/${db}.sql'" fi fi debug "su $user -c \"$execstr\"" diff --git a/handlers/pgsql.in b/handlers/pgsql.in index a7e3ec2..d7839fb 100644 --- a/handlers/pgsql.in +++ b/handlers/pgsql.in @@ -75,15 +75,15 @@ chmod 700 $vroot$backupdir if [ "$databases" == "all" ]; then if [ $usevserver = yes ]; then if [ "$compress" == "yes" ]; then - execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMPALL | $GZIP --rsyncable > $backupdir/${vsname}.sql.gz\"" + execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMPALL | $GZIP --rsyncable > '$backupdir/${vsname}.sql.gz'\"" else - execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMPALL > $backupdir/${vsname}.sql\"" + execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMPALL > '$backupdir/${vsname}.sql'\"" fi else if [ "$compress" == "yes" ]; then - execstr="su - $PGSQLUSER -c \"$PGSQLDUMPALL | $GZIP --rsyncable > $backupdir/${localhost}-all.sql.gz\"" + execstr="su - $PGSQLUSER -c \"$PGSQLDUMPALL | $GZIP --rsyncable > '$backupdir/${localhost}-all.sql.gz'\"" else - execstr="su - $PGSQLUSER -c \"$PGSQLDUMPALL > $backupdir/${localhost}-all.sql\"" + execstr="su - $PGSQLUSER -c \"$PGSQLDUMPALL > '$backupdir/${localhost}-all.sql'\"" fi fi debug "$execstr" @@ -104,15 +104,15 @@ else for db in $databases; do if [ $usevserver = yes ]; then if [ "$compress" == "yes" ]; then - execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMP $db | $GZIP --rsyncable > $backupdir/${db}.sql.gz\"" + execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMP $db | $GZIP --rsyncable > '$backupdir/${db}.sql.gz'\"" else - execstr="$VSERVER $vsname exec su - $PGSQLUSER -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 - $PGSQLUSER -c \"$PGSQLDUMP $db | $GZIP --rsyncable > $backupdir/${db}.sql.gz\"" + execstr="su - $PGSQLUSER -c \"$PGSQLDUMP $db | $GZIP --rsyncable > '$backupdir/${db}.sql.gz'\"" else - execstr="su - $PGSQLUSER -c \"$PGSQLDUMP $db > $backupdir/${db}.sql\"" + execstr="su - $PGSQLUSER -c \"$PGSQLDUMP $db > '$backupdir/${db}.sql'\"" fi fi debug "$execstr" -- cgit v1.2.3 From d65fa0c058b6a2e91126e1634aafd130807f58bd Mon Sep 17 00:00:00 2001 From: intrigeri Date: Tue, 5 Jan 2010 13:09:38 +0100 Subject: Cherry-picked "fixes for mysql handler for mysqld inside a vserver" This commit (64edfccf7684d9c080e734b25fa9361f0190afec) was wrongly committed to the debian branch. Conflicts: handlers/mysql.in --- handlers/mysql.in | 119 +++++++++++++++++++++++++++++------------------------- 1 file changed, 63 insertions(+), 56 deletions(-) (limited to 'handlers/mysql.in') diff --git a/handlers/mysql.in b/handlers/mysql.in index 0aa3abb..3b7423f 100644 --- a/handlers/mysql.in +++ b/handlers/mysql.in @@ -88,29 +88,35 @@ defaultsfile="" if [ "$dbusername" != "" -a "$dbpassword" != "" ] then - if [ $usevserver = yes ] - then - vhome=`$VSERVER $vsname exec getent passwd "root" | @AWK@ -F: '{print $6}'` - home="$vroot$vhome" - else - home=`getent passwd "root" | @AWK@ -F: '{print $6}'` - fi + if [ $usevserver = yes ] + then + home=`$VSERVER $vsname exec getent passwd "root" | @AWK@ -F: '{print $6}'` + else + home=`getent passwd "root" | @AWK@ -F: '{print $6}'` + fi - [ -d $home ] || fatal "Can't find root's home directory ($home)." + [ -d $home ] || fatal "Can't find root's home directory ($home)." + + mycnf="$home/.my.cnf" - mycnf="$home/.my.cnf" - - if [ -f $mycnf ] - then - # rename temporarily - tmpcnf="$home/my.cnf.disable" - debug "mv $mycnf $tmpcnf" - mv $mycnf $tmpcnf - fi + if [ $usevserver = yes ] + then + workcnf="$vroot$mycnf" + else + workcnf="$mycnf" + fi - oldmask=`umask` - umask 077 - cat > $mycnf < $workcnf < Date: Tue, 5 Jan 2010 13:11:57 +0100 Subject: Fix indentation of previously cherry-picked patch --- handlers/mysql.in | 98 +++++++++++++++++++++++++++---------------------------- 1 file changed, 49 insertions(+), 49 deletions(-) (limited to 'handlers/mysql.in') diff --git a/handlers/mysql.in b/handlers/mysql.in index 3b7423f..f3230ad 100644 --- a/handlers/mysql.in +++ b/handlers/mysql.in @@ -88,35 +88,35 @@ defaultsfile="" if [ "$dbusername" != "" -a "$dbpassword" != "" ] then - if [ $usevserver = yes ] - then - home=`$VSERVER $vsname exec getent passwd "root" | @AWK@ -F: '{print $6}'` - else - home=`getent passwd "root" | @AWK@ -F: '{print $6}'` - fi + if [ $usevserver = yes ] + then + home=`$VSERVER $vsname exec getent passwd "root" | @AWK@ -F: '{print $6}'` + else + home=`getent passwd "root" | @AWK@ -F: '{print $6}'` + fi - [ -d $home ] || fatal "Can't find root's home directory ($home)." + [ -d $home ] || fatal "Can't find root's home directory ($home)." - mycnf="$home/.my.cnf" + mycnf="$home/.my.cnf" - if [ $usevserver = yes ] - then + if [ $usevserver = yes ] + then workcnf="$vroot$mycnf" - else + else workcnf="$mycnf" - fi + fi - if [ -f $workcnf ] - then + if [ -f $workcnf ] + then # rename temporarily tmpcnf="$workcnf.disable" debug "mv $workcnf $tmpcnf" mv $workcnf $tmpcnf - fi + fi - oldmask=`umask` - umask 077 - cat > $workcnf < $workcnf < Date: Fri, 8 Jan 2010 23:40:23 +0100 Subject: ldap,mysql,pgsql: use bash pipefail option so that failed dumps are reported as such This should fix Redmine bug #1340. This option makes pipelines return as status the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands exit successfully. See bash(1) for details. E.g. this prevents the following from exiting with status 0 (!) if pg_dumpall fails: pg_dumpall | gzip --- ChangeLog | 6 ++++++ handlers/ldap.in | 2 +- handlers/mysql.in | 8 ++++---- handlers/pgsql.in | 8 ++++---- 4 files changed, 15 insertions(+), 9 deletions(-) (limited to 'handlers/mysql.in') diff --git a/ChangeLog b/ChangeLog index 130a544..18ed157 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,8 @@ version 0.9.7 -- UNRELEASED handler changes ldap: . Use gzip's --rsyncable option. + . Use bash pipefail option when needed so that failed dumps are + reported as such. maildir: . fix location of deleted_on file . add missing destid_file options to ssh connections @@ -32,10 +34,14 @@ version 0.9.7 -- UNRELEASED . Use gzip's --rsyncable option. . Quote output filenames to support shell meta-characters in database names. + . Use bash pipefail option when needed so that failed dumps are + reported as such. pgsql: . Use gzip's --rsyncable option. . Quote output filenames to support shell meta-characters in database names. + . Use bash pipefail option when needed so that failed dumps are + reported as such. sys: . New luksheaders option (default=disabled) to backup the Luks header of every Luks device. diff --git a/handlers/ldap.in b/handlers/ldap.in index 853cefb..fda24d0 100644 --- a/handlers/ldap.in +++ b/handlers/ldap.in @@ -91,7 +91,7 @@ if [ "$ldif" == "yes" ]; then execstr="$execstr > $dumpdir/$dbsuffix.ldif" fi debug "$execstr" - output=`su root -c "$execstr" 2>&1` + output=`su root -c "set -o pipefail ; $execstr" 2>&1` code=$? if [ "$code" == "0" ]; then debug $output diff --git a/handlers/mysql.in b/handlers/mysql.in index f3230ad..3488c51 100644 --- a/handlers/mysql.in +++ b/handlers/mysql.in @@ -237,14 +237,14 @@ then then if [ $usevserver = yes ] then - debug '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` + debug 'set -o pipefail ; echo show databases | $VSERVER $vsname exec su $user -c \"$MYSQL $defaultsfile\" | grep -v Database' + databases=`set -o pipefail ; echo 'show databases' | $VSERVER $vsname exec su $user -c "$MYSQL $defaultsfile" | grep -v Database` if [ $? -ne 0 ] then fatal "Authentication problem, maybe user/password is wrong or mysqld is not running?" fi else - databases=$(su $user -c "$MYSQL $defaultsfile -N -B -e 'show databases'" | sed 's/|//g;/\+----/d') + databases=$(set -o pipefail ; su $user -c "$MYSQL $defaultsfile -N -B -e 'show databases'" | sed 's/|//g;/\+----/d') if [ $? -ne 0 ] then fatal "Authentication problem, maybe user/password is wrong or mysqld is not running?" @@ -298,7 +298,7 @@ then debug "su $user -c \"$execstr\"" if [ ! $test ] then - output=`su $user -c "$execstr" 2>&1` + output=`su $user -c "set -o pipefail ; $execstr" 2>&1` code=$? if [ "$code" == "0" ] then diff --git a/handlers/pgsql.in b/handlers/pgsql.in index d7839fb..77a73fe 100644 --- a/handlers/pgsql.in +++ b/handlers/pgsql.in @@ -75,13 +75,13 @@ chmod 700 $vroot$backupdir if [ "$databases" == "all" ]; then if [ $usevserver = yes ]; then if [ "$compress" == "yes" ]; then - execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMPALL | $GZIP --rsyncable > '$backupdir/${vsname}.sql.gz'\"" + execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"set -o pipefail ; $PGSQLDUMPALL | $GZIP --rsyncable > '$backupdir/${vsname}.sql.gz'\"" else execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMPALL > '$backupdir/${vsname}.sql'\"" fi else if [ "$compress" == "yes" ]; then - execstr="su - $PGSQLUSER -c \"$PGSQLDUMPALL | $GZIP --rsyncable > '$backupdir/${localhost}-all.sql.gz'\"" + execstr="su - $PGSQLUSER -c \"set -o pipefail ; $PGSQLDUMPALL | $GZIP --rsyncable > '$backupdir/${localhost}-all.sql.gz'\"" else execstr="su - $PGSQLUSER -c \"$PGSQLDUMPALL > '$backupdir/${localhost}-all.sql'\"" fi @@ -104,13 +104,13 @@ else for db in $databases; do if [ $usevserver = yes ]; then if [ "$compress" == "yes" ]; then - execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMP $db | $GZIP --rsyncable > '$backupdir/${db}.sql.gz'\"" + execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"set -o pipefail ; $PGSQLDUMP $db | $GZIP --rsyncable > '$backupdir/${db}.sql.gz'\"" else execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMP $db | > '$backupdir/${db}.sql'\"" fi else if [ "$compress" == "yes" ]; then - execstr="su - $PGSQLUSER -c \"$PGSQLDUMP $db | $GZIP --rsyncable > '$backupdir/${db}.sql.gz'\"" + execstr="su - $PGSQLUSER -c \"set -o pipefail ; $PGSQLDUMP $db | $GZIP --rsyncable > '$backupdir/${db}.sql.gz'\"" else execstr="su - $PGSQLUSER -c \"$PGSQLDUMP $db > '$backupdir/${db}.sql'\"" fi -- cgit v1.2.3