aboutsummaryrefslogtreecommitdiff
path: root/handlers/dup.in
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2010-08-26 02:04:13 +0200
committerintrigeri <intrigeri@boum.org>2010-08-26 02:04:13 +0200
commit93041732b3ccffa113693af8480d69fc080d9ec1 (patch)
treeb2950b49cba6a22b448a7e88819c2ac6c26847ad /handlers/dup.in
parente6c65815c8201d123f477e05a367832204c39886 (diff)
parent40155781065eb7254eb9fc9c48bd85b0b8ace4c0 (diff)
downloadbackupninja-93041732b3ccffa113693af8480d69fc080d9ec1.tar.gz
backupninja-93041732b3ccffa113693af8480d69fc080d9ec1.tar.bz2
Merge branch 'master' into debian
Conflicts: examples/example.ldap
Diffstat (limited to 'handlers/dup.in')
-rw-r--r--handlers/dup.in35
1 files changed, 33 insertions, 2 deletions
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"`