-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated contrib script systemd/send-error.sh (#49)
Applied latest changes from ERROR env and added the profile to the mail
- Loading branch information
Showing
2 changed files
with
130 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,20 +15,130 @@ With `/usr/local/bin/resticprofile-send-error.sh` being: | |
#!/usr/bin/env bash | ||
[[ -z "${PROFILE_NAME}" ]] || sendmail -t <<ERRMAIL | ||
To: $1 | ||
From: "Resticprofile $(hostname -f)" <$USER@$(hostname -f)> | ||
Subject: Restic Failed: ${PROFILE_COMMAND} "${PROFILE_NAME}" | ||
From: "resticprofile $(hostname -f)" <$USER@$(hostname -f)> | ||
Subject: restic failed: ${PROFILE_COMMAND} "${PROFILE_NAME}" | ||
Content-Transfer-Encoding: 8bit | ||
Content-Type: text/plain; charset=UTF-8 | ||
${ERROR} | ||
---- | ||
COMMANDLINE: | ||
${ERROR_COMMANDLINE} | ||
---- | ||
STDERR: | ||
${ERROR_STDERR} | ||
---- | ||
DETAILS: | ||
$(systemctl status --full "resticprofile-${PROFILE_COMMAND}@profile-${PROFILE_NAME}") | ||
---- | ||
CONFIG: | ||
$(resticprofile --name "${PROFILE_NAME}" show) | ||
ERRMAIL | ||
exit 0 | ||
``` | ||
|
||
## Quick installation | ||
|
||
```sh | ||
curl -ssL https://github.com/creativeprojects/resticprofile/raw/master/contrib/systemd/resticprofile-send-error.sh \ | ||
> /usr/local/bin/resticprofile-send-error.sh \ | ||
&& chmod +x /usr/local/bin/resticprofile-send-error.sh | ||
``` | ||
|
||
Requirement: sendmail must be working | ||
|
||
## Sample mail | ||
|
||
In this example, the failure is caused by a custom pre-script complaining about a non-existing path: | ||
|
||
``` | ||
Date: Fri, 23 Apr 2021 23:25:03 +0200 | ||
To: [email protected] | ||
From: "resticprofile hyper1.domain.tl" <[email protected]> | ||
Subject: restic failed: backup "vms" | ||
run-before backup on profile 'vms': exit status 1 | ||
---- | ||
COMMANDLINE: | ||
"vm-snapshot create-all-to-folder /storage/vms /storage/vms/updates live-backup" | ||
---- | ||
STDERR: | ||
Panic: Expected [source] and [target] to be folders and [prefix] to be specified | ||
---- | ||
DETAILS: | ||
● [email protected] - resticprofile backup for profile vms in /etc/resticprofile/profiles.yaml | ||
Loaded: loaded (/etc/systemd/system/[email protected]; static; vendor preset: enabled) | ||
Active: active (running) since Fri 2021-04-23 23:25:02 CEST; 566ms ago | ||
Main PID: 27259 (resticprofile) | ||
Tasks: 13 (limit: 4915) | ||
Memory: 12.1M | ||
CGroup: /system.slice/system-resticprofile\x2dbackup.slice/[email protected] | ||
├─27259 /usr/local/bin/resticprofile --no-prio --no-ansi --config /etc/resticprofile/profiles.yaml --name vms --lock-wait 45m0s backup | ||
├─27294 /usr/bin/sh -c resticprofile-send-error.sh [email protected] | ||
├─27295 bash /usr/local/bin/resticprofile-send-error.sh [email protected] | ||
├─27296 bash /usr/local/bin/resticprofile-send-error.sh [email protected] | ||
└─27299 systemctl status --full resticprofile-backup@profile-vms | ||
Apr 23 23:25:02 hyper1 systemd[1]: Starting resticprofile backup for profile vms in /etc/resticprofile/profiles.yaml... | ||
Apr 23 23:25:02 hyper1 systemd[1]: Started resticprofile backup for profile vms in /etc/resticprofile/profiles.yaml. | ||
Apr 23 23:25:02 hyper1 resticprofile[27259]: 2021/04/23 23:25:02 profile 'vms': initializing repository (if not existing) | ||
Apr 23 23:25:03 hyper1 resticprofile[27259]: Panic: Expected [source] and [target] to be folders and [prefix] to be specified | ||
Apr 23 23:25:03 hyper1 resticprofile[27259]: Usage /usr/bin/vm-snapshot (exists|create|create-to-file|delete|delete-from-file|create-all-to-folder|delete-all-from-folder) | ||
---- | ||
CONFIG: | ||
2021/04/23 23:25:03 using configuration file: /etc/resticprofile/profiles.yaml | ||
global: | ||
default-command: snapshots | ||
restic-binary: restic | ||
restic-lock-retry-after: 1m0s | ||
restic-stale-lock-age: 2h0m0s | ||
min-memory: 100 | ||
vms: | ||
repository: rest:https://u:[email protected]:8443/shared-repo/ | ||
password-file: /etc/resticprofile/shared-repo.key | ||
initialize: true | ||
lock: /tmp/resticprofile.shared-repo.lock | ||
force-inactive-lock: true | ||
run-after-fail: resticprofile-send-error.sh [email protected] | ||
env: | ||
tmpdir: /tmp | ||
backup: | ||
schedule: *-*-* 23:25 | ||
schedule-permission: system | ||
schedule-lock-wait: 45m0s | ||
run-before: vmctl dumpxml-all | ||
vm-snapshot create-all-to-folder /storage/vms /storage/vms/updates live-backup | ||
run-after: vm-snapshot delete-all-from-folder /storage/vms/updates live-backup | ||
source: /storage/vms | ||
exclude: \*\*/updates/\*\* | ||
tag: vms | ||
one-file-system: true | ||
exclude-caches: true | ||
retention: | ||
after-backup: true | ||
keep-daily: 14 | ||
keep-weekly: 4 | ||
``` | ||
|
||
See details in [#20](https://github.com/creativeprojects/resticprofile/issues/20) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,32 @@ | ||
#!/usr/bin/env bash | ||
[[ -z "${PROFILE_NAME}" ]] || sendmail -t <<ERRMAIL | ||
To: $1 | ||
From: "Resticprofile $(hostname -f)" <$USER@$(hostname -f)> | ||
Subject: Restic Failed: ${PROFILE_COMMAND} "${PROFILE_NAME}" | ||
From: "resticprofile $(hostname -f)" <$USER@$(hostname -f)> | ||
Subject: restic failed: ${PROFILE_COMMAND} "${PROFILE_NAME}" | ||
Content-Transfer-Encoding: 8bit | ||
Content-Type: text/plain; charset=UTF-8 | ||
${ERROR} | ||
---- | ||
COMMANDLINE: | ||
${ERROR_COMMANDLINE} | ||
---- | ||
STDERR: | ||
${ERROR_STDERR} | ||
---- | ||
DETAILS: | ||
$(systemctl status --full "resticprofile-${PROFILE_COMMAND}@profile-${PROFILE_NAME}") | ||
---- | ||
CONFIG: | ||
$(resticprofile --name "${PROFILE_NAME}" show) | ||
ERRMAIL | ||
exit 0 |