diff options
Diffstat (limited to 'handlers/dup.in')
-rw-r--r-- | handlers/dup.in | 99 |
1 files changed, 32 insertions, 67 deletions
diff --git a/handlers/dup.in b/handlers/dup.in index 5216643..e3475b8 100644 --- a/handlers/dup.in +++ b/handlers/dup.in @@ -2,7 +2,7 @@ # vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # duplicity script for backupninja -# requires duplicity +# requires duplicity >= 0.4.4, and >= 0.4.9 when using a custom tmpdir. # getconf options @@ -106,35 +106,14 @@ 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}'`" -### ssh/scp/sftp options -# 1. duplicity >= 0.4.2 needs --sftp-command -# (NB: sftp does not support the -l option) -# 2. duplicity 0.4.3 to 0.4.9 replace --ssh-command with --ssh-options, which is -# passed to scp and sftp commands by duplicity. 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 - +### ssh/scp/sftp options (duplicity < 0.4.3 is unsupported) scpoptions="$sshoptions" if [ "$bandwidthlimit" != 0 ]; then [ -z "$desturl" ] || warning 'The bandwidthlimit option is not used when desturl is set.' scpoptions="$scpoptions -l $bandwidthlimit" fi - -# < 0.4.2 : only uses ssh and scp -if [ "$duplicity_major" -le 0 -a "$duplicity_minor" -le 4 -a "$duplicity_sub" -lt 2 ]; then - execstr_options="${execstr_options} --scp-command 'scp $scpoptions' --ssh-command 'ssh $sshoptions'" -# >= 0.4.2 : also uses sftp, --sftp-command option is now supported -else - sftpoptions="$sshoptions" - # == 0.4.2 : uses ssh, scp and sftp - if [ "$duplicity_major" -eq 0 -a "$duplicity_minor" -eq 4 -a "$duplicity_sub" -eq 2 ]; then - execstr_options="${execstr_options} --scp-command 'scp $scpoptions' --sftp-command 'sftp $sftpoptions' --ssh-command 'ssh $sshoptions'" - # >= 0.4.3 : uses only scp and sftp, --ssh-command option is not supported anymore - else - execstr_options="${execstr_options} --scp-command 'scp $scpoptions' --sftp-command 'sftp $sftpoptions'" - fi -fi +sftpoptions="$sshoptions" +execstr_options="${execstr_options} --scp-command 'scp $scpoptions' --sftp-command 'sftp $sftpoptions'" ### Symmetric or asymmetric (public/private key pair) encryption if [ -n "$encryptkey" ]; then @@ -162,12 +141,7 @@ fi # full backup. # If incremental==no, force a full backup anyway. if [ "$incremental" == "no" ]; then - # before 0.4.4, full was an option and not a command - if [ "$duplicity_major" -le 0 -a "$duplicity_minor" -le 4 -a "$duplicity_sub" -lt 4 ]; then - execstr_options="${execstr_options} --full" - else - execstr_command="full" - fi + execstr_command="full" else # we're in incremental mode if [ "$increments" != "keep" ]; then @@ -185,7 +159,6 @@ if [ "$duplicity_major" -ge 0 -a "$duplicity_minor" -ge 6 -a "$duplicity_sub" -g fi ### Temporary directory -precmd= if [ -n "$tmpdir" ]; then if [ ! -d "$tmpdir" ]; then info "Temporary directory ($tmpdir) does not exist, creating it." @@ -194,7 +167,7 @@ if [ -n "$tmpdir" ]; then chmod 0700 "$tmpdir" fi info "Using $tmpdir as TMPDIR" - precmd="${precmd}TMPDIR=$tmpdir " + execstr_options="${execstr_options} --tempdir '$tmpdir'" fi ### Archive directory @@ -211,10 +184,6 @@ if [ "$keep" != "yes" ]; then if [ "`echo $keep | tr -d 0-9`" == "" ]; then keep="${keep}D" fi - # before 0.4.4, remove-older-than was an option and not a command - if [ "$duplicity_major" -le 0 -a "$duplicity_minor" -le 4 -a "$duplicity_sub" -lt 4 ]; then - execstr_options="${execstr_options} --remove-older-than $keep" - fi fi ### Source @@ -269,56 +238,52 @@ fi ### Cleanup commands (duplicity >= 0.4.4) # cleanup -if [ "$duplicity_major" -ge 0 -a "$duplicity_minor" -ge 4 -a "$duplicity_sub" -ge 4 ]; then - debug "$precmd duplicity cleanup --force $execstr_options $execstr_serverpart" +debug "duplicity cleanup --force $execstr_options $execstr_serverpart" +if [ ! $test ]; then + export PASSPHRASE=$password + export FTP_PASSWORD=$ftp_password + output=`nice -n $nicelevel \ + su -c \ + "duplicity cleanup --force $execstr_options $execstr_serverpart 2>&1"` + exit_code=$? + if [ $exit_code -eq 0 ]; then + debug $output + info "Duplicity cleanup finished successfully." + else + debug $output + warning "Duplicity cleanup failed." + fi +fi + +# remove-older-than +if [ "$keep" != "yes" ]; then + debug "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 cleanup --force $execstr_options $execstr_serverpart 2>&1"` + su -c \ + "duplicity remove-older-than $keep --force $execstr_options $execstr_serverpart 2>&1"` exit_code=$? if [ $exit_code -eq 0 ]; then debug $output - info "Duplicity cleanup finished successfully." + info "Duplicity remove-older-than finished successfully." else debug $output - warning "Duplicity cleanup failed." - fi - fi -fi - -# remove-older-than -if [ "$keep" != "yes" ]; then - if [ "$duplicity_major" -ge 0 -a "$duplicity_minor" -ge 4 -a "$duplicity_sub" -ge 4 ]; 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"` - exit_code=$? - if [ $exit_code -eq 0 ]; then - debug $output - info "Duplicity remove-older-than finished successfully." - else - debug $output - warning "Duplicity remove-older-than failed." - fi + warning "Duplicity remove-older-than failed." fi fi fi ### Backup command -debug "$precmd duplicity $execstr_command $execstr_options $execstr_source --exclude '**' / $execstr_serverpart" +debug "duplicity $execstr_command $execstr_options $execstr_source --exclude '**' / $execstr_serverpart" 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"` + "duplicity $execstr_command $execstr_options $execstr_source --exclude '**' / $execstr_serverpart >$outputfile 2>&1"` exit_code=$? debug $output cat $outputfile | (while read output ; do |