diff options
Diffstat (limited to 'handlers/dup.in')
-rw-r--r-- | handlers/dup.in | 65 |
1 files changed, 50 insertions, 15 deletions
diff --git a/handlers/dup.in b/handlers/dup.in index 40f6723..9eb2fbb 100644 --- a/handlers/dup.in +++ b/handlers/dup.in @@ -30,6 +30,9 @@ getconf keepincroffulls all getconf desturl getconf awsaccesskeyid getconf awssecretaccesskey +getconf cfusername +getconf cfapikey +getconf cfauthurl getconf ftp_password getconf sshoptions getconf bandwidthlimit 0 @@ -46,6 +49,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}'`" == "cf+http" ]; then + [ -n "$cfusername" -a -n "$cfapikey" ] || fatal "Cloudfiles 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 @@ -89,6 +95,7 @@ fi ### COMMAND-LINE MANGLING ###################################################### ### initialize $execstr* +execstr_precmd= execstr_command= execstr_options="$options --no-print-statistics" execstr_source= @@ -108,13 +115,27 @@ duplicity_minor="`echo $duplicity_version | @AWK@ -F '.' '{print $2}'`" duplicity_sub="`echo $duplicity_version | @AWK@ -F '.' '{print $3}'`" ### 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" +## duplicity >= 0.6.17 : paramiko backend +if [ "$duplicity_major" -ge 0 -a "$duplicity_minor" -ge 6 -a "$duplicity_sub" -ge 17 ]; then + if [ -n "$sshoptions" ]; then + echo "$sshoptions" | grep -Eqs '^-o[[:space:]]*IdentityFile=[^ ]+$' \ + || warning 'duplicity >= 0.6.17 only supports the IdentityFile SSH option' + fi + execstr_options="${execstr_options} --ssh-options '$sshoptions'" + if [ "$bandwidthlimit" != 0 ]; then + [ -z "$desturl" ] || warning 'The bandwidthlimit option is not used when desturl is set.' + execstr_precmd="trickle -s -d $bandwidthlimit -u $bandwidthlimit" + fi +## duplicity < 0.6.17 : scp/sftp backend +else + scpoptions="$sshoptions" + if [ "$bandwidthlimit" != 0 ]; then + [ -z "$desturl" ] || warning 'The bandwidthlimit option is not used when desturl is set.' + scpoptions="$scpoptions -l $bandwidthlimit" + fi + sftpoptions="$sshoptions" + execstr_options="${execstr_options} --scp-command 'scp $scpoptions' --sftp-command 'sftp $sftpoptions'" 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 @@ -232,16 +253,26 @@ if [ "`echo $desturl | @AWK@ -F ':' '{print $1}'`" == "s3+http" ]; then export AWS_SECRET_ACCESS_KEY="$awssecretaccesskey" fi +### If desturl is a RackSpace's CloudFiles URL export the relevant +### environment variables +if [ "`echo $desturl | @AWK@ -F ':' '{print $1}'`" == "cf+http" ]; then + export CLOUDFILES_USERNAME="$cfusername" + export CLOUDFILES_APIKEY="$cfapikey" + if [ -n "$cfauthurl" ]; then + export CLOUDFILES_AUTHURL="$cfauthurl" + fi +fi + ### Cleanup commands (duplicity >= 0.4.4) # cleanup -debug "duplicity cleanup --force $execstr_options $execstr_serverpart" +debug "$execstr_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 \ - "duplicity cleanup --force $execstr_options $execstr_serverpart 2>&1"` + "$execstr_precmd duplicity cleanup --force $execstr_options $execstr_serverpart 2>&1"` exit_code=$? if [ $exit_code -eq 0 ]; then debug $output @@ -254,13 +285,13 @@ fi # remove-older-than if [ "$keep" != "yes" ]; then - debug "duplicity remove-older-than $keep --force $execstr_options $execstr_serverpart" + debug "$execstr_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 \ - "duplicity remove-older-than $keep --force $execstr_options $execstr_serverpart 2>&1"` + "$execstr_precmd duplicity remove-older-than $keep --force $execstr_options $execstr_serverpart 2>&1"` exit_code=$? if [ $exit_code -eq 0 ]; then debug $output @@ -276,13 +307,13 @@ fi if [ "$keep" != "yes" ]; then if [ "$keepincroffulls" != "all" ]; then if [ "$duplicity_major" -ge 0 -a "$duplicity_minor" -ge 6 -a "$duplicity_sub" -ge 10 ]; then - debug "$precmd duplicity remove-all-inc-of-but-n-full $keepincroffulls --force $execstr_options $execstr_serverpart" + debug "$execstr_precmd duplicity remove-all-inc-of-but-n-full $keepincroffulls --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-all-inc-of-but-n-full $keepincroffulls --force $execstr_options $execstr_serverpart 2>&1"` + "$execstr_precmd duplicity remove-all-inc-of-but-n-full $keepincroffulls --force $execstr_options $execstr_serverpart 2>&1"` exit_code=$? if [ $exit_code -eq 0 ]; then debug $output @@ -297,18 +328,22 @@ if [ "$keep" != "yes" ]; then fi ### Backup command -debug "duplicity $execstr_command $execstr_options $execstr_source --exclude '**' / $execstr_serverpart" +debug "$execstr_precmd 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 \ - "duplicity $execstr_command $execstr_options $execstr_source --exclude '**' / $execstr_serverpart >$outputfile 2>&1"` + "$execstr_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 + if [ $exit_code -eq 0 ]; then + info $output + else + error $output + fi done ) if [ $exit_code -eq 0 ]; then |