2 # duplicity script for backupninja
7 getconf testconnect yes
27 [ "$destdir" != "" ] || fatal "Destination directory not set"
28 [ "$include" != "" ] || fatal "No source includes specified"
29 [ "$password" != "" ] || fatal "No password specified"
32 if [ "$testconnect" == "yes" ]; then
33 debug "ssh $sshoptions -o PasswordAuthentication=no $desthost -l $destuser 'echo -n 1'"
35 result=`ssh $sshoptions -o PasswordAuthentication=no $desthost -l $destuser 'echo -n 1' 2>&1`
36 if [ "$result" != "1" ]; then
37 fatal "Can't connect to $desthost as $destuser."
39 debug "Connected to $desthost as $destuser successfully"
44 ### COMMAND-LINE MANGLING ###
46 execstr="$options --no-print-statistics --scp-command 'scp $sshoptions' --ssh-command 'ssh $sshoptions' "
48 if [ "$encryptkey" == "" ]; then
49 [ "$sign" != "yes" ] || fatal "encryptkey option must be set when signing."
51 execstr="${execstr}--encrypt-key $encryptkey "
52 [ "$sign" != "yes" ] || execstr="${execstr}--sign-key $encryptkey "
55 if [ "$keep" != "yes" ]; then
56 if [ "`echo $keep | tr -d 0-9`" == "" ]; then
59 execstr="${execstr}--remove-older-than $keep "
62 execstr_serverpart="scp://$destuser@$desthost/$destdir"
63 execstr_clientpart="/"
69 str="${i//__star__/*}"
70 execstr="${execstr}--exclude $str "
75 str="${i//__star__/*}"
76 execstr="${execstr}--include $str "
81 # exclude everything else, start with root
82 #execstr="${execstr}--exclude '**' / "
84 # include client-part and server-part
85 #execstr="$execstr $execstr_serverpart"
87 execstr=${execstr//\\*/\\\\\\*}
89 debug "duplicity $execstr --exclude '**' / $execstr_serverpart"
91 output=`nice -n $nicelevel \
93 "export PASSPHRASE=$password \
94 && duplicity $execstr --exclude '**' / $execstr_serverpart 2>&1"`
96 if [ "$code" == "0" ]; then
98 info "Duplicity finished successfully."
101 warning "Duplicity failed."