2005-12-28 21:19:29 +01:00
|
|
|
# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
|
2009-05-22 15:27:09 +02:00
|
|
|
# vim: set filetype=sh sw=3 sts=3 expandtab autoindent:
|
2005-01-19 20:37:20 +01:00
|
|
|
#
|
|
|
|
# duplicity script for backupninja
|
2010-10-12 11:47:15 +02:00
|
|
|
# requires duplicity >= 0.4.4, and >= 0.4.9 when using a custom tmpdir.
|
2005-01-19 20:37:20 +01:00
|
|
|
#
|
|
|
|
|
|
|
|
getconf options
|
2005-05-24 21:08:51 +02:00
|
|
|
getconf testconnect yes
|
|
|
|
getconf nicelevel 0
|
2020-05-16 18:02:43 +02:00
|
|
|
getconf ionicelevel
|
2007-11-26 08:42:24 +01:00
|
|
|
getconf tmpdir
|
2005-05-24 21:08:51 +02:00
|
|
|
|
|
|
|
setsection gpg
|
|
|
|
getconf password
|
2013-11-13 15:18:15 +01:00
|
|
|
getconf signpassword
|
2005-05-24 21:08:51 +02:00
|
|
|
getconf sign no
|
|
|
|
getconf encryptkey
|
2005-12-27 20:38:15 +01:00
|
|
|
getconf signkey
|
2005-05-24 21:08:51 +02:00
|
|
|
|
|
|
|
setsection source
|
2005-01-19 20:37:20 +01:00
|
|
|
getconf include
|
|
|
|
getconf exclude
|
2005-05-24 21:08:51 +02:00
|
|
|
|
|
|
|
setsection dest
|
2005-08-20 20:17:25 +02:00
|
|
|
getconf incremental yes
|
2010-05-02 17:40:50 +02:00
|
|
|
getconf increments 30
|
2005-05-24 21:08:51 +02:00
|
|
|
getconf keep 60
|
2010-11-21 10:07:36 +01:00
|
|
|
getconf keepincroffulls all
|
2008-06-24 15:32:34 +02:00
|
|
|
getconf desturl
|
2010-01-09 23:14:17 +01:00
|
|
|
getconf awsaccesskeyid
|
|
|
|
getconf awssecretaccesskey
|
2011-10-22 21:46:50 +02:00
|
|
|
getconf cfusername
|
|
|
|
getconf cfapikey
|
|
|
|
getconf cfauthurl
|
2017-07-25 11:55:13 +02:00
|
|
|
getconf dropboxappkey
|
|
|
|
getconf dropboxappsecret
|
|
|
|
getconf dropboxaccesstoken
|
2010-05-06 20:05:20 +02:00
|
|
|
getconf ftp_password
|
2005-05-24 21:08:51 +02:00
|
|
|
getconf sshoptions
|
2005-05-27 20:41:40 +02:00
|
|
|
getconf bandwidthlimit 0
|
2005-01-19 20:37:20 +01:00
|
|
|
getconf desthost
|
|
|
|
getconf destdir
|
|
|
|
getconf destuser
|
|
|
|
destdir=${destdir%/}
|
|
|
|
|
2008-01-14 21:32:19 +01:00
|
|
|
### SANITY CHECKS ##############################################################
|
2005-01-19 20:37:20 +01:00
|
|
|
|
2021-01-05 16:52:46 +01:00
|
|
|
if [ -z "$desturl" ]; then
|
|
|
|
# desturl undefined, ensure desthost, destuser and destdir are set
|
|
|
|
[ -n "$desthost" ] || fatal "The destination host (desthost) must be set when desturl is not used."
|
|
|
|
[ -n "$destuser" ] || fatal "The destination user (destuser) must be set when desturl is not used."
|
|
|
|
[ -n "$destdir" ] || fatal "The destination directory (destdir) must be set when desturl is not used."
|
|
|
|
else
|
|
|
|
# desturl overrides other destination specifiers, warn if they are used
|
|
|
|
[ -z "$destuser" ] || warning 'the configured destuser is ignored since desturl is set'
|
|
|
|
[ -z "$desthost" ] || warning 'the configured desthost is ignored since desturl is set'
|
|
|
|
[ -z "$destdir" ] || warning 'the configured destdir is ignored since desturl is set'
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ -n "$include" ] || fatal "No source includes specified."
|
|
|
|
|
2008-01-14 21:32:19 +01:00
|
|
|
[ -n "$password" ] || fatal "The password option must be set."
|
2021-01-05 16:52:46 +01:00
|
|
|
|
2017-10-12 11:20:31 +02:00
|
|
|
if [ -n "$signkey" -a -n "$encryptkey" -a "$signkey" != "$encryptkey" ]; then
|
|
|
|
[ -n "$signpassword" ] || fatal "The signpassword option must be set because signkey is different from encryptkey."
|
|
|
|
fi
|
2021-01-05 16:52:46 +01:00
|
|
|
|
2010-01-09 23:14:17 +01:00
|
|
|
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
|
2021-01-05 16:52:46 +01:00
|
|
|
|
2011-10-22 21:46:50 +02:00
|
|
|
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
|
2021-01-05 16:52:46 +01:00
|
|
|
|
2017-07-25 11:55:13 +02:00
|
|
|
if [ "`echo $desturl | @AWK@ -F ':' '{print $1}'`" == "dpbx" ]; then
|
|
|
|
[ -n "$dropboxappkey" -a -n "$dropboxappsecret" ] || fatal "Dropbox app ID and secret must be set for Dropbox backups."
|
|
|
|
|
|
|
|
if [ ! -n "$dropboxaccesstoken" ]; then
|
|
|
|
error "To obtain an access token for Dropbox, you will need to manually run this command:"
|
|
|
|
error "DPBX_APP_KEY=$dropboxappkey DPBX_APP_SECRET=$dropboxappsecret duplicity list-current-files $desturl"
|
|
|
|
fatal "Dropbox access token must be set"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-01-05 16:52:46 +01:00
|
|
|
# Ensure ftp_password is defined if needed
|
2010-05-06 20:05:20 +02:00
|
|
|
if [ "`echo $desturl | @AWK@ -F ':' '{print $1}'`" == "ftp" ]; then
|
|
|
|
[ -n "$ftp_password" ] || fatal "ftp_password must be set for FTP backups."
|
|
|
|
fi
|
2006-01-19 22:58:38 +01:00
|
|
|
|
2020-05-16 18:02:43 +02:00
|
|
|
# Check that the ionicelevel is valid
|
|
|
|
if [ -n "$ionicelevel" ] && echo "$ionicelevel" | grep -vq "^[0-7]$"; then
|
|
|
|
fatal "The value of ionicelevel is expected to be either empty or an integer from 0 to 7. Got: $ionicelevel"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Only use ionice if ionicelevel is not empty
|
|
|
|
nice="nice -n $nicelevel"
|
|
|
|
if [ -n "$ionicelevel" ]; then
|
|
|
|
nice="ionice -c2 -n $ionicelevel $nice"
|
|
|
|
fi
|
|
|
|
|
2008-01-14 21:32:19 +01:00
|
|
|
### See if we can login on $desthost
|
2021-01-05 16:56:26 +01:00
|
|
|
[ -n "$test" ] || test=0
|
|
|
|
if [ "$testconnect" == "yes" ] || [ "${test}" -eq 1 ]; then
|
2008-06-24 15:32:34 +02:00
|
|
|
if [ -n "$desturl" ]; then
|
|
|
|
warning 'testconnect can not be used when desturl is set'
|
|
|
|
else
|
|
|
|
debug "ssh $sshoptions -o PasswordAuthentication=no $desthost -l $destuser 'echo -n 1'"
|
2021-01-05 16:56:26 +01:00
|
|
|
result=`ssh $sshoptions -o PasswordAuthentication=no $desthost -l $destuser 'echo -n 1'`
|
|
|
|
if [ "$result" != "1" ]; then
|
|
|
|
fatal "Can't connect to $desthost as $destuser."
|
|
|
|
else
|
|
|
|
debug "Connected to $desthost as $destuser successfully"
|
2008-01-14 21:32:19 +01:00
|
|
|
fi
|
|
|
|
fi
|
2005-01-19 20:37:20 +01:00
|
|
|
fi
|
|
|
|
|
2008-01-14 21:32:19 +01:00
|
|
|
### COMMAND-LINE MANGLING ######################################################
|
|
|
|
|
|
|
|
### initialize $execstr*
|
2014-03-01 12:54:34 +01:00
|
|
|
execstr_precmd='LC_ALL=C'
|
2008-01-14 21:32:19 +01:00
|
|
|
execstr_command=
|
|
|
|
execstr_options="$options --no-print-statistics"
|
|
|
|
execstr_source=
|
2008-06-24 15:32:34 +02:00
|
|
|
if [ -n "$desturl" ]; then
|
|
|
|
execstr_serverpart="$desturl"
|
|
|
|
else
|
|
|
|
execstr_serverpart="scp://$destuser@$desthost/$destdir"
|
|
|
|
fi
|
2005-05-24 21:08:51 +02:00
|
|
|
|
2010-04-24 19:56:54 +02:00
|
|
|
### duplicity version (ignore anything else than 0-9 and ".")
|
|
|
|
duplicity_version="`duplicity --version | @AWK@ '{print $2}' | @SED@ 's/[^.[:digit:]]//g'`"
|
2007-10-15 22:55:59 +02:00
|
|
|
|
2010-10-12 11:44:35 +02:00
|
|
|
### ssh/scp/sftp options (duplicity < 0.4.3 is unsupported)
|
2012-01-29 14:39:39 +01:00
|
|
|
## duplicity >= 0.6.17 : paramiko backend
|
2014-02-22 15:21:19 +01:00
|
|
|
if version_ge "$duplicity_version" '0.6.17'; then
|
2012-01-29 14:39:39 +01:00
|
|
|
if [ -n "$sshoptions" ]; then
|
2013-07-23 12:01:37 +02:00
|
|
|
if echo "$sshoptions" | grep -Eqs '^-o[[:space:]]*IdentityFile=[^ ]+$' ; then
|
|
|
|
spaceless_sshoptions="$(echo -n "$sshoptions" | @SED@ 's/^-o[[:space:]]*/-o/')"
|
|
|
|
if [ "$spaceless_sshoptions" != "$sshoptions" ] ; then
|
|
|
|
warning 'Since duplicity >= 0.6.17, sshoptions option requires no space between -o and IdentityFile.'
|
|
|
|
warning 'The bad space has been ignored. Update your duplicity handler config file to suppress this message.'
|
|
|
|
sshoptions="$spaceless_sshoptions"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
warning 'duplicity >= 0.6.17 only supports the IdentityFile SSH option'
|
|
|
|
fi
|
2012-01-29 14:39:39 +01:00
|
|
|
fi
|
|
|
|
execstr_options="${execstr_options} --ssh-options '$sshoptions'"
|
2012-01-29 14:40:46 +01:00
|
|
|
if [ "$bandwidthlimit" != 0 ]; then
|
2021-01-05 16:59:49 +01:00
|
|
|
if [ "`echo $desturl | @AWK@ -F ':' '{print $1}'`" == "file" ]; then
|
|
|
|
warning 'The bandwidthlimit option is not used with a local file path destination.'
|
|
|
|
else
|
|
|
|
execstr_precmd="trickle -s -d $bandwidthlimit -u $bandwidthlimit"
|
|
|
|
fi
|
2012-01-29 14:40:46 +01:00
|
|
|
fi
|
2012-01-29 14:39:39 +01:00
|
|
|
## 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'"
|
2008-06-24 16:11:22 +02:00
|
|
|
fi
|
2005-05-24 21:08:51 +02:00
|
|
|
|
2021-01-05 17:00:54 +01:00
|
|
|
### Encryption and signing
|
2005-12-28 18:32:12 +01:00
|
|
|
if [ -n "$encryptkey" ]; then
|
2021-01-05 17:00:54 +01:00
|
|
|
if [ "$sign" = yes ]; then
|
|
|
|
if [ -n "$signkey" -a "$encryptkey" != "$signkey" ]; then
|
|
|
|
# encryptkey and signkey are different
|
|
|
|
debug "Data will be encrypted with the GnuPG key $encryptkey."
|
|
|
|
debug "Data will be signed with the GnuPG key $signkey."
|
|
|
|
execstr_options="${execstr_options} --encrypt-key $encryptkey --sign-key $signkey"
|
|
|
|
else
|
|
|
|
# encryptkey and signkey identical
|
|
|
|
debug "Data will be encrypted ang signed with the GnuPG key $encryptkey."
|
|
|
|
execstr_options="${execstr_options} --encrypt-sign-key $encryptkey"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
execstr_options="${execstr_options} --encrypt-key $encryptkey"
|
|
|
|
debug "Data will be encrypted with the GnuPG key $encryptkey."
|
|
|
|
debug "Data won't be signed."
|
|
|
|
fi
|
|
|
|
elif [ "$sign" == yes ]; then
|
2008-01-14 21:32:19 +01:00
|
|
|
# duplicity is not able to sign data when using symmetric encryption
|
2021-01-05 17:00:54 +01:00
|
|
|
fatal "The encryptkey option must be set when signing."
|
2005-12-28 18:32:12 +01:00
|
|
|
else
|
2021-01-05 17:00:54 +01:00
|
|
|
debug "Data will be encrypted using symmetric encryption."
|
2005-05-24 21:08:51 +02:00
|
|
|
fi
|
|
|
|
|
2008-01-14 21:32:19 +01:00
|
|
|
### Incremental or full backup mode
|
|
|
|
# If incremental==yes, use the default duplicity behaviour: perform an
|
|
|
|
# incremental backup if old signatures can be found, else switch to
|
|
|
|
# full backup.
|
|
|
|
# If incremental==no, force a full backup anyway.
|
|
|
|
if [ "$incremental" == "no" ]; then
|
2010-10-12 11:44:35 +02:00
|
|
|
execstr_command="full"
|
2010-05-02 12:05:10 +02:00
|
|
|
else
|
2010-05-02 17:40:50 +02:00
|
|
|
# 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"
|
2010-05-02 12:05:10 +02:00
|
|
|
fi
|
2010-05-02 17:40:50 +02:00
|
|
|
execstr_options="${execstr_options} --full-if-older-than $increments"
|
2010-05-02 12:05:10 +02:00
|
|
|
fi
|
2005-01-19 20:37:20 +01:00
|
|
|
fi
|
|
|
|
|
2010-03-06 19:25:27 +01:00
|
|
|
### Cleanup options
|
2014-02-22 15:21:19 +01:00
|
|
|
if ! version_ge "$duplicity_version" '0.6.20'; then
|
2013-11-17 15:55:05 +01:00
|
|
|
execstr_options="${execstr_options} --extra-clean"
|
|
|
|
fi
|
2010-03-06 19:25:27 +01:00
|
|
|
|
2008-01-14 21:32:19 +01:00
|
|
|
### Temporary directory
|
|
|
|
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)."
|
2008-06-25 11:54:45 +02:00
|
|
|
chmod 0700 "$tmpdir"
|
2008-01-14 21:32:19 +01:00
|
|
|
fi
|
|
|
|
info "Using $tmpdir as TMPDIR"
|
2010-10-12 11:15:47 +02:00
|
|
|
execstr_options="${execstr_options} --tempdir '$tmpdir'"
|
2005-08-20 20:17:25 +02:00
|
|
|
fi
|
|
|
|
|
2010-05-06 19:27:18 +02:00
|
|
|
### Archive directory
|
2011-08-17 12:31:30 +02:00
|
|
|
# duplicity now enables the archive_dir by default, let's put it into /var/cache/backupninja/duplicity
|
2010-05-06 19:27:18 +02:00
|
|
|
# unless the user has specified it.
|
2011-08-17 12:31:30 +02:00
|
|
|
if echo "${options}" | grep -qv -- "--archive-dir" ; then
|
2018-04-30 14:47:30 +02:00
|
|
|
[ -d "/var/cache/backupninja" ] || fatal "/var/cache/backupninja does not exist - create it"
|
2011-08-17 12:31:30 +02:00
|
|
|
execstr_options="${execstr_options} --archive-dir /var/cache/backupninja/duplicity"
|
2010-05-06 19:27:18 +02:00
|
|
|
fi
|
|
|
|
|
2008-01-14 21:32:19 +01:00
|
|
|
### Cleanup old backup sets (or not)
|
|
|
|
if [ "$keep" != "yes" ]; then
|
|
|
|
if [ "`echo $keep | tr -d 0-9`" == "" ]; then
|
|
|
|
keep="${keep}D"
|
|
|
|
fi
|
|
|
|
fi
|
2005-05-24 21:08:51 +02:00
|
|
|
|
2008-01-14 21:32:19 +01:00
|
|
|
### Source
|
2005-01-19 20:37:20 +01:00
|
|
|
|
2006-01-19 22:58:38 +01:00
|
|
|
set -o noglob
|
|
|
|
|
2005-01-19 20:37:20 +01:00
|
|
|
# excludes
|
2010-01-09 00:44:43 +01:00
|
|
|
SAVEIFS=$IFS
|
|
|
|
IFS=$(echo -en "\n\b")
|
2006-01-19 22:58:38 +01:00
|
|
|
for i in $exclude; do
|
2006-06-04 02:30:03 +02:00
|
|
|
str="${i//__star__/*}"
|
2008-01-14 21:32:19 +01:00
|
|
|
execstr_source="${execstr_source} --exclude '$str'"
|
2005-01-19 20:37:20 +01:00
|
|
|
done
|
2010-01-09 00:44:43 +01:00
|
|
|
IFS=$SAVEIFS
|
2008-01-14 21:32:19 +01:00
|
|
|
|
|
|
|
# includes
|
2010-01-09 00:44:43 +01:00
|
|
|
SAVEIFS=$IFS
|
|
|
|
IFS=$(echo -en "\n\b")
|
2006-01-19 22:58:38 +01:00
|
|
|
for i in $include; do
|
2006-06-04 02:36:33 +02:00
|
|
|
[ "$i" != "/" ] || fatal "Sorry, you cannot use 'include = /'"
|
2006-06-04 02:30:03 +02:00
|
|
|
str="${i//__star__/*}"
|
2008-01-14 21:32:19 +01:00
|
|
|
execstr_source="${execstr_source} --include '$str'"
|
2005-01-19 20:37:20 +01:00
|
|
|
done
|
2010-01-09 00:44:43 +01:00
|
|
|
IFS=$SAVEIFS
|
2005-01-19 20:37:20 +01:00
|
|
|
|
2006-01-19 22:58:38 +01:00
|
|
|
set +o noglob
|
|
|
|
|
2008-01-14 21:32:19 +01:00
|
|
|
### EXECUTE ####################################################################
|
|
|
|
|
|
|
|
execstr_source=${execstr_source//\\*/\\\\\\*}
|
|
|
|
|
2010-01-09 23:14:17 +01:00
|
|
|
### 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
|
|
|
|
|
2011-10-22 21:46:50 +02:00
|
|
|
### 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
|
|
|
|
|
2017-07-25 11:55:13 +02:00
|
|
|
### If desturl is a Dropbox URL, export the relevant environment variables
|
|
|
|
if [ "`echo $desturl | @AWK@ -F ':' '{print $1}'`" == "dpbx" ]; then
|
|
|
|
export DPBX_APP_KEY="$dropboxappkey"
|
|
|
|
export DPBX_APP_SECRET="$dropboxappsecret"
|
|
|
|
export DPBX_ACCESS_TOKEN="$dropboxaccesstoken"
|
|
|
|
fi
|
|
|
|
|
2008-01-14 21:32:19 +01:00
|
|
|
### Cleanup commands (duplicity >= 0.4.4)
|
|
|
|
|
|
|
|
# cleanup
|
2020-05-16 18:02:43 +02:00
|
|
|
debug "$nice $execstr_precmd duplicity cleanup --force $execstr_options $execstr_serverpart"
|
2021-01-05 16:56:26 +01:00
|
|
|
if [ $test = 0 ]; then
|
2010-10-12 11:44:35 +02:00
|
|
|
export PASSPHRASE=$password
|
2013-11-13 15:18:15 +01:00
|
|
|
export SIGN_PASSPHRASE=$signpassword
|
2010-10-12 11:44:35 +02:00
|
|
|
export FTP_PASSWORD=$ftp_password
|
2020-05-16 18:02:43 +02:00
|
|
|
output=`$nice su -c \
|
2012-01-29 14:39:10 +01:00
|
|
|
"$execstr_precmd duplicity cleanup --force $execstr_options $execstr_serverpart 2>&1"`
|
2010-10-12 11:44:35 +02:00
|
|
|
exit_code=$?
|
|
|
|
if [ $exit_code -eq 0 ]; then
|
2018-01-10 11:43:36 +01:00
|
|
|
debug "$output"
|
2010-10-12 11:44:35 +02:00
|
|
|
info "Duplicity cleanup finished successfully."
|
|
|
|
else
|
2018-01-10 11:43:36 +01:00
|
|
|
debug "$output"
|
2010-10-12 11:44:35 +02:00
|
|
|
warning "Duplicity cleanup failed."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# remove-older-than
|
|
|
|
if [ "$keep" != "yes" ]; then
|
2020-05-16 18:02:43 +02:00
|
|
|
debug "$nice $execstr_precmd duplicity remove-older-than $keep --force $execstr_options $execstr_serverpart"
|
2008-01-14 21:32:19 +01:00
|
|
|
if [ ! $test ]; then
|
|
|
|
export PASSPHRASE=$password
|
2013-11-13 15:18:15 +01:00
|
|
|
export SIGN_PASSPHRASE=$signpassword
|
2010-05-06 20:05:20 +02:00
|
|
|
export FTP_PASSWORD=$ftp_password
|
2020-05-16 18:02:43 +02:00
|
|
|
output=`$nice su -c \
|
2012-01-29 14:39:10 +01:00
|
|
|
"$execstr_precmd duplicity remove-older-than $keep --force $execstr_options $execstr_serverpart 2>&1"`
|
2008-01-14 21:32:19 +01:00
|
|
|
exit_code=$?
|
|
|
|
if [ $exit_code -eq 0 ]; then
|
2018-01-10 11:43:36 +01:00
|
|
|
debug "$output"
|
2010-10-12 11:44:35 +02:00
|
|
|
info "Duplicity remove-older-than finished successfully."
|
2008-01-14 21:32:19 +01:00
|
|
|
else
|
2018-01-10 11:43:36 +01:00
|
|
|
debug "$output"
|
2010-10-12 11:44:35 +02:00
|
|
|
warning "Duplicity remove-older-than failed."
|
2008-01-14 21:32:19 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
2005-01-19 20:37:20 +01:00
|
|
|
|
2010-11-21 10:07:36 +01:00
|
|
|
# remove-all-inc-of-but-n-full : remove increments of older full backups : only keep latest ones
|
|
|
|
if [ "$keep" != "yes" ]; then
|
|
|
|
if [ "$keepincroffulls" != "all" ]; then
|
2014-02-22 15:21:19 +01:00
|
|
|
if version_ge "$duplicity_version" '0.6.10'; then
|
2020-05-16 18:02:43 +02:00
|
|
|
debug "$nice $execstr_precmd duplicity remove-all-inc-of-but-n-full $keepincroffulls --force $execstr_options $execstr_serverpart"
|
2021-01-05 16:56:26 +01:00
|
|
|
if [ $test = 0 ]; then
|
2010-11-21 10:07:36 +01:00
|
|
|
export PASSPHRASE=$password
|
2013-11-13 15:18:15 +01:00
|
|
|
export SIGN_PASSPHRASE=$signpassword
|
2010-11-21 10:07:36 +01:00
|
|
|
export FTP_PASSWORD=$ftp_password
|
2020-05-16 18:02:43 +02:00
|
|
|
output=`$nice su -c \
|
2012-01-29 14:39:10 +01:00
|
|
|
"$execstr_precmd duplicity remove-all-inc-of-but-n-full $keepincroffulls --force $execstr_options $execstr_serverpart 2>&1"`
|
2010-11-21 10:07:36 +01:00
|
|
|
exit_code=$?
|
|
|
|
if [ $exit_code -eq 0 ]; then
|
2018-01-10 11:43:36 +01:00
|
|
|
debug "$output"
|
2010-11-21 10:07:36 +01:00
|
|
|
info "Duplicity remove-all-inc-of-but-n-full finished successfully."
|
|
|
|
else
|
2018-01-10 11:43:36 +01:00
|
|
|
debug "$output"
|
2010-11-21 10:07:36 +01:00
|
|
|
warning "Duplicity remove-all-inc-of-but-n-full failed."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2008-01-14 21:32:19 +01:00
|
|
|
### Backup command
|
2020-05-16 18:02:43 +02:00
|
|
|
debug "$nice $execstr_precmd duplicity $execstr_command $execstr_options $execstr_source --exclude '**' / $execstr_serverpart"
|
2021-01-05 16:56:26 +01:00
|
|
|
if [ $test = 0 ]; then
|
2010-01-05 06:44:36 +01:00
|
|
|
outputfile=`maketemp backupout`
|
2008-01-14 21:32:19 +01:00
|
|
|
export PASSPHRASE=$password
|
2013-11-13 15:18:15 +01:00
|
|
|
export SIGN_PASSPHRASE=$signpassword
|
2010-05-06 20:05:20 +02:00
|
|
|
export FTP_PASSWORD=$ftp_password
|
2020-05-16 18:02:43 +02:00
|
|
|
output=`$nice su -c \
|
2012-01-29 14:39:10 +01:00
|
|
|
"$execstr_precmd duplicity $execstr_command $execstr_options $execstr_source --exclude '**' / $execstr_serverpart >$outputfile 2>&1"`
|
2008-01-14 21:32:19 +01:00
|
|
|
exit_code=$?
|
2018-01-10 11:43:36 +01:00
|
|
|
debug "$output"
|
2010-01-05 06:44:36 +01:00
|
|
|
cat $outputfile | (while read output ; do
|
2012-02-25 15:04:38 +01:00
|
|
|
if [ $exit_code -eq 0 ]; then
|
2018-01-10 11:43:36 +01:00
|
|
|
info "$output"
|
2012-02-25 15:04:38 +01:00
|
|
|
else
|
2018-01-10 11:43:36 +01:00
|
|
|
error "$output"
|
2012-02-25 15:04:38 +01:00
|
|
|
fi
|
2010-01-05 06:44:36 +01:00
|
|
|
done
|
|
|
|
)
|
2008-01-14 21:32:19 +01:00
|
|
|
if [ $exit_code -eq 0 ]; then
|
|
|
|
info "Duplicity finished successfully."
|
|
|
|
else
|
|
|
|
fatal "Duplicity failed."
|
|
|
|
fi
|
2010-01-05 06:44:36 +01:00
|
|
|
rm $outputfile
|
2008-01-14 21:32:19 +01:00
|
|
|
fi
|
2005-01-19 20:37:20 +01:00
|
|
|
|
|
|
|
return 0
|