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 in $dup_default_includes; do
18 [ $? = 0 ] || return 1
25 # choose the vservers to backup (into $selected_vservers)
26 choose_one_or_more_vservers "$dup_title"
27 [ $? = 0 ] || return 1
30 # choose the files to backup
32 while [ -z "$REPLY" ]; do
33 formBegin "$dup_title - vservers: includes"
34 for i in $dup_default_includes; do
41 [ $? = 0 ] || return 1
42 dup_vsincludes="$REPLY"
49 formBegin "$dup_title: excludes"
50 for i in $dup_default_excludes; do
57 [ $? = 0 ] || return 1
63 choose_host_or_vservers_or_both "$dup_title"
64 [ $? = 0 ] || return 1
65 case $host_or_vservers in
68 [ $? = 0 ] || return 1
72 [ $? = 0 ] || return 1
76 [ $? = 0 ] || return 1
78 [ $? = 0 ] || return 1
85 [ $? = 0 ] || return 1
98 while [ -z "$REPLY" -o -z "$dup_destdir" -o -z "$dup_desthost" -o -z "$dup_destuser" ]; do
99 formBegin "$dup_title - destination: last three items are compulsory"
100 formItem "desthost" "$dup_desthost"
101 formItem "destuser" "$dup_destuser"
102 formItem "destdir" "$dup_destdir"
103 formItem "keep" "$dup_keep"
104 formItem "incremental" "$dup_incremental"
105 formItem "bandwidthlimit" "$dup_bandwidth"
106 formItem "sshoptions" "$dup_sshoptions"
108 [ $? = 0 ] || return 1
111 replyconverted=`echo $REPLY | tr '\n' :`
113 thereply=($replyconverted)
116 dup_desthost=${thereply[0]}
117 dup_destuser=${thereply[1]}
118 dup_destdir=${thereply[2]}
119 dup_keep=${thereply[3]}
120 dup_incremental=${thereply[4]}
121 dup_bandwidth=${thereply[5]}
122 dup_sshoptions=${thereply[6]}
137 while [ -z "$REPLY" -o -z "$dup_gpg_encryptkey" ]; do
138 inputBox "$dup_title - GnuPG" "Enter the GnuPG key ID to be used to encrypt the backups:" "$dup_gpg_encryptkey"
139 [ $? = 0 ] || return 1
140 dup_gpg_encryptkey="$REPLY"
145 while [ -z "$REPLY" -o -z "$dup_gpg_password" ]; do
146 passwordBox "$dup_title - GnuPG" "Enter the passphrase needed to unlock the key 0x$dup_gpg_encryptkey"
147 [ $? = 0 ] || return 1
148 dup_gpg_password="$REPLY"
152 booleanBox "$dup_title - GnuPG" "Sign the backups?" "$dup_gpg_sign"
162 # TODO: replace the above line by the following when do_dup_conn is written
166 # TODO: share rdiff.helper code in some lib, and use it here
172 do_dup_misc_options() {
178 formBegin "$dup_title - misc. options"
179 formItem "nicelevel" "$dup_nicelevel"
180 formItem "testconnect" "$dup_testconnect"
181 formItem "options" "$dup_options"
183 [ $? = 0 ] || return 1
186 replyconverted=`echo $REPLY | tr '\n' :`
188 thereply=($replyconverted)
191 dup_nicelevel=${thereply[0]}
192 dup_testconnect=${thereply[1]}
193 dup_options=${thereply[2]}
198 # (rdiff.helper compatible interface... there could be some sode to share, hmmm.)
201 [ $? = 0 ] || return 1
207 get_next_filename $configdirectory/90.dup
208 cat > $next_filename <<EOF
209 # passed directly to duplicity
210 #options = --verbosity 8
211 options = $dup_options
213 # default is 0, but set to 19 if you want to lower the priority.
214 nicelevel = $dup_nicelevel
216 # default is yes. set to no to skip the test if the remote host is alive
217 testconnect = $dup_testconnect
219 ######################################################
221 ## (how to encrypt and optionnally sign the backups)
225 # passphrase needed to unlock the GnuPG key
226 # NB: do not quote it, and it should not contain any quote
227 password = $dup_gpg_password
229 # default is no, for backward compatibility with backupninja <= 0.5.
230 # when set to yes, encryptkey option must be set below.
233 # key ID used for data encryption and, optionnally, signing.
234 # if not set, local root's default gpg key is used.
235 encryptkey = $dup_gpg_encryptkey
237 ######################################################
239 ## (where the files to be backed up are coming from)
243 # files to include in the backup
244 # (supports globbing with '*')
246 # Symlinks are not dereferenced. Moreover, an include line whose path
247 # contains, at any level, a symlink to a directory, will only have the
248 # symlink backed-up, not the target directory's content. Yes, you have
249 # to dereference yourself the symlinks, or to use 'mount --bind'
252 # Let's say /home is a symlink to /mnt/crypt/home ; the following line
253 # will only backup a "/home" symlink ; neither /home/user nor
254 # /home/user/Mail will be backed-up :
255 # include = /home/user/Mail
256 # A workaround is to 'mount --bind /mnt/crypt/home /home' ; another
258 # include = /mnt/crypt/home/user/Mail
261 if [ "$host_or_vservers" == host -o "$host_or_vservers" == both ]; then
263 for i in $dup_includes; do
264 echo "include = $i" >> $next_filename
269 cat >> $next_filename <<EOF
271 # If vservers = yes in /etc/backupninja.conf then the following variables can
273 # vsnames = all | <vserver1> <vserver2> ... (default = all)
275 # Any path specified in vsinclude is added to the include list for each vserver
276 # listed in vsnames (or all if vsnames = all).
277 # E.g. vsinclude = /home will backup the /home partition in every vserver
278 # listed in vsnames. If you have vsnames = "foo bar baz", this vsinclude will
279 # add to the include list /vservers/foo/home, /vservers/bar/home and
280 # /vservers/baz/home.
281 # Vservers paths are derived from $VROOTDIR.
285 if [ "$host_or_vservers" == vservers -o "$host_or_vservers" == both ]; then
287 echo -e "vsnames = \"$selected_vservers\"\n" >> $next_filename
288 for i in $dup_vsincludes; do
289 echo "vsinclude = $i" >> $next_filename
295 cat >> $next_filename <<EOF
297 # rdiff-backup specific comment, TO ADAPT
298 # files to exclude from the backup
299 # (supports globbing with '*')
302 for i in $dup_excludes; do
303 echo "exclude = $i" >> $next_filename
307 cat >> $next_filename <<EOF
309 ######################################################
310 ## destination section
311 ## (where the files are copied to)
315 # perform an incremental backup? (default = yes)
316 # if incremental = no, perform a full backup in order to start a new backup set
317 incremental = $dup_incremental
319 # how many days of data to keep ; default is 60 days.
320 # (you can also use the time format of duplicity)
321 # 'keep = yes' means : do not delete old data, the remote host will take care of this
326 # bandwith limit, in kbit/s ; default is 0, i.e. no limit
327 #bandwidthlimit = 128
328 bandwidthlimit = $dup_bandwidth
330 # passed directly to ssh and scp
331 #sshoptions = -i /root/.ssh/id_dsa_duplicity
332 sshoptions = $dup_sshoptions
334 # put the backups under this directory
335 destdir = $dup_destdir
337 # the machine which will receive the backups
338 desthost = $dup_desthost
340 # make the files owned by this user
341 # note: you must be able to ssh backupuser@backhost
342 # without specifying a password (if type = remote).
343 destuser = $dup_destuser
347 chmod 600 $next_filename
354 srcitem="choose files to include & exclude $_src_done"
355 destitem="configure backup destination $_dest_done"
356 gpgitem="configure GnuPG encryption/signing $_gpg_done"
357 conitem="set up ssh keys and test remote connection $_con_done"
358 advitem="edit advanced settings $_adv_done"
359 # TODO: add the following to the menu when do_dup_conn is written
361 menuBox "$dup_title" "choose a step:" \
366 finish "finish and create config file"
367 [ $? = 0 ] || return 1
372 "dest") do_dup_dest;;
374 # TODO: enable the following when do_dup_conn is written
375 # "conn") do_dup_conn;;
378 if [[ "$_dest_done$_gpg_done$_src_done" != "(DONE)(DONE)(DONE)" ]]; then
379 # TODO: replace the previous test by the following when do_dup_conn is written
380 # if [[ "$_con_done$_dest_done$_gpg_done$_src_done" != "(DONE)(DONE)(DONE)(DONE)" ]]; then
381 msgBox "$dup_title" "You cannot create the configuration file until the four first steps are completed."
396 require_packages duplicity
399 dup_title="Duplicity action wizard"
405 declare -a dup_default_includes
406 declare -a dup_default_excludes
407 declare -a dup_includes
408 declare -a dup_excludes
409 declare -a dup_vsincludes
414 dup_destdir="/backups/`hostname`"
418 dup_gpg_encryptkey=""
424 # Global variables whose '*' shall not be expanded
426 dup_default_includes="/var/spool/cron/crontabs /var/backups /etc /root /home /usr/local/*bin /var/lib/dpkg/status*"
427 dup_default_excludes="/home/*/.gnupg"