1 HELPERS="$HELPERS rdiff:incremental_remote_filesystem_backup"
3 declare -a rdiff_includes
4 declare -a rdiff_excludes
8 formBegin "rdiff action wizard"
9 formItem "keep" "$rdiff_keep"
10 formItem "dest_directory" "$rdiff_directory"
11 formItem "dest_host" "$rdiff_host"
12 formItem "dest_user" "$rdiff_user"
17 replyconverted=`echo $REPLY | tr '\n' :`
19 thereply=($replyconverted)
22 rdiff_keep=${thereply[0]}
23 rdiff_directory=${thereply[1]}
24 rdiff_host=${thereply[2]}
25 rdiff_user=${thereply[3]}
33 #echo ${rdiff_includes[@]}
35 formBegin "rdiff action wizard: includes"
36 for ((i=0; i < ${#rdiff_includes[@]} ; i++)); do
37 formItem include ${rdiff_includes[$i]}
46 rdiff_includes=($REPLY)
48 formBegin "rdiff action wizard: excludes"
49 for ((i=0; i < ${#rdiff_excludes[@]} ; i++)); do
50 formItem exclude ${rdiff_excludes[$i]}
58 rdiff_excludes=($REPLY)
67 if [ "$_dest_done" = "" ]; then
68 msgBox "rdiff action wizard: error" "You must first configure the destination."
70 elif [ "$rdiff_user" = "" ]; then
71 msgBox "rdiff action wizard: error" "You must first configure the destination user."
73 elif [ "$rdiff_host" = "" ]; then
74 msgBox "rdiff action wizard: error" "You must first configure the destination host."
77 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?"
81 if [ ! -f /root/.ssh/id_dsa.pub -a ! -f /root/.ssh/id_rsa.pub ]; then
82 echo "Creating local root's ssh key"
83 ssh-keygen -t dsa -f /root/.ssh/id_dsa -N ""
84 echo "Done. hit return to continue"
88 ssh -o PreferredAuthentications=publickey $rdiff_host -l $rdiff_user "exit" 2> /dev/null
90 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."
91 ssh-copy-id -i /root/.ssh/id_[rd]sa.pub $rdiff_user@$rdiff_host
93 echo "FAILED: Couldn't copy root's public ssh key to authorized_keys of $rdiff_user@$rdiff_host."
94 ssh $rdiff_user@$rdiff_host 'test -w .ssh || test -w .'
96 echo "Hit return to continue."
99 0 ) msgBox "rdiff action wizard: error" "Directories are writable: Probably just a typo the first time." ;;
100 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." ;;
101 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." ;;
102 * ) msgBox "rdiff action wizard: error" "Unexpected error." ;;
106 echo "Done. hit return to continue"
110 echo "root@localhost is already in authorized_keys of $rdiff_user@$rdiff_host."
111 echo "Hit return to continue."
114 # test to see if the remote rdiff backup directory exists and is writable
115 echo "Testing to see if remote rdiff backup directory exists and is writable"
116 ssh $rdiff_user@$rdiff_host "test -d ${rdiff_directory}"
119 ssh $rdiff_user@$rdiff_host "test -w $rdiff_directory"
122 msgBox "destination directory is not writable!" "The remote destination directory is not writable by the user you specified. Please fix the permissions on the directory and then try again."
128 booleanBox "Remote directory does not exist" "The destination backup directory does not exist, do you want me to create it for you?"
131 ssh $rdiff_user@$rdiff_host "mkdir -p ${rdiff_directory}"
133 echo "Hit return to continue."
137 msgBox "rdiff action wizard: success" "Creation of the remote destination directory was a success!"
141 msgBox "rdiff action wizard: error" "Connected successfully to $rdiff_user@$rdiff_host, but was unable to create the destination directory, check the directory permissions."
145 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."
149 msgBox "rdiff action wizard: error" "Unexpected error."
157 if [ $remote_status -ne 1 ]
164 echo "Testing to make sure destination has rdiff-backup installed and is compatible."
165 remote_result=`/usr/bin/rdiff-backup --test-server $rdiff_user@$rdiff_host::/ 2>&1 >&-`
168 echo $remote_result | grep -q "command not found"
171 if [ "$rdiff_user" = "root" ]
173 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?"
176 ssh $rdiff_user@$rdiff_host 'apt-get install rdiff-backup'
178 echo "Hit return to continue."
182 msgBox "rdiff action wizard: success" "Installation of rdiff-backup was a success!"
186 msgBox "rdiff action wizard: error" "Connected successfully to $rdiff_user@$rdiff_host, but was unable to install the package for some reason."
189 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."
192 msgBox "rdiff action wizard: error" "Unexpected error."
198 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?"
207 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?"
216 echo "SUCCESS: Everything looks good!"
217 echo "Hit return to continue."
226 get_next_filename $configdirectory/90.rdiff
227 cat > $next_filename <<EOF
229 # when = everyday at 02
236 for ((i=0; i < ${#rdiff_includes[@]} ; i++)); do
237 echo "include = ${rdiff_includes[$i]}" >> $next_filename
239 for ((i=0; i < ${#rdiff_excludes[@]} ; i++)); do
240 echo exclude = ${rdiff_excludes[$i]} >> $next_filename
243 cat >> $next_filename <<EOF
247 directory = $rdiff_directory
251 chmod 600 $next_filename
257 srcitem="choose files to include & exclude $_src_done"
258 destitem="configure backup destination $_dest_done"
259 conitem="set up ssh keys and test remote connection $_con_done"
260 advitem="edit advanced settings $_adv_done"
261 menuBox "rdiff action wizard" "choose a step:" \
265 finish "finish and create config file"
270 "src") do_rdiff_src;;
271 "dest") do_rdiff_dest;;
272 "conn") do_rdiff_ssh_con;;
273 "adv") do_rdiff_adv;;
275 if [[ "$_con_done$_dest_done$_src_done" != "(DONE)(DONE)(DONE)" ]]; then
276 msgBox "rdiff action wizard" "You cannot create the configuration file until the other steps are completed."
288 require_packages rdiff-backup
294 rdiff_directory=/backup/`hostname`
298 rdiff_includes=(/var/spool/cron/crontabs /var/backups /etc /root /home /usr/local/*bin /var/lib/dpkg/status*)
299 rdiff_excludes=(/home/*/.gnupg)