2 HELPERS="$HELPERS rdiff:incremental_remote_filesystem_backup"
4 declare -a rdiff_includes
5 declare -a rdiff_excludes
9 formBegin "rdiff action wizard"
10 formItem "keep" "$rdiff_keep"
11 formItem "dest_directory" "$rdiff_directory"
12 formItem "dest_host" "$rdiff_host"
13 formItem "dest_user" "$rdiff_user"
18 replyconverted=`echo $REPLY | tr '\n' :`
20 thereply=($replyconverted)
23 rdiff_keep=${thereply[0]}
24 rdiff_directory=${thereply[1]}
25 rdiff_host=${thereply[2]}
26 rdiff_user=${thereply[3]}
34 #echo ${rdiff_includes[@]}
36 formBegin "rdiff action wizard: includes"
37 for ((i=0; i < ${#rdiff_includes[@]} ; i++)); do
38 formItem include ${rdiff_includes[$i]}
47 rdiff_includes=($REPLY)
49 formBegin "rdiff action wizard: excludes"
50 for ((i=0; i < ${#rdiff_excludes[@]} ; i++)); do
51 formItem exclude ${rdiff_excludes[$i]}
59 rdiff_excludes=($REPLY)
68 if [ "$_dest_done" = "" ]; then
69 msgBox "rdiff action wizard: error" "You must first configure the destination."
71 elif [ "$rdiff_user" = "" ]; then
72 msgBox "rdiff action wizard: error" "You must first configure the destination user."
74 elif [ "$rdiff_host" = "" ]; then
75 msgBox "rdiff action wizard: error" "You must first configure the destination host."
78 booleanBox "rdiff action wizard" "This step will create a ssh key for the local root user with no passphrase (if one does not already exist), and attempt to copy root's public ssh key to authorized_keys file of $rdiff_user@$rdiff_host. This will allow the local root to make unattended backups to $rdiff_user@$rdiff_host.\n\n\nAre you sure you want to continue?"
82 if [ ! -f /root/.ssh/id_dsa.pub -a ! -f /root/.ssh/id_rsa.pub ]; then
83 echo "Creating local root's ssh key"
84 ssh-keygen -t dsa -f /root/.ssh/id_dsa -N ""
85 echo "Done. hit return to continue"
89 ssh -o PreferredAuthentications=publickey $rdiff_host -l $rdiff_user "exit" 2> /dev/null
91 echo "Copying root's public ssh key to authorized_keys of $rdiff_user@$rdiff_host. When prompted, specify the password for user $rdiff_user@$rdiff_host."
92 ssh-copy-id -i /root/.ssh/id_[rd]sa.pub $rdiff_user@$rdiff_host
94 echo "FAILED: Couldn't copy root's public ssh key to authorized_keys of $rdiff_user@$rdiff_host."
95 ssh $rdiff_user@$rdiff_host 'test -w .ssh || test -w .'
97 echo "Hit return to continue."
100 0 ) msgBox "rdiff action wizard: error" "Directories are writable: Probably just a typo the first time." ;;
101 1 ) msgBox "rdiff action wizard: error" "Connected successfully to $rdiff_user@$rdiff_host, but unable to write. Check ownership and modes of ~$rdiff_user on $rdiff_host." ;;
102 255 ) msgBox "rdiff action wizard: error" "Failed to connect to $rdiff_user@$rdiff_host. Check hostname, username, and password. Also, make sure sshd is running on the destination host." ;;
103 * ) msgBox "rdiff action wizard: error" "Unexpected error." ;;
107 echo "Done. hit return to continue"
111 echo "root@localhost is already in authorized_keys of $rdiff_user@$rdiff_host."
112 echo "Hit return to continue."
119 echo "Testing to make sure destination has rdiff-backup installed and is compatible."
120 remote_result=`rdiff-backup --test-server $rdiff_user@$rdiff_host::/ 2>&1 >&-`
123 echo $remote_result | grep -q "command not found"
126 if [ "$rdiff_user" = "root" ]
128 booleanBox "install rdiff-backup?" "It seems like the remote machine does not have rdiff-backup installed, I can attempt to install rdiff-backup on the remote machine.\n\n\nDo you want me to attempt this now?"
131 ssh $rdiff_user@$rdiff_host 'apt-get install rdiff-backup'
133 echo "Hit return to continue."
137 msgBox "rdiff action wizard: success" "Installation of rdiff-backup was a success!"
141 msgBox "rdiff action wizard: error" "Connected successfully to $rdiff_user@$rdiff_host, but was unable to install the package for some reason."
144 msgBox "rdiff action wizard: error" "Failed to connect to $rdiff_user@$rdiff_host. Check hostname, username, and password. Also, make sure sshd is running on the destination host."
147 msgBox "rdiff action wizard: error" "Unexpected error."
153 booleanBox "install rdiff-backup" "Please install rdiff-backup on the remote machine, this cannot be done automatically, as the remote user in your configuration is not root. \n\nIf you have installed rdiff-backup on the remote machine and you are getting this error, then there is a version incompatibility between that version and the local version.\n\nPlease resolve this problem and then try connecting again.\n\n\n\nTry connecting again?"
162 msgBox "incompatible versions of rdiff-backup" "It looks like rdiff-backup is installed on the remote machine, but it may be an incompatible version with the one installed locally, or something else is amiss.\n\nPlease resolve this problem and then try connecting again.\n\n\nTry connecting again?"
171 echo "SUCCESS: Everything looks good!"
172 echo "Hit return to continue."
181 get_next_filename $configdirectory/90.rdiff
182 cat > $next_filename <<EOF
184 # when = everyday at 02
191 for ((i=0; i < ${#rdiff_includes[@]} ; i++)); do
192 echo "include = ${rdiff_includes[$i]}" >> $next_filename
194 for ((i=0; i < ${#rdiff_excludes[@]} ; i++)); do
195 echo exclude = ${rdiff_excludes[$i]} >> $next_filename
198 cat >> $next_filename <<EOF
202 directory = $rdiff_directory
206 chmod 600 $next_filename
212 srcitem="choose files to include & exclude $_src_done"
213 destitem="configure backup destination $_dest_done"
214 conitem="set up ssh keys and test remote connection $_con_done"
215 advitem="edit advanced settings $_adv_done"
216 menuBox "rdiff action wizard" "choose a step:" \
220 finish "finish and create config file"
221 [ $? = 1 ] && return;
225 "src") do_rdiff_src;;
226 "dest") do_rdiff_dest;;
228 "adv") do_rdiff_adv;;
230 if [[ "$_con_done$_dest_done$_src_done" != "(DONE)(DONE)(DONE)" ]]; then
231 msgBox "rdiff action wizard" "You cannot create the configuration file until the other steps are completed."
243 require_packages rdiff-backup
249 rdiff_directory=/backup/`hostname`
252 rdiff_includes=(/var/spool/cron/crontabs /var/backups /etc /root /home /usr/local/*bin /var/lib/dpkg/status*)
253 rdiff_excludes=(/home/*/.gnupg)