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: last 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]}
140 while [ -z "$REPLY" -o -z "$dup_gpg_encryptkey" ]; do
141 inputBox "$dup_title - GnuPG" "Enter the GnuPG key ID to be used to encrypt the backups:" "$dup_gpg_encryptkey"
142 [ $? = 0 ] || return 1
143 dup_gpg_encryptkey="$REPLY"
148 while [ -z "$REPLY" -o -z "$dup_gpg_password" ]; do
149 passwordBox "$dup_title - GnuPG" "Enter the passphrase needed to unlock the key 0x$dup_gpg_encryptkey"
150 [ $? = 0 ] || return 1
151 dup_gpg_password="$REPLY"
155 booleanBox "$dup_title - GnuPG" "Sign the backups?" "$dup_gpg_sign"
165 # TODO: replace the above line by the following when do_dup_conn is written
169 # TODO: share rdiff.helper code in some lib, and use it here
175 do_dup_misc_options() {
181 formBegin "$dup_title - misc. options"
182 formItem "nicelevel" "$dup_nicelevel"
183 formItem "testconnect" "$dup_testconnect"
184 formItem "options" "$dup_options"
186 [ $? = 0 ] || return 1
189 replyconverted=`echo $REPLY | tr '\n' :`
191 thereply=($replyconverted)
194 dup_nicelevel=${thereply[0]}
195 dup_testconnect=${thereply[1]}
196 dup_options=${thereply[2]}
201 # (rdiff.helper compatible interface... there could be some sode to share, hmmm.)
204 [ $? = 0 ] || return 1
210 get_next_filename $configdirectory/90.dup
211 cat > $next_filename <<EOF
212 # passed directly to duplicity
213 #options = --verbosity 8
214 options = $dup_options
216 # default is 0, but set to 19 if you want to lower the priority.
217 nicelevel = $dup_nicelevel
219 # default is yes. set to no to skip the test if the remote host is alive
220 testconnect = $dup_testconnect
222 ######################################################
224 ## (how to encrypt and optionnally sign the backups)
228 # passphrase needed to unlock the GnuPG key
229 # NB: do not quote it, and it should not contain any quote
230 password = $dup_gpg_password
232 # default is no, for backward compatibility with backupninja <= 0.5.
233 # when set to yes, encryptkey option must be set below.
236 # key ID used for data encryption and, optionnally, signing.
237 # if not set, local root's default gpg key is used.
238 encryptkey = $dup_gpg_encryptkey
240 ######################################################
242 ## (where the files to be backed up are coming from)
246 # files to include in the backup
247 # (supports globbing with '*')
249 # Symlinks are not dereferenced. Moreover, an include line whose path
250 # contains, at any level, a symlink to a directory, will only have the
251 # symlink backed-up, not the target directory's content. Yes, you have
252 # to dereference yourself the symlinks, or to use 'mount --bind'
255 # Let's say /home is a symlink to /mnt/crypt/home ; the following line
256 # will only backup a "/home" symlink ; neither /home/user nor
257 # /home/user/Mail will be backed-up :
258 # include = /home/user/Mail
259 # A workaround is to 'mount --bind /mnt/crypt/home /home' ; another
261 # include = /mnt/crypt/home/user/Mail
264 if [ "$host_or_vservers" == host -o "$host_or_vservers" == both ]; then
266 for i in $dup_includes; do
267 echo "include = $i" >> $next_filename
272 cat >> $next_filename <<EOF
274 # If vservers = yes in /etc/backupninja.conf then the following variables can
276 # vsnames = all | <vserver1> <vserver2> ... (default = all)
278 # Any path specified in vsinclude is added to the include list for each vserver
279 # listed in vsnames (or all if vsnames = all).
280 # E.g. vsinclude = /home will backup the /home partition in every vserver
281 # listed in vsnames. If you have vsnames = "foo bar baz", this vsinclude will
282 # add to the include list /vservers/foo/home, /vservers/bar/home and
283 # /vservers/baz/home.
284 # Vservers paths are derived from $VROOTDIR.
288 if [ "$host_or_vservers" == vservers -o "$host_or_vservers" == both ]; then
290 echo -e "vsnames = \"$selected_vservers\"\n" >> $next_filename
291 for i in $dup_vsincludes; do
292 echo "vsinclude = $i" >> $next_filename
298 cat >> $next_filename <<EOF
300 # rdiff-backup specific comment, TO ADAPT
301 # files to exclude from the backup
302 # (supports globbing with '*')
305 for i in $dup_excludes; do
306 echo "exclude = $i" >> $next_filename
310 cat >> $next_filename <<EOF
312 ######################################################
313 ## destination section
314 ## (where the files are copied to)
318 # perform an incremental backup? (default = yes)
319 # if incremental = no, perform a full backup in order to start a new backup set
320 incremental = $dup_incremental
322 # how many days of data to keep ; default is 60 days.
323 # (you can also use the time format of duplicity)
324 # 'keep = yes' means : do not delete old data, the remote host will take care of this
329 # bandwith limit, in kbit/s ; default is 0, i.e. no limit
330 #bandwidthlimit = 128
331 bandwidthlimit = $dup_bandwidth
333 # passed directly to ssh and scp
334 #sshoptions = -i /root/.ssh/id_dsa_duplicity
335 sshoptions = $dup_sshoptions
337 # put the backups under this directory
338 destdir = $dup_destdir
340 # the machine which will receive the backups
341 desthost = $dup_desthost
343 # make the files owned by this user
344 # note: you must be able to ssh backupuser@backhost
345 # without specifying a password (if type = remote).
346 destuser = $dup_destuser
350 chmod 600 $next_filename
357 srcitem="choose files to include & exclude $_src_done"
358 destitem="configure backup destination $_dest_done"
359 gpgitem="configure GnuPG encryption/signing $_gpg_done"
360 conitem="set up ssh keys and test remote connection $_con_done"
361 advitem="edit advanced settings $_adv_done"
362 # TODO: add the following to the menu when do_dup_conn is written
364 menuBox "$dup_title" "choose a step:" \
369 finish "finish and create config file"
370 [ $? = 0 ] || return 1
375 "dest") do_dup_dest;;
377 # TODO: enable the following when do_dup_conn is written
378 # "conn") do_dup_conn;;
381 if [[ "$_dest_done$_gpg_done$_src_done" != "(DONE)(DONE)(DONE)" ]]; then
382 # TODO: replace the previous test by the following when do_dup_conn is written
383 # if [[ "$_con_done$_dest_done$_gpg_done$_src_done" != "(DONE)(DONE)(DONE)(DONE)" ]]; then
384 msgBox "$dup_title" "You cannot create the configuration file until the four first steps are completed."
399 require_packages duplicity
402 dup_title="Duplicity action wizard"
415 dup_destdir="/backups/`hostname`"
419 dup_gpg_encryptkey=""
425 # Global variables whose '*' shall not be expanded
427 dup_default_includes="/var/spool/cron/crontabs /var/backups /etc /root /home /usr/local/*bin /var/lib/dpkg/status*"
428 dup_default_excludes="/home/*/.gnupg"