diff options
Diffstat (limited to 'handlers')
-rw-r--r-- | handlers/dup.helper.in | 37 | ||||
-rw-r--r-- | handlers/dup.in | 35 | ||||
-rw-r--r-- | handlers/ldap.in | 2 | ||||
-rw-r--r-- | handlers/mysql.in | 23 | ||||
-rw-r--r-- | handlers/pgsql.in | 8 | ||||
-rw-r--r-- | handlers/rdiff.helper.in | 2 | ||||
-rwxr-xr-x | handlers/sys.in | 4 |
7 files changed, 86 insertions, 25 deletions
diff --git a/handlers/dup.helper.in b/handlers/dup.helper.in index 8b344dc..e985c5e 100644 --- a/handlers/dup.helper.in +++ b/handlers/dup.helper.in @@ -123,6 +123,7 @@ do_dup_dest() { formItem "destdir" "$dup_destdir" formItem "keep" "$dup_keep" formItem "incremental" "$dup_incremental" + formItem "increments" "$dup_increments" formItem "bandwidthlimit" "$dup_bandwidth" formItem "sshoptions" "$dup_sshoptions" formDisplay @@ -139,8 +140,9 @@ do_dup_dest() { dup_destdir=${thereply[2]} dup_keep=${thereply[3]} dup_incremental=${thereply[4]} - dup_bandwidth=${thereply[5]} - dup_sshoptions=${thereply[6]} + dup_increments=${thereply[5]} + dup_bandwidth=${thereply[6]} + dup_sshoptions=${thereply[7]} done set +o noglob @@ -278,7 +280,8 @@ options = $dup_options # default is 0, but set to 19 if you want to lower the priority. nicelevel = $dup_nicelevel -# default is yes. set to no to skip the test if the remote host is alive +# default is yes. set to no to skip the test if the remote host is alive. +# if 'desturl' is set below, 'testconnect' must be set to 'no' for now. testconnect = $dup_testconnect ###################################################### @@ -406,6 +409,14 @@ EOF # if incremental = no, perform a full backup in order to start a new backup set incremental = $dup_incremental +# how many days of incremental backups before doing a full backup again ; +# default is 30 days (one can also use the time format of duplicity). +# if increments = keep, never automatically perform a new full backup ; +# only perform incremental backups. +#increments = 30 +#increments = keep +increments = $dup_increments + # how many days of data to keep ; default is 60 days. # (you can also use the time format of duplicity) # 'keep = yes' means : do not delete old data, the remote host will take care of this @@ -419,13 +430,19 @@ keep = $dup_keep #desturl = file:///usr/local/backup #desturl = rsync://user@other.host//var/backup/bla #desturl = s3+http://your_bucket +#desturl = ftp://myftpuser@ftp.example.org/remote/ftp/path # Amazon Web Services Access Key ID and Secret Access Key, needed for backups # to S3 buckets. #awsaccesskeyid = YOUR_AWS_ACCESS_KEY_ID #awssecretaccesskey = YOUR_AWS_SECRET_KEY +# FTP password, needed for backups using desturl = ftp://... +#ftp_password = + # bandwith limit, in kbit/s ; default is 0, i.e. no limit +# if using 'desturl' above, 'bandwidthlimit' must not be set +# an example setting of 128 kbps would be: #bandwidthlimit = 128 bandwidthlimit = $dup_bandwidth @@ -435,15 +452,20 @@ bandwidthlimit = $dup_bandwidth #sshoptions = -o IdentityFile=/root/.ssh/id_dsa_duplicity sshoptions = $dup_sshoptions -# put the backups under this directory +# put the backups under this destination directory +# if using 'desturl' above, this must not be set +# in all other cases, this must be set! destdir = $dup_destdir # the machine which will receive the backups +# if using 'desturl' above, this must not be set +# in all other cases, this must be set! desthost = $dup_desthost # make the files owned by this user -# note: you must be able to ssh backupuser@backhost -# without specifying a password (if type = remote). +# if using 'desturl' above, this must not be set +# note: if using an SSH based transport and 'type' is set to 'remote', you must +# be able to 'ssh backupuser@backuphost' without specifying a password. destuser = $dup_destuser EOF @@ -510,6 +532,7 @@ dup_wizard() { dup_excludes= dup_vsincludes= dup_incremental=yes + dup_increments=30 dup_keep=60 dup_bandwidth= dup_sshoptions= @@ -529,7 +552,7 @@ dup_wizard() { # Global variables whose '*' shall not be expanded set -o noglob dup_default_includes="/var/spool/cron/crontabs /var/backups /etc /root /home /usr/local/*bin /var/lib/dpkg/status*" - dup_default_excludes="/home/*/.gnupg /home/*/.local/share/Trash /home/*/.Trash /home/*/.thumbnails /home/*/.beagle /home/*/.aMule /home/*/gtk-gnutella-downloads" + dup_default_excludes="/home/*/.gnupg /home/*/.local/share/Trash /home/*/.Trash /home/*/.thumbnails /home/*/.beagle /home/*/.aMule /home/*/gtk-gnutella-downloads /var/cache/backupninja/duplicity" set +o noglob dup_main_menu diff --git a/handlers/dup.in b/handlers/dup.in index ffae48c..5216643 100644 --- a/handlers/dup.in +++ b/handlers/dup.in @@ -24,10 +24,12 @@ getconf exclude setsection dest getconf incremental yes +getconf increments 30 getconf keep 60 getconf desturl getconf awsaccesskeyid getconf awssecretaccesskey +getconf ftp_password getconf sshoptions getconf bandwidthlimit 0 getconf desthost @@ -43,6 +45,9 @@ destdir=${destdir%/} if [ "`echo $desturl | @AWK@ -F ':' '{print $1}'`" == "s3+http" ]; then [ -n "$awsaccesskeyid" -a -n "$awssecretaccesskey" ] || fatal "AWS access keys must be set for S3 backups." fi +if [ "`echo $desturl | @AWK@ -F ':' '{print $1}'`" == "ftp" ]; then + [ -n "$ftp_password" ] || fatal "ftp_password must be set for FTP backups." +fi ### VServers # If vservers are configured, check that the ones listed in $vsnames do exist. @@ -95,8 +100,8 @@ else execstr_serverpart="scp://$destuser@$desthost/$destdir" fi -### duplicity version -duplicity_version="`duplicity --version | @AWK@ '{print $2}'`" +### duplicity version (ignore anything else than 0-9 and ".") +duplicity_version="`duplicity --version | @AWK@ '{print $2}' | @SED@ 's/[^.[:digit:]]//g'`" duplicity_major="`echo $duplicity_version | @AWK@ -F '.' '{print $1}'`" duplicity_minor="`echo $duplicity_version | @AWK@ -F '.' '{print $2}'`" duplicity_sub="`echo $duplicity_version | @AWK@ -F '.' '{print $3}'`" @@ -163,6 +168,20 @@ if [ "$incremental" == "no" ]; then else execstr_command="full" fi +else + # we're in incremental mode + if [ "$increments" != "keep" ]; then + # if we don't want to keep every increments + if [ "`echo $increments | tr -d 0-9`" == "" ]; then + increments="${increments}D" + fi + execstr_options="${execstr_options} --full-if-older-than $increments" + fi +fi + +### Cleanup options +if [ "$duplicity_major" -ge 0 -a "$duplicity_minor" -ge 6 -a "$duplicity_sub" -ge 1 ]; then + execstr_options="${execstr_options} --extra-clean" fi ### Temporary directory @@ -178,6 +197,15 @@ if [ -n "$tmpdir" ]; then precmd="${precmd}TMPDIR=$tmpdir " fi +### Archive directory +# duplicity >= 0.6.01 enables the archive_dir by default, let's put it into /var/cache/backupninja/duplicity +# unless the user has specified it. +if [ "$duplicity_major" -ge 0 -a "$duplicity_minor" -ge 6 -a "$duplicity_sub" -ge 1 ]; then + if echo "${options}" | grep -qv -- "--archive-dir" ; then + execstr_options="${execstr_options} --archive-dir /var/cache/backupninja/duplicity" + fi +fi + ### Cleanup old backup sets (or not) if [ "$keep" != "yes" ]; then if [ "`echo $keep | tr -d 0-9`" == "" ]; then @@ -245,6 +273,7 @@ if [ "$duplicity_major" -ge 0 -a "$duplicity_minor" -ge 4 -a "$duplicity_sub" -g debug "$precmd duplicity cleanup --force $execstr_options $execstr_serverpart" if [ ! $test ]; then export PASSPHRASE=$password + export FTP_PASSWORD=$ftp_password output=`nice -n $nicelevel \ su -c \ "$precmd duplicity cleanup --force $execstr_options $execstr_serverpart 2>&1"` @@ -265,6 +294,7 @@ if [ "$keep" != "yes" ]; then debug "$precmd duplicity remove-older-than $keep --force $execstr_options $execstr_serverpart" if [ ! $test ]; then export PASSPHRASE=$password + export FTP_PASSWORD=$ftp_password output=`nice -n $nicelevel \ su -c \ "$precmd duplicity remove-older-than $keep --force $execstr_options $execstr_serverpart 2>&1"` @@ -285,6 +315,7 @@ debug "$precmd duplicity $execstr_command $execstr_options $execstr_source --exc if [ ! $test ]; then outputfile=`maketemp backupout` export PASSPHRASE=$password + export FTP_PASSWORD=$ftp_password output=`nice -n $nicelevel \ su -c \ "$precmd duplicity $execstr_command $execstr_options $execstr_source --exclude '**' / $execstr_serverpart >$outputfile 2>&1"` diff --git a/handlers/ldap.in b/handlers/ldap.in index fda24d0..83307ee 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 --rsyncable > $dumpdir/$dbsuffix.ldif.gz" + execstr="$execstr | $GZIP $GZIP_OPTS > $dumpdir/$dbsuffix.ldif.gz" else execstr="$execstr > $dumpdir/$dbsuffix.ldif" fi diff --git a/handlers/mysql.in b/handlers/mysql.in index 3488c51..0282046 100644 --- a/handlers/mysql.in +++ b/handlers/mysql.in @@ -86,7 +86,7 @@ fi defaultsfile="" -if [ "$dbusername" != "" -a "$dbpassword" != "" ] +if [ -n "$dbusername" -a -n "$dbpassword" ] then if [ $usevserver = yes ] then @@ -140,13 +140,10 @@ password="$dbpassword" EOF umask $oldmask defaultsfile="--defaults-extra-file=$mycnf" -fi -# if a user is not set, use $configfile, otherwise use $mycnf -if [ "$user" == "" ]; then - user=root; - defaultsfile="--defaults-extra-file=$configfile" -else +# else, if a user is set use her .my.cnf +elif [ -n "$user" ] +then userset=true; if [ $usevserver = yes ] then @@ -169,6 +166,10 @@ else defaultsfile="--defaults-extra-file=$userhome/.my.cnf" debug "using $defaultsfile" +# otherwise use $configfile +else + user=root + defaultsfile="--defaults-extra-file=$configfile" fi ####################################################################### @@ -255,6 +256,10 @@ then for db in $databases do DUMP_BASE="$MYSQLDUMP $defaultsfile $sqldumpoptions" + if [ "$db" = "information_schema" ] + then + DUMP_BASE="${DUMP_BASE} --skip-lock-tables" + fi # Dumping structure and data DUMP="$DUMP_BASE $ignore $db" @@ -279,7 +284,7 @@ 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 $GZIP_OPTS > '$vroot$dumpdir/${db}.sql.gz'" else execstr="$VSERVER $vsname exec $DUMP -r '$vroot$dumpdir/${db}.sql'" fi @@ -290,7 +295,7 @@ 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 $GZIP_OPTS > '$dumpdir/${db}.sql.gz'" else execstr="$DUMP -r '$dumpdir/${db}.sql'" fi diff --git a/handlers/pgsql.in b/handlers/pgsql.in index 77a73fe..0b7badf 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 \"set -o pipefail ; $PGSQLDUMPALL | $GZIP --rsyncable > '$backupdir/${vsname}.sql.gz'\"" + execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"set -o pipefail ; $PGSQLDUMPALL | $GZIP $GZIP_OPTS > '$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 \"set -o pipefail ; $PGSQLDUMPALL | $GZIP --rsyncable > '$backupdir/${localhost}-all.sql.gz'\"" + execstr="su - $PGSQLUSER -c \"set -o pipefail ; $PGSQLDUMPALL | $GZIP $GZIP_OPTS > '$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 \"set -o pipefail ; $PGSQLDUMP $db | $GZIP --rsyncable > '$backupdir/${db}.sql.gz'\"" + execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"set -o pipefail ; $PGSQLDUMP $db | $GZIP $GZIP_OPTS > '$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 \"set -o pipefail ; $PGSQLDUMP $db | $GZIP --rsyncable > '$backupdir/${db}.sql.gz'\"" + execstr="su - $PGSQLUSER -c \"set -o pipefail ; $PGSQLDUMP $db | $GZIP $GZIP_OPTS > '$backupdir/${db}.sql.gz'\"" else execstr="su - $PGSQLUSER -c \"$PGSQLDUMP $db > '$backupdir/${db}.sql'\"" fi diff --git a/handlers/rdiff.helper.in b/handlers/rdiff.helper.in index e35d629..b5bb8bb 100644 --- a/handlers/rdiff.helper.in +++ b/handlers/rdiff.helper.in @@ -415,7 +415,7 @@ rdiff_wizard() { # Global variables whose '*' shall not be expanded set -o noglob rdiff_includes=(/var/spool/cron/crontabs /var/backups /etc /root /home /usr/local/*bin /var/lib/dpkg/status*) - rdiff_excludes=(/home/*/.gnupg /home/*/.local/share/Trash /home/*/.Trash /home/*/.thumbnails /home/*/.beagle /home/*/.aMule /home/*/gtk-gnutella-downloads) + rdiff_excludes=(/home/*/.gnupg /home/*/.local/share/Trash /home/*/.Trash /home/*/.thumbnails /home/*/.beagle /home/*/.aMule /home/*/gtk-gnutella-downloads /var/cache/backupninja/duplicity) rdiff_vsincludes= set +o noglob diff --git a/handlers/sys.in b/handlers/sys.in index 69751ed..a92663e 100755 --- a/handlers/sys.in +++ b/handlers/sys.in @@ -462,7 +462,9 @@ STATUS="Collecting Software RAID information (/etc/mdadm.conf)" catiffile "/etc/mdadm.conf" STATUS="Collecting Software RAID information (/sbin/mdadm -Q)" -catifexec "/sbin/mdadm" "-Q" "--detail" '/dev/md?*' +if ls /dev/md?* >/dev/null 2>&1; then + catifexec "/sbin/mdadm" "-Q" "--detail" '/dev/md?*' +fi STATUS="Collecting Automount information (auto.master)" catiffile "/etc/auto.master" |