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 for ((i=0; i < ${#dup_default_includes[@]} ; i++)); do
12 formItem include ${dup_default_includes[$i]}
18 [ $? = 0 ] || return 1
25 # choose the vservers to backup
26 vservers_chooser "$dup_title"
27 [ $? = 0 ] || return 1
28 dup_vsnames="$vservers_chooser_vsnames"
31 # choose the files to backup
33 while [ -z "$REPLY" ]; do
34 formBegin "$dup_title - vservers: includes"
35 for ((i=0; i < ${#dup_default_includes[@]} ; i++)); do
36 formItem include ${dup_default_includes[$i]}
42 [ $? = 0 ] || return 1
43 dup_vsincludes=($REPLY)
50 formBegin "$dup_title: excludes"
51 for ((i=0; i < ${#dup_default_excludes[@]} ; i++)); do
52 formItem exclude ${dup_default_excludes[$i]}
58 [ $? = 0 ] || return 1
64 host_or_vservers_chooser "$dup_title"
65 [ $? = 0 ] || return 1
66 case $host_or_vservers in
69 [ $? = 0 ] || return 1
73 [ $? = 0 ] || return 1
77 [ $? = 0 ] || return 1
79 [ $? = 0 ] || return 1
86 [ $? = 0 ] || return 1
99 while [ -z "$REPLY" -o -z "$dup_destdir" -o -z "$dup_desthost" -o -z "$dup_destuser" ]; do
100 formBegin "$dup_title - destination: last three items are compulsory"
101 formItem "desthost" "$dup_desthost"
102 formItem "destuser" "$dup_destuser"
103 formItem "destdir" "$dup_destdir"
104 formItem "keep" "$dup_keep"
105 formItem "incremental" "$dup_incremental"
106 formItem "bandwidthlimit" "$dup_bandwidth"
107 formItem "sshoptions" "$dup_sshoptions"
109 [ $? = 0 ] || return 1
112 replyconverted=`echo $REPLY | tr '\n' :`
114 thereply=($replyconverted)
117 dup_desthost=${thereply[0]}
118 dup_destuser=${thereply[1]}
119 dup_destdir=${thereply[2]}
120 dup_keep=${thereply[3]}
121 dup_incremental=${thereply[4]}
122 dup_bandwidth=${thereply[5]}
123 dup_sshoptions=${thereply[6]}
138 while [ -z "$REPLY" -o -z "$dup_gpg_encryptkey" ]; do
139 inputBox "$dup_title - GnuPG" "Enter the GnuPG key ID to be used to encrypt the backups:" "$dup_gpg_encryptkey"
140 [ $? = 0 ] || return 1
141 dup_gpg_encryptkey="$REPLY"
146 while [ -z "$REPLY" -o -z "$dup_gpg_password" ]; do
147 passwordBox "$dup_title - GnuPG" "Enter the passphrase needed to unlock the key 0x$dup_gpg_encryptkey"
148 [ $? = 0 ] || return 1
149 dup_gpg_password="$REPLY"
153 booleanBox "$dup_title - GnuPG" "Sign the backups?" "$dup_gpg_sign"
163 # TODO: replace the above line by the following when do_dup_conn is written
167 # TODO: share rdiff.helper code in some lib, and use it here
173 do_dup_misc_options() {
179 formBegin "$dup_title - misc. options"
180 formItem "nicelevel" "$dup_nicelevel"
181 formItem "testconnect" "$dup_testconnect"
182 formItem "options" "$dup_options"
184 [ $? = 0 ] || return 1
187 replyconverted=`echo $REPLY | tr '\n' :`
189 thereply=($replyconverted)
192 dup_nicelevel=${thereply[0]}
193 dup_testconnect=${thereply[1]}
194 dup_options=${thereply[2]}
199 # (rdiff.helper compatible interface... there could be some sode to share, hmmm.)
202 [ $? = 0 ] || return 1
208 get_next_filename $configdirectory/90.dup
209 cat > $next_filename <<EOF
210 # passed directly to duplicity
211 #options = --verbosity 8
212 options = $dup_options
214 # default is 0, but set to 19 if you want to lower the priority.
215 nicelevel = $dup_nicelevel
217 # default is yes. set to no to skip the test if the remote host is alive
218 testconnect = $dup_testconnect
220 ######################################################
222 ## (how to encrypt and optionnally sign the backups)
226 # passphrase needed to unlock the GnuPG key
227 # NB: do not quote it, and it should not contain any quote
228 password = $dup_gpg_password
230 # default is no, for backward compatibility with backupninja <= 0.5.
231 # when set to yes, encryptkey option must be set below.
234 # key ID used for data encryption and, optionnally, signing.
235 # if not set, local root's default gpg key is used.
236 encryptkey = $dup_gpg_encryptkey
238 ######################################################
240 ## (where the files to be backed up are coming from)
244 # files to include in the backup
245 # (supports globbing with '*')
247 # Symlinks are not dereferenced. Moreover, an include line whose path
248 # contains, at any level, a symlink to a directory, will only have the
249 # symlink backed-up, not the target directory's content. Yes, you have
250 # to dereference yourself the symlinks, or to use 'mount --bind'
253 # Let's say /home is a symlink to /mnt/crypt/home ; the following line
254 # will only backup a "/home" symlink ; neither /home/user nor
255 # /home/user/Mail will be backed-up :
256 # include = /home/user/Mail
257 # A workaround is to 'mount --bind /mnt/crypt/home /home' ; another
259 # include = /mnt/crypt/home/user/Mail
262 if [ "$host_or_vservers" == 'host' -o "$host_or_vservers" == 'both' ]; then
264 for ((i=0; i < ${#dup_includes[@]} ; i++)); do
265 echo "include = ${dup_includes[$i]}" >> $next_filename
270 cat >> $next_filename <<EOF
272 # If vservers = yes in /etc/backupninja.conf then the following variables can
274 # vsnames = all | <vserver1> <vserver2> ... (default = all)
276 # Any path specified in vsinclude is added to the include list for each vserver
277 # listed in vsnames (or all if vsnames = all).
278 # E.g. vsinclude = /home will backup the /home partition in every vserver
279 # listed in vsnames. If you have vsnames = "foo bar baz", this vsinclude will
280 # add to the include list /vservers/foo/home, /vservers/bar/home and
281 # /vservers/baz/home.
282 # Vservers paths are derived from $VROOTDIR.
286 if [ "$host_or_vservers" == 'vservers' -o "$host_or_vservers" == 'both' ]; then
288 echo "vsnames = \"$dup_vsnames\"\n" >> $next_filename
289 for ((i=0; i < ${#dup_vsincludes[@]} ; i++)); do
290 echo "vsinclude = ${dup_vsincludes[$i]}" >> $next_filename
296 cat >> $next_filename <<EOF
298 # rdiff-backup specific comment, TO ADAPT
299 # files to exclude from the backup
300 # (supports globbing with '*')
303 for ((i=0; i < ${#dup_excludes[@]} ; i++)); do
304 echo exclude = ${dup_excludes[$i]} >> $next_filename
308 cat >> $next_filename <<EOF
310 ######################################################
311 ## destination section
312 ## (where the files are copied to)
316 # perform an incremental backup? (default = yes)
317 # if incremental = no, perform a full backup in order to start a new backup set
318 incremental = $dup_incremental
320 # how many days of data to keep ; default is 60 days.
321 # (you can also use the time format of duplicity)
322 # 'keep = yes' means : do not delete old data, the remote host will take care of this
327 # bandwith limit, in kbit/s ; default is 0, i.e. no limit
328 #bandwidthlimit = 128
329 bandwidthlimit = $dup_bandwidth
331 # passed directly to ssh and scp
332 #sshoptions = -i /root/.ssh/id_dsa_duplicity
333 sshoptions = $dup_sshoptions
335 # put the backups under this directory
336 destdir = $dup_destdir
338 # the machine which will receive the backups
339 desthost = $dup_desthost
341 # make the files owned by this user
342 # note: you must be able to ssh backupuser@backhost
343 # without specifying a password (if type = remote).
344 destuser = $dup_destuser
348 chmod 600 $next_filename
355 srcitem="choose files to include & exclude $_src_done"
356 destitem="configure backup destination $_dest_done"
357 gpgitem="configure GnuPG encryption/signing $_gpg_done"
358 conitem="set up ssh keys and test remote connection $_con_done"
359 advitem="edit advanced settings $_adv_done"
360 # TODO: add the following to the menu when do_dup_conn is written
362 menuBox "$dup_title" "choose a step:" \
367 finish "finish and create config file"
368 [ $? = 0 ] || return 1
373 "dest") do_dup_dest;;
375 # TODO: enable the following when do_dup_conn is written
376 # "conn") do_dup_conn;;
379 if [[ "$_dest_done$_gpg_done$_src_done" != "(DONE)(DONE)(DONE)" ]]; then
380 # TODO: replace the previous test by the following when do_dup_conn is written
381 # if [[ "$_con_done$_dest_done$_gpg_done$_src_done" != "(DONE)(DONE)(DONE)(DONE)" ]]; then
382 msgBox "$dup_title" "You cannot create the configuration file until the four first steps are completed."
397 require_packages duplicity
400 dup_title="Duplicity action wizard"
406 declare -a dup_default_includes
407 declare -a dup_default_excludes
408 declare -a dup_includes
409 declare -a dup_excludes
410 declare -a dup_vsincludes
416 dup_destdir="/backups/`hostname`"
420 dup_gpg_encryptkey=""
426 # Global variables whose '*' shall not be expanded
428 dup_default_includes=(/var/spool/cron/crontabs /var/backups /etc /root /home /usr/local/*bin /var/lib/dpkg/status*)
429 dup_default_excludes=(/home/*/.gnupg)