aboutsummaryrefslogtreecommitdiff
path: root/handlers/dup.in
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2010-01-17 23:54:09 +1300
committerMicah Anderson <micah@riseup.net>2010-01-17 23:54:09 +1300
commitfe3620c6529cc449cd152ed58667e39d4a80257e (patch)
treeec83be42237855979a31f38cdce51f45cdbd7312 /handlers/dup.in
parent18f28c2cb00286cc0ff790ef6b6914f3f22ec4ac (diff)
parent46eccf2fd0c894790405b2e3aae8dfb99f5a5d98 (diff)
downloadbackupninja-fe3620c6529cc449cd152ed58667e39d4a80257e.tar.gz
backupninja-fe3620c6529cc449cd152ed58667e39d4a80257e.tar.bz2
Merge branch 'master' into debian
Conflicts: AUTHORS ChangeLog handlers/maildir.in handlers/mysql.in handlers/rsync.in handlers/sys.helper.in handlers/sys.in src/backupninja.in
Diffstat (limited to 'handlers/dup.in')
-rw-r--r--handlers/dup.in35
1 files changed, 30 insertions, 5 deletions
diff --git a/handlers/dup.in b/handlers/dup.in
index aed6030..ffae48c 100644
--- a/handlers/dup.in
+++ b/handlers/dup.in
@@ -26,6 +26,8 @@ setsection dest
getconf incremental yes
getconf keep 60
getconf desturl
+getconf awsaccesskeyid
+getconf awssecretaccesskey
getconf sshoptions
getconf bandwidthlimit 0
getconf desthost
@@ -38,6 +40,9 @@ destdir=${destdir%/}
[ -n "$desturl" -o -n "$destdir" ] || fatal "The destination directory (destdir) must be set when desturl is not used."
[ -n "$include" -o -n "$vsinclude" ] || fatal "No source includes specified"
[ -n "$password" ] || fatal "The password option must be set."
+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
### VServers
# If vservers are configured, check that the ones listed in $vsnames do exist.
@@ -106,8 +111,8 @@ duplicity_sub="`echo $duplicity_version | @AWK@ -F '.' '{print $3}'`"
# --sftp-command ourselves
scpoptions="$sshoptions"
-if [ "$bandwidthlimit" =! 0 ]; then
- [ -z "$testurl" ] || warning 'The bandwidthlimit option is not used when desturl is set.'
+if [ "$bandwidthlimit" != 0 ]; then
+ [ -z "$desturl" ] || warning 'The bandwidthlimit option is not used when desturl is set.'
scpoptions="$scpoptions -l $bandwidthlimit"
fi
@@ -189,26 +194,35 @@ fi
set -o noglob
# excludes
+SAVEIFS=$IFS
+IFS=$(echo -en "\n\b")
for i in $exclude; do
str="${i//__star__/*}"
execstr_source="${execstr_source} --exclude '$str'"
done
+IFS=$SAVEIFS
# includes
+SAVEIFS=$IFS
+IFS=$(echo -en "\n\b")
for i in $include; do
[ "$i" != "/" ] || fatal "Sorry, you cannot use 'include = /'"
str="${i//__star__/*}"
execstr_source="${execstr_source} --include '$str'"
done
+IFS=$SAVEIFS
# vsincludes
if [ $usevserver = yes ]; then
for vserver in $vsnames; do
+ SAVEIFS=$IFS
+ IFS=$(echo -en "\n\b")
for vi in $vsinclude; do
str="${vi//__star__/*}"
str="$VROOTDIR/$vserver$str"
execstr_source="${execstr_source} --include '$str'"
done
+ IFS=$SAVEIFS
done
fi
@@ -218,6 +232,12 @@ set +o noglob
execstr_source=${execstr_source//\\*/\\\\\\*}
+### If desturl is an S3 URL export the AWS environment variables
+if [ "`echo $desturl | @AWK@ -F ':' '{print $1}'`" == "s3+http" ]; then
+ export AWS_ACCESS_KEY_ID="$awsaccesskeyid"
+ export AWS_SECRET_ACCESS_KEY="$awssecretaccesskey"
+fi
+
### Cleanup commands (duplicity >= 0.4.4)
# cleanup
@@ -263,18 +283,23 @@ fi
### Backup command
debug "$precmd duplicity $execstr_command $execstr_options $execstr_source --exclude '**' / $execstr_serverpart"
if [ ! $test ]; then
+ outputfile=`maketemp backupout`
export PASSPHRASE=$password
output=`nice -n $nicelevel \
su -c \
- "$precmd duplicity $execstr_command $execstr_options $execstr_source --exclude '**' / $execstr_serverpart 2>&1"`
+ "$precmd duplicity $execstr_command $execstr_options $execstr_source --exclude '**' / $execstr_serverpart >$outputfile 2>&1"`
exit_code=$?
+ debug $output
+ cat $outputfile | (while read output ; do
+ info $output
+ done
+ )
if [ $exit_code -eq 0 ]; then
- debug $output
info "Duplicity finished successfully."
else
- debug $output
fatal "Duplicity failed."
fi
+ rm $outputfile
fi
return 0