mirror of
https://github.com/roles-ansible/ansible_role_restic/
synced 2024-11-13 23:30:19 +01:00
adding mail on error feature
This commit is contained in:
parent
f385bfcb73
commit
9b8d0fe599
5 changed files with 27 additions and 133 deletions
19
CHANGELOG.md
19
CHANGELOG.md
|
@ -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
|
|
97
HISTORY.md
97
HISTORY.md
|
@ -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
|
|
35
README.md
35
README.md
|
@ -118,16 +118,16 @@ 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 |
|
||||||
| `stdin` | no | Is this backup created from a [stdin](https://restic.readthedocs.io/en/stable/040_backup.html#reading-data-from-stdin)? |
|
| `stdin` | no | Is this backup created from a [stdin](https://restic.readthedocs.io/en/stable/040_backup.html#reading-data-from-stdin)? |
|
||||||
| `stdin_cmd` | no (yes if `stdin` == `true`) | The command to produce the stdin. |
|
| `stdin_cmd` | no (yes if `stdin` == `true`) | The command to produce the stdin. |
|
||||||
| `stdin_filename` | no | The filename used in the repository. |
|
| `stdin_filename` | no | The filename used in the repository. |
|
||||||
| `tags` | no | Array of default tags |
|
| `tags` | no | Array of default tags |
|
||||||
| `keep_last` | no | If set, only keeps the last n snapshots. |
|
| `keep_last` | no | If set, only keeps the last n snapshots. |
|
||||||
| `keep_hourly` | no | If set, only keeps the last n hourly snapshots. |
|
| `keep_hourly` | no | If set, only keeps the last n hourly snapshots. |
|
||||||
| `keep_daily` | no | If set, only keeps the last n daily snapshots. |
|
| `keep_daily` | no | If set, only keeps the last n daily snapshots. |
|
||||||
| `keep_weekly ` | no | If set, only keeps the last n weekly snapshots. |
|
| `keep_weekly ` | no | If set, only keeps the last n weekly snapshots. |
|
||||||
|
@ -136,13 +136,16 @@ Available variables:
|
||||||
| `keep_within` | no | If set, only keeps snapshots in this time period. |
|
| `keep_within` | no | If set, only keeps snapshots in this time period. |
|
||||||
| `keep_tag` | no | If set, keep snapshots with this tags. Make sure to specify a list. |
|
| `keep_tag` | no | If set, keep snapshots with this tags. Make sure to specify a list. |
|
||||||
| `prune` | no (`false`) | If `true`, the `restic forget` command in the script has the [`--prune` option](https://restic.readthedocs.io/en/stable/060_forget.html#removing-backup-snapshots) appended. |
|
| `prune` | no (`false`) | If `true`, the `restic forget` command in the script has the [`--prune` option](https://restic.readthedocs.io/en/stable/060_forget.html#removing-backup-snapshots) appended. |
|
||||||
| `scheduled` | no (`false`) | If `restic_create_cron` is set to `true`, this backup is scheduled and tries to create a systemd timer unit. If it fails, it is creating a cronjob. |
|
| `scheduled` | no (`false`) | If `restic_create_cron` is set to `true`, this backup is scheduled and tries to create a systemd timer unit. If it fails, it is creating a cronjob. |
|
||||||
| `schedule_oncalendar` | ``'*-*-* 02:00:00'`` | The time for the systemd timer. Please notice the randomDelaySec option. By Default the backup is done every night at 2 am (+0-4h). But only if scheduled is true. |
|
| `schedule_oncalendar` | ``'*-*-* 02:00:00'`` | The time for the systemd timer. Please notice the randomDelaySec option. By Default the backup is done every night at 2 am (+0-4h). But only if scheduled is true. |
|
||||||
| `schedule_minute` | no (`*`) | Minute when the job is run. ( 0-59, *, */2, etc ) |
|
| `schedule_minute` | no (`*`) | Minute when the job is run. ( 0-59, *, */2, etc ) |
|
||||||
| `schedule_hour` | no (`*`) | Hour when the job is run. ( 0-23, *, */2, etc ) |
|
| `schedule_hour` | no (`*`) | Hour when the job is run. ( 0-23, *, */2, etc ) |
|
||||||
| `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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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'
|
||||||
|
|
Loading…
Reference in a new issue