summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2023-05-22 15:45:24 -0400
committerAndrew Cady <d@jerkface.net>2023-05-22 15:45:24 -0400
commit1e91b2fac8135a37509d9e8129494a639674e7c6 (patch)
tree077aceca8ee08d1597e22de5782a3fdec3887a92
parent684c592ac659de0d934f5c9a47d28348d12e723e (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--Makefile8
-rw-r--r--push-btrfs.path6
-rw-r--r--push-btrfs.service10
-rw-r--r--push-btrfs.timer5
4 files changed, 28 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index ac0ab02..0dd9c7e 100644
--- a/Makefile
+++ b/Makefile
@@ -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)>).
6endif 6endif
7 7
8unit_files = push-btrfs.path push-btrfs.service push-btrfs.timer push-btrfs@.service push-btrfs@.timer
9
10enable_unit = push-btrfs.timer
11
8install: 12install:
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
11go: 17go:
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]
2PathExistsGlob=/etc/btrfs-backup/remotes/*.json
3PathChanged=/etc/btrfs-backup/remotes
4
5[Install]
6WantedBy=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]
2Description = Btrfs Backup over SSH
3ConditionUser = root
4
5[Service]
6WorkingDirectory = /etc/btrfs-backup/remotes
7ExecStart = bash -c 'shopt -s nullglob; for f in *.json; do (set -x; systemctl enable push-btrfs@$$f.timer); done'
8
9[Install]
10WantedBy=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]
2OnUnitInactiveSec=5
3
4[Install]
5WantedBy=default.target