adding mail on error feature

This commit is contained in:
L3D 2021-07-05 14:51:27 +02:00
parent f385bfcb73
commit 9b8d0fe599
No known key found for this signature in database
GPG key ID: CD08445BFF4313D1
5 changed files with 27 additions and 133 deletions

View file

@ -1,19 +0,0 @@
> @ changelog /Users/mleutenegger/Desktop/Syntro/Ansible/ansible.restic
> git-chglog 0.2.8..
<a name="unreleased"></a>
## [Unreleased]
### 🍰 Added
- git-chglog
- github workflows ([#25](https://github.com/syntro-opensource/ansible.silverstripe/issues/25))
- example for backup syntax ([#24](https://github.com/syntro-opensource/ansible.silverstripe/issues/24))
<a name="0.2.8"></a>
## [0.2.8] - 2020-09-08
## History
For versions before 0.2.9, see [HISTORY.md](HISTORY.md)
[Unreleased]: https://github.com/syntro-opensource/ansible.silverstripe/compare/0.2.8...HEAD
[0.2.8]: https://github.com/syntro-opensource/ansible.silverstripe/compare/0.2.7...0.2.8

View file

@ -1,97 +0,0 @@
# Changelog
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
and [human-readable changelog](https://keepachangelog.com/en/1.0.0/).
## Unreleased
## [0.2.8] 2020-09-08
### Added
* Sanity check for restic binary
* Support for the Backblaze B2 backend
## [0.2.7] 2020-08-05
### Added
* Config option to exclude files
* Contributing guide
## [0.2.6] 2020-06-05
### Changed
* Password now use `regex_escape()` filter in templates
## [0.2.5] - 2020-06-02
### Fixed:
* AWS credentials are now supplied to the initialising step
* Cronjob step does not fail if `scheduled` parameter is not set on repo
* init respects `'config already initialized'` string
## [0.2.4] - 2020-06-01
### Added
* `aws_default_region` for repos
## 0.2.3 - 2020-05-18
### Fixed
* extraction path is actually generated
## [0.2.2]
### Changed
* Updated default Restic version to `'0.9.6'`
### Fixed
* Backup scripts use bash (@maciekmm)
* SFTP Link correctly renders in MD
## [0.2.1]
### Fixed
* Crontab entries are now created correctly (@dnmvisser)
* Molecule now correctly runs lint (@mleutenegger)
## [0.2.0]
### Added
* S3 Support
## [0.1.5]
### Changed
* Path generation for `forget` task now checks if `src` is actually filled and not only defined.
### Added
* `prune` option for automatic pruning during forget
## [0.1.4]
### Changed
* `--keep-tags` tags are correctly applied to the forget command
* Backup policies now also check if the respective variable actually contains a value
### Added
* Added a template which only adds credentials for use with `source` on linux distros
## [0.1.3]
### Changed
* Creating script dir before templating out scripts
## [0.1.2]
### Changed
* build sucessfully completes
## [0.1.1]
### Changed
* `restic_url` is now set in defaults
## 0.1.0
### Added
* initial release
[Unreleased]: https://github.com/arillso/ansible.restic/compare/0.2.8...HEAD
[0.2.8]: https://github.com/arillso/ansible.restic/compare/0.2.7...0.2.8
[0.2.7]: https://github.com/arillso/ansible.restic/compare/0.2.6...0.2.7
[0.2.6]: https://github.com/arillso/ansible.restic/compare/0.2.5...0.2.6
[0.2.5]: https://github.com/arillso/ansible.restic/compare/0.2.4...0.2.5
[0.2.4]: https://github.com/arillso/ansible.restic/compare/0.2.3...0.2.4
[0.2.3]: https://github.com/arillso/ansible.restic/compare/0.2.2...0.2.3
[0.2.2]: https://github.com/arillso/ansible.restic/compare/0.2.1...0.2.2
[0.2.1]: https://github.com/arillso/ansible.restic/compare/0.2.0...0.2.1
[0.2.0]: https://github.com/arillso/ansible.restic/compare/0.1.5...0.2.0
[0.1.5]: https://github.com/arillso/ansible.restic/compare/0.1.4...0.1.5
[0.1.4]: https://github.com/arillso/ansible.restic/compare/0.1.3...0.1.4
[0.1.3]: https://github.com/arillso/ansible.restic/compare/0.1.2...0.1.3
[0.1.2]: https://github.com/arillso/ansible.restic/compare/0.1.1...0.1.2
[0.1.1]: https://github.com/arillso/ansible.restic/compare/0.1.0...0.1.1

View file

@ -119,7 +119,7 @@ Repository defined in `restic_repos`.
Available variables: Available variables:
| Name | Required (Default) | Description | | Name | Required (Default) | Description |
| ------------------ |:-----------------------------:| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ------------------ |:-----------------------------:| ------------ |
| `name` | yes | The name of this backup. Used together with pruning and scheduling and needs to be unique. | | `name` | yes | The name of this backup. Used together with pruning and scheduling and needs to be unique. |
| `repo` | yes | The name of the repository to backup to. | | `repo` | yes | The name of the repository to backup to. |
| `src` | yes | The source directory or file | | `src` | yes | The source directory or file |
@ -143,6 +143,9 @@ Available variables:
| `schedule_weekday` | no (`*`) | Weekday when the job is run. ( 0-6 for Sunday-Saturday, *, etc ) | | `schedule_weekday` | no (`*`) | Weekday when the job is run. ( 0-6 for Sunday-Saturday, *, etc ) |
| `schedule_month` | no (`*`) | Month when the job is run. ( 1-12, *, */2, etc ) | | `schedule_month` | no (`*`) | Month when the job is run. ( 1-12, *, */2, etc ) |
| `exclude` | no (`{}`) | Allows you to specify files to exclude. See [Exclude](#exclude) for reference. | | `exclude` | no (`{}`) | Allows you to specify files to exclude. See [Exclude](#exclude) for reference. |
| `disable_logging` | no | Optionally disable logging |
| `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``. |
Example: Example:
```yaml ```yaml

View file

@ -32,6 +32,8 @@ export B2_ACCOUNT_KEY={{ restic_repos[item.repo].b2_account_key }}
{% if item.src is defined %} {% if item.src is defined %}
BACKUP_SOURCE={{ item.src }} BACKUP_SOURCE={{ item.src }}
{% endif %} {% endif %}
set -uxo pipefail set -uxo pipefail
{# {#
Define Tags Define Tags
@ -131,6 +133,8 @@ else
echo "$(date -u '+%Y-%m-%d %H:%M:%S') ERROR" >> {{ backup_result_log }} echo "$(date -u '+%Y-%m-%d %H:%M:%S') ERROR" >> {{ backup_result_log }}
fi fi
{# {#
Define stdin forget commands Define stdin forget commands
#} #}
@ -140,4 +144,7 @@ then
echo "$(date -u '+%Y-%m-%d %H:%M:%S') OK" >> {{ forget_result_log }} echo "$(date -u '+%Y-%m-%d %H:%M:%S') OK" >> {{ forget_result_log }}
else else
echo "$(date -u '+%Y-%m-%d %H:%M:%S') ERROR" >> {{ forget_result_log }} echo "$(date -u '+%Y-%m-%d %H:%M:%S') ERROR" >> {{ forget_result_log }}
{% if item.mail_on_error is defined and item.mail_on_error == true %}
mail -s "restic backup failed on {{ ansible_hostname }}" {{ item.mail_address }} <<< 'Something went wrong while running restic backup script at {{ ansible_hostname }}'
{% endif %}
fi fi

View file

@ -10,5 +10,5 @@ restic_os_variables:
paths: paths:
- 'vars' - 'vars'
playbook_version_number: 8 # should be int playbook_version_number: 9 # should be int
playbook_version_path: 'do1jlr.restic.version' playbook_version_path: 'do1jlr.restic.version'