Skip to content

Additional GUI integration

rugk edited this page Oct 1, 2017 · 1 revision

In your configuration file, you can overwrite the functions for GUI integration, to do different or additional things. Here are some examples. (Feel free to add you own!)

Different ways for notification

Scary prompt with additional information

Error prompt about failed backup: "The backup process failed. (…)"

# show a scary prompt if the backup fails with additional information
guiShowBackupError() {
	zenity --error --text "<b>The backup process failed.</b> See the log for more details.

<small><tt>$( tail -25 path/to/log.log )</tt></small>" \
		--title "BorgBackup \"$BACKUP_NAME\"" --window-icon "$GUI_OVERWRITE_ICON" \
		--name borg-cron-helper --class borg-cron-helper 2> /dev/null
}

Additional user interaction

Retry popup

Question prompt asking about whether to retry the backup

# Interactively ask for retrying the backup. 
guiTryAgain() {
	zenity --question --text "<b>The backup failed.</b> ($i. try) Do you want to try it again?" \
		--height=10 --title "BorgBackup \"$BACKUP_NAME\"" --window-icon "$GUI_OVERWRITE_ICON" \
		--name borg-cron-helper --class borg-cron-helper 2> /dev/null
}

RETRY_NUM is a maxium number fo retries, then.

Retry CLI question

Of course, also a CLI version is of the retry prompt is possible:

Question on the command line asking about whether to retry the backup

# ask on the shell whether to retry the backup
guiTryAgain() {
	read -rp "The backup failed. ($i. try) Do you want to try it again? [yN]: " retry
	if [ "$retry" = "Y" ] || [ "$retry" = "y" ]; then
		return 0 # (true)
	fi
	return 1 # (false)
}