From c5c23768aeaa7d69c4c1ad713e56ab791f708f44 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 2 Oct 2023 10:58:06 +0200 Subject: systemd service and timer for backup removal --- .gitignore | 2 ++ Makefile | 3 ++- remove-old-backups.service.in | 8 ++++++++ remove-old-backups.timer.in | 10 ++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 remove-old-backups.service.in create mode 100644 remove-old-backups.timer.in 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 -- cgit v1.2.3-70-g09d2