mirror of
https://github.com/YunoHost-Apps/borg_ynh.git
synced 2024-09-03 18:16:05 +02:00
Merge 0acea182aa
into b458195190
This commit is contained in:
commit
c5e2b9dd79
4 changed files with 30 additions and 0 deletions
|
@ -17,12 +17,21 @@ filter_hooks() {
|
|||
sudo ls /usr/share/yunohost/hooks/backup/ /etc/yunohost/hooks.d/backup/ | grep "\-$1_" | cut -d"-" -f2 | uniq 2>> "$err_file"
|
||||
}
|
||||
|
||||
healthcheck_url="$(sudo yunohost app setting "${borg_id}" healthcheck_url)"
|
||||
healthcheck() {
|
||||
if [[ -n "$healthcheck_url" ]]; then
|
||||
curl -s -m 10 -o /dev/null --data-raw "$(echo $2 | tail --bytes=10000)" "$healthcheck_url/$1"
|
||||
fi
|
||||
}
|
||||
|
||||
fail_if_partially_failed() {
|
||||
grep Skipped|Error
|
||||
}
|
||||
sudo yunohost app setting "${borg_id}" last_run -v "${current_date}"
|
||||
sudo yunohost app setting "${borg_id}" state -v "ongoing"
|
||||
|
||||
healthcheck "start"
|
||||
|
||||
# Backup system part conf
|
||||
conf=$(sudo yunohost app setting "${borg_id}" conf)
|
||||
if [[ "$conf" = "1" ]]; then
|
||||
|
@ -74,8 +83,10 @@ repository="$(sudo yunohost app setting "${borg_id}" repository)"
|
|||
mailalert="$(sudo yunohost app setting "${borg_id}" mailalert)"
|
||||
if [[ -n "$errors" ]]; then
|
||||
sudo yunohost app setting "${borg_id}" state -v "failed"
|
||||
healthcheck "fail" "$errors"
|
||||
else
|
||||
sudo yunohost app setting "${borg_id}" state -v "successful"
|
||||
healthcheck
|
||||
fi
|
||||
|
||||
if [[ -n "$errors" && $mailalert != "never" ]]; then
|
||||
|
|
|
@ -46,6 +46,12 @@ services = []
|
|||
choices.errors_only = "Only if an error occured"
|
||||
choices.never = "Never alert me"
|
||||
help = "Alerts are sent to the first user of this server"
|
||||
|
||||
[main.general.healthcheck_url]
|
||||
ask.en = "Healthcheck URL"
|
||||
type = "string"
|
||||
help = "Use a healthcheck to detect silent failures. It's optional, if you don't know what it is, just leave it blank or look it up: https://healthchecks.io"
|
||||
optional = "true"
|
||||
|
||||
[main.content]
|
||||
name = "What should be backuped?"
|
||||
|
|
|
@ -76,6 +76,13 @@ ram.runtime = "50M"
|
|||
choices = ["always", "errors_only", "never"]
|
||||
default = "errors_only"
|
||||
|
||||
[install.healthcheck_url]
|
||||
ask.en = "Optional - you may specify a healthcheck URL to check against silent failures."
|
||||
ask.fr = "Optionnel - vous pouvez spécifier une URL de vérification de l'état pour vérifier les pannes silencieuses."
|
||||
type = "string"
|
||||
default = ""
|
||||
optional = true
|
||||
|
||||
[resources]
|
||||
[resources.system_user]
|
||||
|
||||
|
@ -85,6 +92,7 @@ ram.runtime = "50M"
|
|||
|
||||
[resources.apt]
|
||||
packages = [
|
||||
"curl",
|
||||
"python3-pip",
|
||||
"python3-dev",
|
||||
"python3-jinja2",
|
||||
|
|
|
@ -66,6 +66,11 @@ validate__on_calendar() {
|
|||
echo 'Please follow systemd OnCalendar format: https://man.archlinux.org/man/systemd.time.7#CALENDAR_EVENTS'
|
||||
}
|
||||
|
||||
validate__healthcheck_url() {
|
||||
[[ $healthcheck_url =~ ^https?://[^/]+(/.*)?$ ]] ||
|
||||
echo 'Please enter a valid URL'
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETTERS FOR TOML SHORT KEYS
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue