duplicity: clarify comments about duplicity versions compatibility
[matthijs/upstream/backupninja.git] / handlers / dup.in
index 4b286a36c6003bf301e5e33cc645d549822a24b6..055531f3e3dd07ec88a2861d233b1f49532173ad 100644 (file)
@@ -7,6 +7,7 @@
 getconf options
 getconf testconnect yes
 getconf nicelevel 0
+getconf tmpdir
 
 setsection gpg
 getconf password
@@ -78,7 +79,8 @@ duplicity_sub="`echo $duplicity_version | @AWK@ -F '.' '{print $3}'`"
 # 1. duplicity >= 0.4.2 needs --sftp-command (NB: sftp does not support the -l option)
 # 2. duplicity >= 0.4.3 replaces --ssh-command with --ssh-options, which:
 #      - is passed to scp and sftp commands by duplicity
-#      - has a special syntax we can not feed the command line with
+#      - has a special syntax we can not directly feed the command line with
+#        (e.g. "IdentityFile=/root/.ssh/id_dsa_backupninja Port=2222", without the -o)
 #    so we don't use it: since this version does not use the ssh command anymore,
 #    we keep compatibility with our previous config files by passing $sshoptions to
 #    --scp-command and --sftp-command ourselves
@@ -170,16 +172,28 @@ fi
 
 set +o noglob
 
+### deal with tmpdir ###
+precmd=
+if [ -n "$tmpdir" ]; then
+   if [ ! -d "$tmpdir" ]; then
+      info "Temporary directory ($tmpdir) does not exist, creating it."
+      mkdir -p "$tmpdir"
+      [ $? -eq 0 ] || fatal "Could not create temporary directory ($tmpdir)."
+   fi
+   info "Using $tmpdir as TMPDIR"
+   precmd="${precmd}TMPDIR=$tmpdir "
+fi
+
 ### EXECUTE ###
 
 execstr=${execstr//\\*/\\\\\\*}
 
-debug "duplicity $execstr --exclude '**' / $execstr_serverpart"
+debug "$precmd duplicity $execstr --exclude '**' / $execstr_serverpart"
 if [ ! $test ]; then
         export PASSPHRASE=$password
        output=`nice -n $nicelevel \
                   su -c \
-                    "duplicity $execstr --exclude '**' / $execstr_serverpart 2>&1"`
+                    "$precmd duplicity $execstr --exclude '**' / $execstr_serverpart 2>&1"`
        code=$?
        if [ $code -eq 0 ]; then
                debug $output