msgBox "$borg_title: error""You must first configure the destination."
return 1
fi
echo"Testing to see if the borg backup directory exists and is writable"
test-d$borg_directory
if[$?= 0 ];then
test-w$borg_directory
if[$?!= 0 ];then
msgBox "destination directory is not writable!""The destination directory is not writable by the user you specified. Please fix the permissions on the directory and then try again."
dir_status=failed
fi
else
booleanBox "Destination does not exist""The destination backup directory does not exist, do you want me to create it for you?"
if[$?= 0 ];then
mkdir-p$borg_directory
result=$?
case$resultin
0) msgBox "$borg_title: success""Creation of the destination directory was a success!";;
1) msgBox "$borg_title: error""Creation of the destination directory failed, check the directory permissions."
dir_status=failed;;
esac
fi
fi
["$dir_status"="ok"]||return 1
}
do_borg_ssh_con(){
local remote_status="ok"
IFS=$' \t\n'
if["$_dest_done"=""];then
msgBox "$borg_title: error""You must first configure the destination."
return 1
elif["$borg_user"=""];then
msgBox "$borg_title: error""You must first configure the destination user."
return 1
elif["$borg_host"=""];then
msgBox "$borg_title: error""You must first configure the destination host."
return 1
else
booleanBox "$borg_title""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 $borg_user@$borg_host. This will allow the local root to make unattended backups to $borg_user@$borg_host.\n\n\nAre you sure you want to continue?"
echo"FAILED: Couldn't copy root's public ssh key to authorized_keys of $borg_user@$borg_host."
ssh $borg_user@$borg_host'test -w .ssh || test -w .'
result=$?
echo"Hit return to continue."
read
case$resultin
0 ) msgBox "$borg_title: error""Directories are writable: Probably just a typo the first time.";;
1 ) msgBox "$borg_title: error""Connected successfully to $borg_user@$borg_host, but unable to write. Check ownership and modes of ~$borg_user on $borg_host.";;
255 ) msgBox "$borg_title: error""Failed to connect to $borg_user@$borg_host. Check hostname, username, and password. Also, make sure sshd is running on the destination host.";;
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."
remote_status=failed
fi
else
booleanBox "Remote directory does not exist""The destination backup directory does not exist, do you want me to create it for you?"
0) msgBox "$borg_title: success""Creation of the remote destination directory was a success!";;
1) msgBox "$borg_title: error""Connected successfully to $borg_user@$borg_host, but was unable to create the destination directory, check the directory permissions."
remote_status=failed;;
255) msgBox "$borg_title: error""Failed to connect to $borg_user@$borg_host. Check hostname, username, and password. Also, make sure sshd is running on the destination host."
remote_status=failed;;
*) msgBox "$borg_title: error""Unexpected error."
remote_status=failed;;
esac
fi
fi
["$remote_status"="ok"]||return 1
}
do_borg_con(){
echo"Checking for local install of borg"
which borg
if[$?!= 0 ];then
msgBox "$borg_title: error""borg executable not found, please install borg ($borg_docs/installation.html)."
return
fi
if["$borg_host"!="localhost"];then
do_borg_ssh_con
else
do_borg_local_dir
fi
[$?= 0 ]||return
echo"SUCCESS: Everything looks good!"
echo"Hit return to continue."
read
_con_done="(DONE)"
setDefault finish
}
do_borg_prune(){
declare-a tmp_array
set-o noglob
REPLY=
formBegin "$borg_title - pruning (how many backups to keep)"