From 8e3f1444f4f64b80ca2f5af8d96e8c32e0afdc02 Mon Sep 17 00:00:00 2001 From: ljf Date: Sat, 24 Nov 2018 02:20:47 +0100 Subject: [PATCH 1/6] [fix] Check process --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 38f45b8..9443473 100644 --- a/check_process +++ b/check_process @@ -11,7 +11,7 @@ pkg_linter=1 setup_sub_dir=0 setup_root=0 - setup_nourl=0 + setup_nourl=1 setup_private=0 setup_public=0 upgrade=1 From 5eb259a2ee12070fcf8171e83b8bffcd34a9ea9a Mon Sep 17 00:00:00 2001 From: ljf Date: Sun, 25 Nov 2018 23:21:20 +0100 Subject: [PATCH 2/6] [fix] Timers are not supported by yunohost --- conf/backup_method.j2 | 8 ++++---- manifest.json | 2 +- scripts/install | 8 +++++--- scripts/restore | 8 +++++--- scripts/upgrade | 3 +++ 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/conf/backup_method.j2 b/conf/backup_method.j2 index 1ea3cde..dedbdb0 100644 --- a/conf/backup_method.j2 +++ b/conf/backup_method.j2 @@ -29,13 +29,13 @@ do_backup() { pushd $work_dir set +e if borg init -e repokey $repo >> $LOGFILE 2>> $ERRFILE; then - human_size=`echo $size | awk '{ suffix=" KMGT"; for(i=1; $1>1024 && i < length(suffix); i++) $1/=1024; print int($1) substr(suffix, i, 1), $3; }'` + #human_size=`echo $size | awk '{ suffix=" KMGT"; for(i=1; $1>1024 && i < length(suffix); i++) $1/=1024; print int($1) substr(suffix, i, 1), $3; }'` # Speed in Kbps - speed=1000 - evaluated_time=$(($size / ($speed * 1000 / 8) / 3600)) + #speed=1000 + #evaluated_time=$(($size / ($speed * 1000 / 8) / 3600)) echo "Hello, -Your first backup on $repo is starting. The backup size is evaluated to $human_size. If connectivity is 1Mbps between the 2 servers, it will take about $evaluated_time hour(s) to transmit. +Your first backup on $repo is starting. This is an automated message from your beloved YunoHost server." | /usr/bin/mail.mailutils -a "Content-Type: text/plain; charset=UTF-8" -s "[YNH] First backup is starting" "root" fi diff --git a/manifest.json b/manifest.json index cb84099..6ce468a 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Backup your server with borg.", "fr": "Sauvegarder votre serveur avec borg." }, - "version": "1.0.1", + "version": "1.0.2", "url": "https://borgbackup.readthedocs.io", "license": "BSD-3-Clause", "maintainer": { diff --git a/scripts/install b/scripts/install index 6d0cad5..d009fab 100755 --- a/scripts/install +++ b/scripts/install @@ -70,9 +70,11 @@ ynh_configure backup-with-borg "/usr/local/bin/backup-with-$app" chmod u+x "/usr/local/bin/backup-with-$app" ynh_add_systemd_config ynh_configure systemd.timer "/etc/systemd/system/$app.timer" -yunohost service add $app.timer -yunohost service enable $app.timer -yunohost service start $app.timer +systemctl enable $app.timer +systemctl start $app.timer +#yunohost service add $app.timer +#yunohost service enable $app.timer +#yunohost service start $app.timer #================================================= # GENERATE SSH KEY diff --git a/scripts/restore b/scripts/restore index 8b76574..314bce0 100755 --- a/scripts/restore +++ b/scripts/restore @@ -57,9 +57,11 @@ ynh_restore # ADVERTISE SERVICE IN ADMIN PANEL #================================================= yunohost service add $app -yunohost service add $app.timer -yunohost service enable $app.timer -yunohost service start $app.timer +systemctl enable $app.timer +systemctl start $app.timer +#yunohost service add $app.timer +#yunohost service enable $app.timer +#yunohost service start $app.timer #================================================= # RESTORE SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index a2f1c92..ea436f8 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -33,3 +33,6 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +yunohost service remove $app.timer +systemctl enable $app.timer +systemctl start $app.timer From 696c319ffe6a66d62997f8506df832ed03eb6986 Mon Sep 17 00:00:00 2001 From: ljf Date: Wed, 28 Nov 2018 21:08:14 +0100 Subject: [PATCH 3/6] [fix] No yuno service to remove --- scripts/remove | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/remove b/scripts/remove index fefc270..d001268 100755 --- a/scripts/remove +++ b/scripts/remove @@ -28,9 +28,8 @@ ynh_remove_backports #================================================= # REMOVE FILES #================================================= -yunohost service stop $app.timer -yunohost service disable $app.timer -yunohost service remove $app.timer +systemctl stop $app.timer +systemctl disable $app.timer ynh_remove_systemd_config ynh_secure_remove "/etc/systemd/system/$app.timer" ynh_secure_remove "/usr/local/bin/backup-with-$app" From ae6f3266d5c44c891b2ad919635dd6409cd4a564 Mon Sep 17 00:00:00 2001 From: ljf Date: Wed, 28 Nov 2018 21:08:45 +0100 Subject: [PATCH 4/6] [fix] Don't fail on missing yuno service --- manifest.json | 2 +- scripts/upgrade | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index 6ce468a..2072a73 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Backup your server with borg.", "fr": "Sauvegarder votre serveur avec borg." }, - "version": "1.0.2", + "version": "1.0.3", "url": "https://borgbackup.readthedocs.io", "license": "BSD-3-Clause", "maintainer": { diff --git a/scripts/upgrade b/scripts/upgrade index ea436f8..c8411ec 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -33,6 +33,8 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors -yunohost service remove $app.timer -systemctl enable $app.timer -systemctl start $app.timer +if grep "borg.timer" /etc/yunohost/services.yml > /dev/null ; then + yunohost service remove $app.timer + systemctl enable $app.timer + systemctl start $app.timer +fi From d2ce705a7eb001a265cad614228cc0cf723e88b2 Mon Sep 17 00:00:00 2001 From: nicofrand Date: Mon, 4 Feb 2019 21:07:38 +0100 Subject: [PATCH 5/6] Fix system conf/data backup setting check (fix #21) --- conf/backup-with-borg.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/backup-with-borg.j2 b/conf/backup-with-borg.j2 index 3724024..d2b9f1b 100644 --- a/conf/backup-with-borg.j2 +++ b/conf/backup-with-borg.j2 @@ -15,14 +15,14 @@ filter_hooks() { # Backup system part conf conf=$(yunohost app setting {{ app }} conf) -if [ "$conf" = "true" ] +if [ $conf -eq 1 ] then yunohost backup create $ignore_apps -n auto_conf --method {{ app }}_app --system $(filter_hooks conf) fi # Backup system data data=$(yunohost app setting {{ app }} data) -if [ "$data" = "true" ] +if [ $data -eq 1 ] then yunohost backup create $ignore_apps -n auto_data --method {{ app }}_app --system $(filter_hooks data) fi From dc5cad75cf872172df2d0bf8f3df8ad7a034e5c2 Mon Sep 17 00:00:00 2001 From: JocelynDelalande Date: Sun, 13 Jan 2019 00:47:53 +0100 Subject: [PATCH 6/6] [ehn] Test hostkey presence a more reliable way --- conf/backup_method.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/backup_method.j2 b/conf/backup_method.j2 index dedbdb0..7eef826 100644 --- a/conf/backup_method.j2 +++ b/conf/backup_method.j2 @@ -3,7 +3,7 @@ set -e BORG_PASSPHRASE="{{ passphrase }}" -if grep "{{ server }}" ~/.ssh/known_hosts; then +if ssh-keygen -F "{{ server }}" >/dev/null ; then BORG_RSH="ssh -i /root/.ssh/id_{{ app }}_ed25519 -oStrictHostKeyChecking=yes " else BORG_RSH="ssh -i /root/.ssh/id_{{ app }}_ed25519 -oStrictHostKeyChecking=no "