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
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"
170 do_dup_misc_options() {
176 formBegin "$dup_title - misc. options"
177 formItem "nicelevel" "$dup_nicelevel"
178 formItem "testconnect" "$dup_testconnect"
179 formItem "options" "$dup_options"
181 [ $? = 0 ] || return 1
184 replyconverted=`echo $REPLY | tr '\n' :`
186 thereply=($replyconverted)
189 dup_nicelevel=${thereply[0]}
190 dup_testconnect=${thereply[1]}
191 dup_options=${thereply[2]}
196 # (rdiff.helper compatible interface... there could be some sode to share, hmmm.)
199 [ $? = 0 ] || return 1
205 get_next_filename $configdirectory/90.dup
206 cat > $next_filename <<EOF
207 # passed directly to duplicity
208 #options = --verbosity 8
209 options = $dup_options
211 # default is 0, but set to 19 if you want to lower the priority.
212 nicelevel = $dup_nicelevel
214 # default is yes. set to no to skip the test if the remote host is alive
215 testconnect = $dup_testconnect
217 ######################################################
219 ## (how to encrypt and optionnally sign the backups)
223 # passphrase needed to unlock the GnuPG key
224 # NB: do not quote it, and it should not contain any quote
225 password = $dup_gpg_password
227 # default is no, for backward compatibility with backupninja <= 0.5.
228 # when set to yes, encryptkey option must be set below.
231 # key ID used for data encryption and, optionnally, signing.
232 # if not set, local root's default gpg key is used.
233 encryptkey = $dup_gpg_encryptkey
235 ######################################################
237 ## (where the files to be backed up are coming from)
241 # files to include in the backup
242 # (supports globbing with '*')
244 # Symlinks are not dereferenced. Moreover, an include line whose path
245 # contains, at any level, a symlink to a directory, will only have the
246 # symlink backed-up, not the target directory's content. Yes, you have
247 # to dereference yourself the symlinks, or to use 'mount --bind'
250 # Let's say /home is a symlink to /mnt/crypt/home ; the following line
251 # will only backup a "/home" symlink ; neither /home/user nor
252 # /home/user/Mail will be backed-up :
253 # include = /home/user/Mail
254 # A workaround is to 'mount --bind /mnt/crypt/home /home' ; another
256 # include = /mnt/crypt/home/user/Mail
259 if [ "$host_or_vservers" == 'host' -o "$host_or_vservers" == 'both' ]; then
261 for ((i=0; i < ${#dup_includes[@]} ; i++)); do
262 echo "include = ${dup_includes[$i]}" >> $next_filename
267 cat >> $next_filename <<EOF
269 # If vservers = yes in /etc/backupninja.conf then the following variables can
271 # vsnames = all | <vserver1> <vserver2> ... (default = all)
273 # Any path specified in vsinclude is added to the include list for each vserver
274 # listed in vsnames (or all if vsnames = all).
275 # E.g. vsinclude = /home will backup the /home partition in every vserver
276 # listed in vsnames. If you have vsnames = "foo bar baz", this vsinclude will
277 # add to the include list /vservers/foo/home, /vservers/bar/home and
278 # /vservers/baz/home.
279 # Vservers paths are derived from $VROOTDIR.
283 if [ "$host_or_vservers" == 'vservers' -o "$host_or_vservers" == 'both' ]; then
285 echo "vsnames = \"$dup_vsnames\"\n" >> $next_filename
286 for ((i=0; i < ${#dup_vsincludes[@]} ; i++)); do
287 echo "vsinclude = ${dup_vsincludes[$i]}" >> $next_filename
293 cat >> $next_filename <<EOF
295 # rdiff-backup specific comment, TO ADAPT
296 # files to exclude from the backup
297 # (supports globbing with '*')
300 for ((i=0; i < ${#dup_excludes[@]} ; i++)); do
301 echo exclude = ${dup_excludes[$i]} >> $next_filename
305 cat >> $next_filename <<EOF
307 ######################################################
308 ## destination section
309 ## (where the files are copied to)
313 # perform an incremental backup? (default = yes)
314 # if incremental = no, perform a full backup in order to start a new backup set
315 incremental = $dup_incremental
317 # how many days of data to keep ; default is 60 days.
318 # (you can also use the time format of duplicity)
319 # 'keep = yes' means : do not delete old data, the remote host will take care of this
324 # bandwith limit, in kbit/s ; default is 0, i.e. no limit
325 #bandwidthlimit = 128
326 bandwidthlimit = $dup_bandwidth
328 # passed directly to ssh and scp
329 #sshoptions = -i /root/.ssh/id_dsa_duplicity
330 sshoptions = $dup_sshoptions
332 # put the backups under this directory
333 destdir = $dup_destdir
335 # the machine which will receive the backups
336 desthost = $dup_desthost
338 # make the files owned by this user
339 # note: you must be able to ssh backupuser@backhost
340 # without specifying a password (if type = remote).
341 destuser = $dup_destuser
345 chmod 600 $next_filename
352 srcitem="choose files to include & exclude $_src_done"
353 destitem="configure backup destination $_dest_done"
354 gpgitem="configure GnuPG encryption/signing $_gpg_done"
355 conitem="set up ssh keys and test remote connection $_con_done"
356 advitem="edit advanced settings $_adv_done"
357 menuBox "$dup_title" "choose a step:" \
363 finish "finish and create config file"
364 [ $? = 0 ] || return 1
369 "dest") do_dup_dest;;
371 "conn") do_dup_conn;;
374 if [[ "$_con_done$_dest_done$_gpg_done$_src_done" != "(DONE)(DONE)(DONE)(DONE)" ]]; then
375 msgBox "$dup_title" "You cannot create the configuration file until the four first steps are completed."
390 require_packages duplicity
393 dup_title="Duplicity action wizard"
399 declare -a dup_default_includes
400 declare -a dup_default_excludes
401 declare -a dup_includes
402 declare -a dup_excludes
403 declare -a dup_vsincludes
409 dup_destdir="/backups/`hostname`"
413 dup_gpg_encryptkey=""
419 # Global variables whose '*' shall not be expanded
421 dup_default_includes=(/var/spool/cron/crontabs /var/backups /etc /root /home /usr/local/*bin /var/lib/dpkg/status*)
422 dup_default_excludes=(/home/*/.gnupg)