2 # duplicity script for backupninja
7 getconf testconnect yes
22 getconf bandwidthlimit 0
28 [ "$destdir" != "" ] || fatal "Destination directory not set"
29 [ "$include" != "" ] || fatal "No source includes specified"
30 [ "$password" != "" ] || fatal "No password specified"
33 if [ "$testconnect" == "yes" ]; then
34 debug "ssh $sshoptions -o PasswordAuthentication=no $desthost -l $destuser 'echo -n 1'"
36 result=`ssh $sshoptions -o PasswordAuthentication=no $desthost -l $destuser 'echo -n 1' 2>&1`
37 if [ "$result" != "1" ]; then
38 fatal "Can't connect to $desthost as $destuser."
40 debug "Connected to $desthost as $destuser successfully"
45 ### COMMAND-LINE MANGLING ###
47 scpoptions="$sshoptions"
48 [ "$bandwidthlimit" == 0 ] || scpoptions="$scpoptions -l $bandwidthlimit"
50 execstr="$options --no-print-statistics --scp-command 'scp $scpoptions' --ssh-command 'ssh $sshoptions' "
52 if [ "$encryptkey" == "" ]; then
53 [ "$sign" != "yes" ] || fatal "encryptkey option must be set when signing."
55 execstr="${execstr}--encrypt-key $encryptkey "
56 [ "$sign" != "yes" ] || execstr="${execstr}--sign-key $encryptkey "
59 if [ "$keep" != "yes" ]; then
60 if [ "`echo $keep | tr -d 0-9`" == "" ]; then
63 execstr="${execstr}--remove-older-than $keep "
66 execstr_serverpart="scp://$destuser@$desthost/$destdir"
67 execstr_clientpart="/"
73 str="${i//__star__/*}"
74 execstr="${execstr}--exclude $str "
79 str="${i//__star__/*}"
80 execstr="${execstr}--include $str "
85 # exclude everything else, start with root
86 #execstr="${execstr}--exclude '**' / "
88 # include client-part and server-part
89 #execstr="$execstr $execstr_serverpart"
91 execstr=${execstr//\\*/\\\\\\*}
93 debug "duplicity $execstr --exclude '**' / $execstr_serverpart"
95 output=`nice -n $nicelevel \
97 "export PASSPHRASE=$password \
98 && duplicity $execstr --exclude '**' / $execstr_serverpart 2>&1"`
100 if [ "$code" == "0" ]; then
102 info "Duplicity finished successfully."
105 warning "Duplicity failed."