From 4d21e0f4c1d31625e08313664bbef0128614a6f3 Mon Sep 17 00:00:00 2001 From: Felix Andersen Date: Wed, 3 Jan 2024 18:32:15 +0000 Subject: [PATCH 1/2] call restic backup script with nice --- templates/restic.service.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/restic.service.j2 b/templates/restic.service.j2 index 924381b..b47d276 100644 --- a/templates/restic.service.j2 +++ b/templates/restic.service.j2 @@ -10,6 +10,6 @@ Type=oneshot {% if item.lvm is defined %} PrivateMounts=on {% endif %} -ExecStart={{ restic_script_dir }}/backup-{{ item.name }}.sh +ExecStart=/usr/bin/nice {{ restic_script_dir }}/backup-{{ item.name }}.sh TimeoutStartSec=0 Environment="CRON=true" From 09af54284a0497d20998567b8f856a37103a2aff Mon Sep 17 00:00:00 2001 From: Felix Andersen Date: Thu, 4 Jan 2024 17:52:05 +0000 Subject: [PATCH 2/2] template change and README clarification --- README.md | 2 ++ templates/restic.service.j2 | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f6236f6..b6e39c5 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,7 @@ Available variables: | `mail_on_error` | no | Optionally send a mail if the backupjob will fail *(mailx is required)* | | `mail_address` | if `mail_on_error` is true | The mail addressto recive mails if you enabled ``mail_on_error``. | | `monitoring_call` | no | A command that will be called if the backup is *successful*. Useful for heartbeat monitoring systems that warn when no heartbeat is received. Use the full command, you need to run. Example: `curl https://monitoring.example.com/api/push/E9Wzm4lJ2O?status=up&msg=OK&ping=` | +| `niceness` | no | If set, runs any scheduled backup with given [niceness-value](https://en.wikipedia.org/wiki/Nice_(Unix)). On Linux -20 is highest priority, 0 default and 19 is lowest priority. 10 is a common low priority assigned to backup routines on production systems. | Example: ```yaml @@ -197,6 +198,7 @@ restic_backups: stdin_filename: db_name_dump.sql scheduled: true schedule_oncalendar: '*-*-* 01:30:00' + niceness: 10 ``` > You can also specify restic_backups as an array, which is a legacy feature and diff --git a/templates/restic.service.j2 b/templates/restic.service.j2 index b47d276..1d35d41 100644 --- a/templates/restic.service.j2 +++ b/templates/restic.service.j2 @@ -10,6 +10,10 @@ Type=oneshot {% if item.lvm is defined %} PrivateMounts=on {% endif %} -ExecStart=/usr/bin/nice {{ restic_script_dir }}/backup-{{ item.name }}.sh +{% if item.niceness is defined %} +ExecStart=/usr/bin/nice -n {{ item.niceness }} {{ restic_script_dir }}/backup-{{ item.name }}.sh +{% else %} +ExecStart={{ restic_script_dir }}/backup-{{ item.name }}.sh +{% endif %} TimeoutStartSec=0 Environment="CRON=true"