diff options
author | Andrew Cady <d@jerkface.net> | 2023-05-22 15:45:24 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2023-05-22 15:45:24 -0400 |
commit | 1e91b2fac8135a37509d9e8129494a639674e7c6 (patch) | |
tree | 077aceca8ee08d1597e22de5782a3fdec3887a92 | |
parent | 684c592ac659de0d934f5c9a47d28348d12e723e (diff) |
poll with timer just to instantiate timers, ugh!
This makes everything work through systemd though.
The user can simply drop config files into
/etc/btrfs-backup/remotes/<name>.json and timers will automatically be
created to handle syncing.
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | push-btrfs.path | 6 | ||||
-rw-r--r-- | push-btrfs.service | 10 | ||||
-rw-r--r-- | push-btrfs.timer | 5 |
4 files changed, 28 insertions, 1 deletions
@@ -5,8 +5,14 @@ ifeq ($(remotes),) | |||
5 | $(error You must put at least one *.json configuration file into <file:///$(config_dir)>). | 5 | $(error You must put at least one *.json configuration file into <file:///$(config_dir)>). |
6 | endif | 6 | endif |
7 | 7 | ||
8 | unit_files = push-btrfs.path push-btrfs.service push-btrfs.timer push-btrfs@.service push-btrfs@.timer | ||
9 | |||
10 | enable_unit = push-btrfs.timer | ||
11 | |||
8 | install: | 12 | install: |
9 | for remote in $(remotes); do systemctl enable push-btrfs@$$remote.service; systemctl enable --now push-btrfs@$$remote.timer; done | 13 | systemctl link $(addprefix ./, $(unit_files)) |
14 | systemctl reset-failed $(enable_unit) | ||
15 | systemctl enable --now $(enable_unit) | ||
10 | 16 | ||
11 | go: | 17 | go: |
12 | for remote in $(remotes); do bash$(if $(verbose), -x) push-btrfs $$remote$(if $(verbose),;, &) done; wait | 18 | for remote in $(remotes); do bash$(if $(verbose), -x) push-btrfs $$remote$(if $(verbose),;, &) done; wait |
diff --git a/push-btrfs.path b/push-btrfs.path new file mode 100644 index 0000000..1767b1f --- /dev/null +++ b/push-btrfs.path | |||
@@ -0,0 +1,6 @@ | |||
1 | [Path] | ||
2 | PathExistsGlob=/etc/btrfs-backup/remotes/*.json | ||
3 | PathChanged=/etc/btrfs-backup/remotes | ||
4 | |||
5 | [Install] | ||
6 | WantedBy=default.target | ||
diff --git a/push-btrfs.service b/push-btrfs.service new file mode 100644 index 0000000..ec9d3cd --- /dev/null +++ b/push-btrfs.service | |||
@@ -0,0 +1,10 @@ | |||
1 | [Unit] | ||
2 | Description = Btrfs Backup over SSH | ||
3 | ConditionUser = root | ||
4 | |||
5 | [Service] | ||
6 | WorkingDirectory = /etc/btrfs-backup/remotes | ||
7 | ExecStart = bash -c 'shopt -s nullglob; for f in *.json; do (set -x; systemctl enable push-btrfs@$$f.timer); done' | ||
8 | |||
9 | [Install] | ||
10 | WantedBy=default.target | ||
diff --git a/push-btrfs.timer b/push-btrfs.timer new file mode 100644 index 0000000..982df5c --- /dev/null +++ b/push-btrfs.timer | |||
@@ -0,0 +1,5 @@ | |||
1 | [Timer] | ||
2 | OnUnitInactiveSec=5 | ||
3 | |||
4 | [Install] | ||
5 | WantedBy=default.target | ||