summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2023-10-02 10:58:06 +0200
committerErich Eckner <git@eckner.net>2023-10-02 10:58:06 +0200
commitc5c23768aeaa7d69c4c1ad713e56ab791f708f44 (patch)
treed2376b3890376aeebf9eb4a22f557716eaf8400d
parent686a96b0150266f4c1c993373f9d195a11137614 (diff)
downloadhardlinkedBackups-c5c23768aeaa7d69c4c1ad713e56ab791f708f44.tar.xz
systemd service and timer for backup removal
-rw-r--r--.gitignore2
-rw-r--r--Makefile3
-rw-r--r--remove-old-backups.service.in8
-rw-r--r--remove-old-backups.timer.in10
4 files changed, 22 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 6dae642..0aa8bb6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,5 @@ remove-old-backups
man.commons
*.common
*.1
+remove-old-backups.service
+remove-old-backups.timer
diff --git a/Makefile b/Makefile
index d26d0d4..c735fe3 100644
--- a/Makefile
+++ b/Makefile
@@ -35,6 +35,7 @@ all: man.commons \
backup-statistics backup-statistics.1 \
forwarddown forwarddown.1 \
last-backups last-backups.1 \
+ remove-old-backups.service remove-old-backups.timer \
remove-old-backups remove-old-backups.1
%: %.in
@@ -55,7 +56,7 @@ all: man.commons \
install: all
install -D -m0755 -t $(DESTDIR)$(BINDIR) backup backup-progress backup-statistics forwarddown last-backups remove-old-backups
- install -D -m0644 -t $(DESTDIR)$(LIBDIR)/systemd/system backup@.service backup@.timer
+ install -D -m0644 -t $(DESTDIR)$(LIBDIR)/systemd/system backup@.service backup@.timer remove-old-backups.service remove-old-backups.timer
install -D -m0644 -t $(DESTDIR)$(MANDIR)/man1 backup.1 backup-statistics.1 forwarddown.1 last-backups.1 remove-old-backups.1
install -D -m0644 -t $(DESTDIR)$(ETCDIR) backup.conf
install -D -m0755 -T sendmailadvanced.hook $(DESTDIR)$(ETCDIR)/sendmailadvanced.hooks/last-backups
diff --git a/remove-old-backups.service.in b/remove-old-backups.service.in
new file mode 100644
index 0000000..dea3649
--- /dev/null
+++ b/remove-old-backups.service.in
@@ -0,0 +1,8 @@
+[Unit]
+Description=Remove old backups.
+Requires=network-online.target local-fs.target
+After=network-online.target local-fs.target
+
+[Service]
+Type=simple
+ExecStart=#BINDIR#/remove-old-backups
diff --git a/remove-old-backups.timer.in b/remove-old-backups.timer.in
new file mode 100644
index 0000000..673e18e
--- /dev/null
+++ b/remove-old-backups.timer.in
@@ -0,0 +1,10 @@
+[Unit]
+Description=Regularly remove old backups.
+
+[Timer]
+AccuracySec=1us
+RandomizedDelaySec=1day
+OnCalendar=*-*-* 00:00:00
+
+[Install]
+WantedBy=timers.target