From b1dc8c9e7ca310789978dd0b26ecee2e9f801dcd Mon Sep 17 00:00:00 2001 From: squeak Date: Sun, 9 May 2021 13:46:51 +0200 Subject: [PATCH 01/10] Added option to chose when to receive email alerts, on errors only, never or always. --- conf/backup-with-borg | 5 +++-- manifest.json | 9 +++++++++ scripts/upgrade | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/conf/backup-with-borg b/conf/backup-with-borg index 4d9bc7e..ba51e1b 100644 --- a/conf/backup-with-borg +++ b/conf/backup-with-borg @@ -73,10 +73,11 @@ fi # Send mail on backup (partially) failed domain=$(hostname) repository="$(sudo yunohost app setting ${borg_id} repository)" -if [ ! -z "$errors" ]; then +mailalert="$(sudo yunohost app setting ${borg_id} mailalert)" +if [[ ! -z "$errors" && $mailalert != "never" ]]; then cat <(echo -e "$errors\n\n\n") "$log_file" "$err_file" | mail -s "[borg] Backup failed from $domain onto $repository" root exit 1 -else +else if [ $mailalert == "always" ] cat $log_file | mail -s "[borg] Backup succeed from $domain onto $repository" root exit 0 fi diff --git a/manifest.json b/manifest.json index 1379553..bd964e3 100644 --- a/manifest.json +++ b/manifest.json @@ -85,6 +85,15 @@ }, "example": "Monthly or Weekly or Daily or Hourly or 4:00 or 5,17:00 or Sat --1..7 18:00:00", "default": "Daily" + }, + { + "name": "mailalert", + "type": "string", + "ask": { + "en": "Do you want admin to receive mail notifications on backups ?", + "fr": "Souhaitez-vous recevoir des notifications par mail à chaque sauvegarde ?" + }, + "choices": ["always", "errors_only", "never"] } ] } diff --git a/scripts/upgrade b/scripts/upgrade index c7b8930..a23d4ff 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,6 +23,7 @@ export on_calendar="$(ynh_app_setting_get $app on_calendar)" export conf="$(ynh_app_setting_get $app conf)" export data="$(ynh_app_setting_get $app data)" export apps="$(ynh_app_setting_get $app apps)" +export mailalert="$(ynh_app_setting_get $app mailalert)" #================================================= # CHECK IF AN UPGRADE IS NEEDED From 340fe001ee062bfa664c5f19c369297d7914e996 Mon Sep 17 00:00:00 2001 From: squeak Date: Sat, 5 Jun 2021 10:13:33 +0200 Subject: [PATCH 02/10] When upgrading, make a default value for mailalert setting, if it is missing. --- scripts/upgrade | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index a23d4ff..46d161a 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,6 +24,10 @@ export conf="$(ynh_app_setting_get $app conf)" export data="$(ynh_app_setting_get $app data)" export apps="$(ynh_app_setting_get $app apps)" export mailalert="$(ynh_app_setting_get $app mailalert)" +if [[ $mailalert != "always" && $mailalert != "errors_only" && $mailalert != "never" ]]; then + ynh_app_setting_set --app=$app --key="mailalert" --value="errors_only" + export mailalert="errors_only" +fi #================================================= # CHECK IF AN UPGRADE IS NEEDED From 4cddcb739db6de57dfe723cf15d97a27a7f4c47c Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Thu, 10 Jun 2021 14:31:25 +0200 Subject: [PATCH 03/10] elif instead of else if Co-authored-by: Alexandre Aubin --- conf/backup-with-borg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/backup-with-borg b/conf/backup-with-borg index ba51e1b..2a42a36 100644 --- a/conf/backup-with-borg +++ b/conf/backup-with-borg @@ -77,7 +77,7 @@ mailalert="$(sudo yunohost app setting ${borg_id} mailalert)" if [[ ! -z "$errors" && $mailalert != "never" ]]; then cat <(echo -e "$errors\n\n\n") "$log_file" "$err_file" | mail -s "[borg] Backup failed from $domain onto $repository" root exit 1 -else if [ $mailalert == "always" ] +elif [ $mailalert == "always" ] cat $log_file | mail -s "[borg] Backup succeed from $domain onto $repository" root exit 0 fi From 859459c1166c7893df50c3e9e82f0c1b0b6c1f88 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Sun, 4 Jul 2021 17:14:52 +0200 Subject: [PATCH 04/10] Update version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index bd964e3..a4d352f 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Backup your server on a host server using Borg.", "fr": "Sauvegardez votre serveur sur un serveur distant avec Borg." }, - "version": "1.1.16~ynh20", + "version": "1.1.16~ynh21", "url": "https://borgbackup.readthedocs.io", "license": "BSD-3-Clause", "maintainer": { From 85104689e78368d4e51abe5de62514166885b71b Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Sun, 4 Jul 2021 17:16:58 +0200 Subject: [PATCH 05/10] [fix] mailalert not backuped --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 834f0a0..fe23302 100755 --- a/scripts/install +++ b/scripts/install @@ -23,7 +23,7 @@ ynh_abort_if_errors export app=$YNH_APP_INSTANCE_NAME # Retrieve arguments -ynh_export repository passphrase on_calendar conf data apps +ynh_export repository passphrase on_calendar conf data apps mailalert #================================================= # STORE SETTINGS FROM MANIFEST @@ -36,7 +36,7 @@ if [[ $repository == *"@"* ]]; then fi ssh_user=$(echo "$repository" | cut -d"@" -f1 | cut -d"/" -f2) fi -ynh_save_args repository server passphrase on_calendar conf data apps +ynh_save_args repository server passphrase on_calendar conf data apps mailalert #================================================= # INSTALL DEPENDENCIES From 44ea48f908d688d39c7c11239f58fb9205d36273 Mon Sep 17 00:00:00 2001 From: ljf Date: Sun, 4 Jul 2021 20:42:36 +0200 Subject: [PATCH 06/10] [fix] Don't backup at boot --- scripts/install | 1 + scripts/restore | 5 ----- scripts/upgrade | 1 + 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index fe23302..d28d732 100755 --- a/scripts/install +++ b/scripts/install @@ -122,6 +122,7 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config +systemctl disable $app.service --quiet #================================================= # CONFIGURE SYSTEMD TIMER diff --git a/scripts/restore b/scripts/restore index 60c7658..2f93f48 100755 --- a/scripts/restore +++ b/scripts/restore @@ -65,11 +65,6 @@ chown $app:$app "/usr/local/bin/backup-with-$app" systemctl enable $app.timer --quiet systemctl start $app.timer -#================================================= -# RESTORE SYSTEMD -#================================================= -systemctl enable $app.service --quiet - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 46d161a..d2fbeb0 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -124,6 +124,7 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config +systemctl disable $app.service --quiet #================================================= # CONFIGURE SYSTEMD TIMER From b80eee6f9730c44914f896673913618ae642b762 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sun, 15 Aug 2021 00:25:37 +0200 Subject: [PATCH 07/10] Propagate changes on check_process --- check_process | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/check_process b/check_process index 1e7a4b2..fcee738 100644 --- a/check_process +++ b/check_process @@ -1,11 +1,12 @@ ;; Test remote directory - ; Manifest - repository="ssh://sam@domain.tld:22/~/backup" + ; Manifest + repository="ssh://sam@domain.tld:22/~/backup" passphrase="APassphrase" conf=1 data=1 apps="all" on_calendar="Daily" + mailalert="errors_only" ; Checks pkg_linter=1 setup_sub_dir=0 @@ -14,19 +15,20 @@ setup_private=0 setup_public=0 upgrade=1 - upgrade=1 from_commit=c1524dd8e37cc671c01f5b5363901dd6a01e6fc1 + upgrade=1 from_commit=c1524dd8e37cc671c01f5b5363901dd6a01e6fc1 backup_restore=1 multi_instance=1 port_already_use=0 change_url=0 ;; Test local directory - ; Manifest - repository="/mnt/backup" + ; Manifest + repository="/mnt/backup" passphrase="APassphrase" conf=1 data=1 apps="all" on_calendar="Daily" + mailalert="errors_only" ; Checks pkg_linter=1 setup_sub_dir=0 @@ -39,9 +41,6 @@ multi_instance=1 port_already_use=0 change_url=0 -;;; Options -Email=ljf+borg_ynh@reflexlibre.net -Notification=change ;;; Upgrade options ; commit=c1524dd8e37cc671c01f5b5363901dd6a01e6fc1 name=Merge pull request #63 from YunoHost-Apps/testing From 4ff3491567292d362f376c70c02d25c51451bfdb Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sun, 15 Aug 2021 00:50:53 +0200 Subject: [PATCH 08/10] Add comment to explain why service is disabled --- scripts/install | 1 + scripts/upgrade | 1 + 2 files changed, 2 insertions(+) diff --git a/scripts/install b/scripts/install index d28d732..6aefffe 100755 --- a/scripts/install +++ b/scripts/install @@ -122,6 +122,7 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config +# Disable the service, this is to prevent the service from being triggered at boot time systemctl disable $app.service --quiet #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index d2fbeb0..6a59011 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -124,6 +124,7 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config +# Disable the service, this is to prevent the service from being triggered at boot time systemctl disable $app.service --quiet #================================================= From 64358b3309c6ed03066e4d8c15eb5e29aeb6aab4 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sun, 22 Aug 2021 20:08:51 +0200 Subject: [PATCH 09/10] Zgmgnifgrmbl --- conf/backup-with-borg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/backup-with-borg b/conf/backup-with-borg index 2a42a36..d5d70c2 100644 --- a/conf/backup-with-borg +++ b/conf/backup-with-borg @@ -77,7 +77,7 @@ mailalert="$(sudo yunohost app setting ${borg_id} mailalert)" if [[ ! -z "$errors" && $mailalert != "never" ]]; then cat <(echo -e "$errors\n\n\n") "$log_file" "$err_file" | mail -s "[borg] Backup failed from $domain onto $repository" root exit 1 -elif [ $mailalert == "always" ] +elif [ $mailalert == "always" ]; then cat $log_file | mail -s "[borg] Backup succeed from $domain onto $repository" root exit 0 fi From 4907bb9f0bfa415a51e521dfa2d88ecc48f0f467 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sun, 22 Aug 2021 20:09:13 +0200 Subject: [PATCH 10/10] Bump manifest version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index a4d352f..0a3c02c 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Backup your server on a host server using Borg.", "fr": "Sauvegardez votre serveur sur un serveur distant avec Borg." }, - "version": "1.1.16~ynh21", + "version": "1.1.16~ynh22", "url": "https://borgbackup.readthedocs.io", "license": "BSD-3-Clause", "maintainer": {