forked from erikw/restic-automatic-backup-scheduler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request erikw#17 from toddejohnson/16-metered-net
Add requires to unmetered-connection.service
- Loading branch information
Showing
6 changed files
with
32 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[Unit] | ||
Description=Check if the current NetworkManager connection is metered | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/local/sbin/nm-unmetered-connection.sh | ||
|
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,10 +1,11 @@ | ||
[Unit] | ||
Description=Backup with restic to Backblaze B2 | ||
OnFailure=status-email-user@%n.service | ||
Requires=nm-unmetered-connection.service | ||
|
||
[Service] | ||
Type=simple | ||
Nice=10 | ||
ExecStart=/usr/local/sbin/restic_backup.sh | ||
# $HOME or $XDG_CACHE_HOME must be set for restic to find /root/.cache/restic/ | ||
Environment="HOME=/root" | ||
Environment="HOME=/root" |
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
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
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,9 +1,10 @@ | ||
[Unit] | ||
Description=Check restic backup Backblaze B2 for errors on a schedule | ||
Requires=nm-unmetered-connection.service | ||
|
||
[Timer] | ||
OnCalendar=monthly | ||
Persistent=true | ||
|
||
[Install] | ||
WantedBy=timers.target | ||
WantedBy=timers.target |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
systemctl is-active dbus.service >/dev/null 2>&1 || exit 0 | ||
systemctl is-active NetworkManager.service >/dev/null 2>&1 || exit 0 | ||
|
||
metered_status=$(dbus-send --system --print-reply=literal \ | ||
--system --dest=org.freedesktop.NetworkManager \ | ||
/org/freedesktop/NetworkManager \ | ||
org.freedesktop.DBus.Properties.Get \ | ||
string:org.freedesktop.NetworkManager string:Metered \ | ||
| grep -o ".$") | ||
|
||
if [[ $metered_status =~ (1|3) ]]; then | ||
echo Current connection is metered | ||
exit 1 | ||
else | ||
exit 0 | ||
fi | ||
|