9 Commits

Author SHA1 Message Date
Erik Westrup
4952cc3ee1 Modified: CHANGELOG.md 2022-02-15 17:49:11 +01:00
Erik Westrup
3ecc3c3510 Consistent default values 2022-02-15 17:47:51 +01:00
Erik Westrup
65172e650b Merge pull request #76 from gerardbosch/feature/desktop-notifications
Add optional desktop notifications
2022-02-15 17:45:07 +01:00
Gerard Bosch
705248ee00 Final cleanup 2022-02-15 16:06:19 +01:00
Gerard Bosch
be2c3163a8 Rework notification data fetching: Use stats+diff 2022-02-15 13:50:10 +01:00
Erik Westrup
84e083c62e Modified: README.md 2022-02-15 12:46:27 +01:00
Gerard Bosch
7dde85f25e Reformat 2022-02-12 10:02:03 +01:00
Gerard Bosch
9ebc9ea641 Replace 'here string' syntax with echo + pipe 2022-02-12 08:47:09 +01:00
Gerard Bosch
3f000ce137 Add optional desktop notifications
When backing up a desktop system it is handy to have regular and
immediate feedback about backups. This features a notification of backup
stats summary, including the added size to the repository, so you can
have a quick follow-up about what are you uploading to the repository.

This may be very useful if you upload by accident a big file or directory
which should be in your exclusions, so it warns you and gives the chance
to fix the exclusions and remove the undesired snapshot later.
2022-02-09 18:19:48 +01:00
4 changed files with 45 additions and 2 deletions

View File

@@ -5,10 +5,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [7.3.0] - 2022-02-15
### Added
- optional user-controlled notification. See `RESTIC_NOTIFY_BACKUP_STATS` and in `backup.sh`.
## [7.2.0] - 2022-02-15
### Added
- restic-check launchagent.
- restic-check LaunchAgent.
### Changed
- [README.md](README.md) is restructured with easier TL;DR for each OS and a more general detailed section for the interested.

View File

@@ -517,4 +517,6 @@ To make a new release:
$ git push && git push --tags
```
1. Update version in the AUR [PKGBUILD](https://aur.archlinux.org/packages/restic-automatic-backup-scheduler/).
1. Update version in the Homebrew [Formula](https://github.com/erikw/homebrew-tap/blob/main/Formula/restic-automatic-backup-scheduler.rb).
1. Update version in the Homebrew Formulas:
* [restic-automatic-backup-scheduler](https://github.com/erikw/homebrew-tap/blob/main/Formula/restic-automatic-backup-scheduler.rb).
* [restic-automatic-backup-scheduler-check](https://github.com/erikw/homebrew-tap/blob/main/Formula/restic-automatic-backup-scheduler-check.rb).

View File

@@ -105,3 +105,37 @@ wait $!
#wait $!
echo "Backup & cleaning is done."
#
# (optionally) Notify about backup summary stats.
#
# How to perform the notification is up to the user; the script only writes the info to a user-owned file in a fire
# and forget fashion. One option is using a special FIFO file (aka pipe file) on user-side (which will work as a queue)
# together with an auto-started user process to read from that queue and trigger the notification.
#
# Examples of such setup:
# - Linux autostart + cross-platform notifier
# https://github.com/gerardbosch/dotfiles-linux/blob/ea0f75bfd7a356945544ecaa42a2fc35c9fab3a1/home/.config/autostart/notification-queue.desktop
# https://github.com/gerardbosch/dotfiles/blob/ddc1491056822eab45dedd131f1946308ef62135/home/bin/notification-queue-notifier
# - MacOS autostart + terminal-notifier
# https://github.com/erikw/dotfiles/blob/c25f44db1cad675becf91fc3ff28a5a4dfc4a373/bin/com.user.notificationqueue.plist
# https://github.com/erikw/dotfiles/blob/c25f44db1cad675becf91fc3ff28a5a4dfc4a373/bin/notification-queue-notifier.sh
#
if [ "$RESTIC_NOTIFY_BACKUP_STATS" = true ]; then
if [ -w "$RESTIC_BACKUP_NOTIFICATION_FILE" ]; then
echo 'Notifications are enabled: Silently computing backup summary stats...'
snapshot_size=$(restic stats latest --tag "$RESTIC_BACKUP_TAG" | grep -i 'total size:' | cut -d ':' -f2 | xargs) # xargs acts as trim
latest_snapshot_diff=$(restic snapshots --tag "$RESTIC_BACKUP_TAG" --latest 2 --compact \
| grep -Ei "^[abcdef0-9]{8} " \
| awk '{print $1}' \
| tr '\n' ' ' \
| xargs restic diff)
added=$(echo "$latest_snapshot_diff" | grep -i 'added:' | awk '{print $2 " " $3}')
removed=$(echo "$latest_snapshot_diff" | grep -i 'removed:' | awk '{print $2 " " $3}')
echo "Added: ${added}. Removed: ${removed}. Snap size: ${snapshot_size}" >> "$RESTIC_BACKUP_NOTIFICATION_FILE"
else
echo "[WARN] Couldn't write the backup summary stats. File not found or not writable: ${RESTIC_BACKUP_NOTIFICATION_FILE}"
fi
fi

View File

@@ -29,3 +29,7 @@ export RESTIC_BACKUP_EXTRA_ARGS=
# Verbosity level from 0-3. 0 means no --verbose.
# Override this value in a profile if needed.
export RESTIC_VERBOSITY_LEVEL=0
# (optional) Desktop notifications. See restic_backup.sh for details on how to set this up.
export RESTIC_NOTIFY_BACKUP_STATS=false
export RESTIC_BACKUP_NOTIFICATION_FILE=