1 HELPERS="$HELPERS dup:incremental_encrypted_remote_filesystem_backup"
5 do_dup_host_includes() {
7 # choose the files to backup
9 while [ -z "$REPLY" ]; do
10 formBegin "$dup_title - host system: includes"
11 [ -z "$dup_includes" ] && dup_includes="$dup_default_includes"
12 for i in $dup_includes; do
19 [ $? = 0 ] || return 1
26 # choose the vservers to backup (into $selected_vservers)
27 choose_one_or_more_vservers "$dup_title"
28 [ $? = 0 ] || return 1
31 # choose the files to backup
33 while [ -z "$REPLY" ]; do
34 formBegin "$dup_title - vservers: includes"
35 [ -z "$dup_vsincludes" ] && dup_vsincludes="$dup_default_includes"
36 for i in $dup_vsincludes; do
43 [ $? = 0 ] || return 1
44 dup_vsincludes="$REPLY"
51 formBegin "$dup_title: excludes"
52 [ -z "$dup_excludes" ] && dup_excludes="$dup_default_excludes"
53 for i in $dup_excludes; do
60 [ $? = 0 ] || return 1
66 choose_host_or_vservers_or_both "$dup_title"
67 [ $? = 0 ] || return 1
68 case $host_or_vservers in
71 [ $? = 0 ] || return 1
75 [ $? = 0 ] || return 1
79 [ $? = 0 ] || return 1
81 [ $? = 0 ] || return 1
88 [ $? = 0 ] || return 1
101 while [ -z "$REPLY" -o -z "$dup_destdir" -o -z "$dup_desthost" -o -z "$dup_destuser" ]; do
102 formBegin "$dup_title - destination: first three items are compulsory"
103 formItem "desthost" "$dup_desthost"
104 formItem "destuser" "$dup_destuser"
105 formItem "destdir" "$dup_destdir"
106 formItem "keep" "$dup_keep"
107 formItem "incremental" "$dup_incremental"
108 formItem "bandwidthlimit" "$dup_bandwidth"
109 formItem "sshoptions" "$dup_sshoptions"
111 [ $? = 0 ] || return 1
114 replyconverted=`echo $REPLY | tr '\n' :`
116 thereply=($replyconverted)
119 dup_desthost=${thereply[0]}
120 dup_destuser=${thereply[1]}
121 dup_destdir=${thereply[2]}
122 dup_keep=${thereply[3]}
123 dup_incremental=${thereply[4]}
124 dup_bandwidth=${thereply[5]}
125 dup_sshoptions=${thereply[6]}
134 do_dup_gpg_encryptkey() {
136 while [ -z "$REPLY" -o -z "$dup_gpg_encryptkey" ]; do
137 inputBox "$dup_title - GnuPG" "Enter ID of the public GnuPG key to be used to encrypt the backups:" "$dup_gpg_encryptkey"
138 [ $? = 0 ] || return 1
139 dup_gpg_encryptkey="$REPLY"
145 booleanBox "$dup_title - GnuPG" "Sign the backups?" "$dup_gpg_sign"
153 do_dup_gpg_signkey() {
155 booleanBox "$dup_title - GnuPG" "Use the same GnuPG key pair for encryption and signing?" "$dup_gpg_onekeypair"
157 dup_gpg_onekeypair=yes
159 dup_gpg_onekeypair=no
162 if [ "$dup_gpg_onekeypair" == "no" }; then
165 while [ -z "$REPLY" -o -z "$dup_gpg_signkey" ]; do
166 inputBox "$dup_title - GnuPG" "Enter the ID of the private GnuPG key to be used to sign the backups:" "$dup_gpg_signkey"
167 [ $? = 0 ] || return 1
168 dup_gpg_signkey="$REPLY"
173 do_dup_gpg_passphrase() {
174 local question="Enter the passphrase needed to $@:"
176 while [ -z "$REPLY" -o -z "$dup_gpg_password" ]; do
177 passwordBox "$dup_title - GnuPG" "$question"
178 [ $? = 0 ] || return 1
179 dup_gpg_password="$REPLY"
185 # symmetric or public key encryption ?
186 booleanBox "$dup_title - GnuPG" "Use public key encryption? Else, symmetric encryption will be used, and data signing will be impossible." "$dup_gpg_asymmetric_encryption"
188 dup_gpg_asymmetric_encryption=yes
190 dup_gpg_asymmetric_encryption=no
193 # when using public/private key pair encryption, ask for the keys to use
194 if [ "$dup_gpg_asymmetric_encryption" == yes ]; then
195 do_dup_gpg_encryptkey ; [ $? = 0 ] || return 1
196 do_dup_gpg_sign ; [ $? = 0 ] || return 1
197 if [ "$dup_gpg_sign" == yes ]; then
198 do_dup_gpg_signkey ; [ $? = 0 ] || return 1
202 # a passphrase is only needed when signing, or when symmetric encryption is used
203 if [ "$dup_gpg_asymmetric_encryption" == "no" ]; then
204 do_dup_gpg_passphrase "encrypt the backups"
205 [ $? = 0 ] || return 1
206 elif [ "$dup_gpg_sign" == "yes" ]; then
207 if [ -z "$dup_gpg_signkey" ]; then
208 do_dup_gpg_passphrase "unlock the GnuPG 0x$dup_gpg_signkey key used to sign the backups"
209 [ $? = 0 ] || return 1
211 do_dup_gpg_passphrase "unlock the GnuPG 0x$dup_gpg_encryptkey key used to sign the backups"
212 [ $? = 0 ] || return 1
218 # TODO: replace the above line by the following when do_dup_conn is written
222 # TODO: share rdiff.helper code in some lib, and use it here
228 do_dup_misc_options() {
234 formBegin "$dup_title - misc. options"
235 formItem "nicelevel" "$dup_nicelevel"
236 formItem "testconnect" "$dup_testconnect"
237 formItem "options" "$dup_options"
239 [ $? = 0 ] || return 1
242 replyconverted=`echo $REPLY | tr '\n' :`
244 thereply=($replyconverted)
247 dup_nicelevel=${thereply[0]}
248 dup_testconnect=${thereply[1]}
249 dup_options=${thereply[2]}
254 # (rdiff.helper compatible interface... there could be some sode to share, hmmm.)
257 [ $? = 0 ] || return 1
263 get_next_filename $configdirectory/90.dup
264 cat > $next_filename <<EOF
265 # passed directly to duplicity
266 #options = --verbosity 8
267 options = $dup_options
269 # default is 0, but set to 19 if you want to lower the priority.
270 nicelevel = $dup_nicelevel
272 # default is yes. set to no to skip the test if the remote host is alive
273 testconnect = $dup_testconnect
275 ######################################################
277 ## (how to encrypt and optionnally sign the backups)
279 ## WARNING: old (pre-0.9.2) example.dup used to give wrong information about
280 ## the way the following options are used. Please read ahead
283 ## If the encryptkey variable is set:
284 ## - data is encrypted with the GnuPG public key specified by the encryptkey
286 ## - if signing is enabled, the password variable is used to unlock the GnuPG
287 ## private key used for signing; else, you do not need to set the password
289 ## If the encryptkey option is not set:
290 ## - data signing is not possible
291 ## - the password variable is used to encrypt the data with symmetric
292 ## encryption: no GnuPG key pair is needed
296 # when set to yes, encryptkey variable must be set bellow; if you want to use
297 # two different keys for encryption and signing, you must also set the signkey
299 # default is no, for backward compatibility with backupninja <= 0.5.
302 # ID of the GnuPG public key used for data encryption.
303 # if not set, symmetric encryption is used, and data signing is not possible.
304 encryptkey = $dup_gpg_encryptkey
306 # ID of the GnuPG private key used for data signing.
307 # if not set, encryptkey will be used.
308 signkey = $dup_gpg_signkey
311 # NB: do not quote it, and it should not contain any quote
312 password = $dup_gpg_password
314 ######################################################
316 ## (where the files to be backed up are coming from)
320 # files to include in the backup
321 # (supports globbing with '*')
323 # Symlinks are not dereferenced. Moreover, an include line whose path
324 # contains, at any level, a symlink to a directory, will only have the
325 # symlink backed-up, not the target directory's content. Yes, you have
326 # to dereference yourself the symlinks, or to use 'mount --bind'
329 # Let's say /home is a symlink to /mnt/crypt/home ; the following line
330 # will only backup a "/home" symlink ; neither /home/user nor
331 # /home/user/Mail will be backed-up :
332 # include = /home/user/Mail
333 # A workaround is to 'mount --bind /mnt/crypt/home /home' ; another
335 # include = /mnt/crypt/home/user/Mail
338 if [ "$host_or_vservers" == host -o "$host_or_vservers" == both ]; then
340 for i in $dup_includes; do
341 echo "include = $i" >> $next_filename
346 cat >> $next_filename <<EOF
348 # If vservers = yes in /etc/backupninja.conf then the following variables can
350 # vsnames = all | <vserver1> <vserver2> ... (default = all)
352 # Any path specified in vsinclude is added to the include list for each vserver
353 # listed in vsnames (or all if vsnames = all).
354 # E.g. vsinclude = /home will backup the /home partition in every vserver
355 # listed in vsnames. If you have vsnames = "foo bar baz", this vsinclude will
356 # add to the include list /vservers/foo/home, /vservers/bar/home and
357 # /vservers/baz/home.
358 # Vservers paths are derived from $VROOTDIR.
362 if [ "$host_or_vservers" == vservers -o "$host_or_vservers" == both ]; then
364 echo -e "vsnames = \"$selected_vservers\"\n" >> $next_filename
365 for i in $dup_vsincludes; do
366 echo "vsinclude = $i" >> $next_filename
372 cat >> $next_filename <<EOF
374 # rdiff-backup specific comment, TO ADAPT
375 # files to exclude from the backup
376 # (supports globbing with '*')
379 for i in $dup_excludes; do
380 echo "exclude = $i" >> $next_filename
384 cat >> $next_filename <<EOF
386 ######################################################
387 ## destination section
388 ## (where the files are copied to)
392 # perform an incremental backup? (default = yes)
393 # if incremental = no, perform a full backup in order to start a new backup set
394 incremental = $dup_incremental
396 # how many days of data to keep ; default is 60 days.
397 # (you can also use the time format of duplicity)
398 # 'keep = yes' means : do not delete old data, the remote host will take care of this
403 # bandwith limit, in kbit/s ; default is 0, i.e. no limit
404 #bandwidthlimit = 128
405 bandwidthlimit = $dup_bandwidth
407 # passed directly to ssh and scp
408 #sshoptions = -i /root/.ssh/id_dsa_duplicity
409 sshoptions = $dup_sshoptions
411 # put the backups under this directory
412 destdir = $dup_destdir
414 # the machine which will receive the backups
415 desthost = $dup_desthost
417 # make the files owned by this user
418 # note: you must be able to ssh backupuser@backhost
419 # without specifying a password (if type = remote).
420 destuser = $dup_destuser
424 chmod 600 $next_filename
431 srcitem="choose files to include & exclude $_src_done"
432 destitem="configure backup destination $_dest_done"
433 gpgitem="configure GnuPG encryption/signing $_gpg_done"
434 conitem="set up ssh keys and test remote connection $_con_done"
435 advitem="edit advanced settings $_adv_done"
436 # TODO: add the following to the menu when do_dup_conn is written
438 menuBox "$dup_title" "choose a step:" \
443 finish "finish and create config file"
444 [ $? = 0 ] || return 1
449 "dest") do_dup_dest;;
451 # TODO: enable the following when do_dup_conn is written
452 # "conn") do_dup_conn;;
455 if [[ "$_dest_done$_gpg_done$_src_done" != "(DONE)(DONE)(DONE)" ]]; then
456 # TODO: replace the previous test by the following when do_dup_conn is written
457 # if [[ "$_con_done$_dest_done$_gpg_done$_src_done" != "(DONE)(DONE)(DONE)(DONE)" ]]; then
458 msgBox "$dup_title" "You cannot create the configuration file until the four first steps are completed."
473 require_packages duplicity
476 dup_title="Duplicity action wizard"
489 dup_destdir="/backups/`hostname`"
492 dup_gpg_asymmetric_encryption="yes"
493 dup_gpg_encryptkey=""
495 dup_gpg_onekeypair="yes"
502 # Global variables whose '*' shall not be expanded
504 dup_default_includes="/var/spool/cron/crontabs /var/backups /etc /root /home /usr/local/*bin /var/lib/dpkg/status*"
505 dup_default_excludes="/home/*/.gnupg"