[pmg-devel] [PATCH pmg-api 11/11] add daily timer for pruning configured remotes

Stoiko Ivanov s.ivanov at proxmox.com
Wed Oct 28 19:54:29 CET 2020


The service runs `pmgbackup pbsjob prune` , which iterates through all
configured remotes and runs prune with the set keep settings.

Running once daily seems like a sensible tradeoff (prune is not so expensive)

adding the dedicated systemd.timer, instead of simply hooking it into
pmg-daily, should make it easier for users who want to override the settings.

Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 debian/pmg-pbsprune.service |  6 ++++++
 debian/pmg-pbsprune.timer   | 10 ++++++++++
 debian/rules                |  3 ++-
 src/Makefile                |  4 ++--
 4 files changed, 20 insertions(+), 3 deletions(-)
 create mode 100644 debian/pmg-pbsprune.service
 create mode 100644 debian/pmg-pbsprune.timer

diff --git a/debian/pmg-pbsprune.service b/debian/pmg-pbsprune.service
new file mode 100644
index 0000000..b7fd633
--- /dev/null
+++ b/debian/pmg-pbsprune.service
@@ -0,0 +1,6 @@
+[Unit]
+Description=Prune all configured Proxmox Backup Server Remotes
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/pmgbackup pbsjob prune
diff --git a/debian/pmg-pbsprune.timer b/debian/pmg-pbsprune.timer
new file mode 100644
index 0000000..52c7e06
--- /dev/null
+++ b/debian/pmg-pbsprune.timer
@@ -0,0 +1,10 @@
+[Unit]
+Description=Prune all configured Proxmox Backup Server Remotes
+
+[Timer]
+OnCalendar=04:00
+RandomizedDelaySec=1hours
+Persistent=true
+
+[Install]
+WantedBy=timers.target
diff --git a/debian/rules b/debian/rules
index 5a2cf7a..227b761 100755
--- a/debian/rules
+++ b/debian/rules
@@ -21,9 +21,10 @@ override_dh_installinit:
 	dh_systemd_enable --name=pmgreport pmgreport.service
 	dh_systemd_enable --name=pmgsync pmgsync.service
 	dh_systemd_enable --no-enable --name=pmg-pbsbackup@ pmg-pbsbackup at .service
+	dh_systemd_enable --name=pmg-pbsprune pmg-pbsprune.service
 
 override_dh_systemd_start:
-	dh_systemd_start pmg-hourly.timer pmg-daily.timer pmgspamreport.timer pmgreport.timer
+	dh_systemd_start pmg-hourly.timer pmg-daily.timer pmgspamreport.timer pmgreport.timer pmg-pbsprune.timer
 	dh_systemd_start --no-restart-on-upgrade --no-start pmgnetcommit.service pmgbanner.service pmgsync.service
 	dh_systemd_start pmg-smtp-filter.service pmgpolicy.service pmgtunnel.service pmgmirror.service
 	# we handle pmgproxy/pmgdaemon manually (use reload instead of restart to keep vnc connection active)
diff --git a/src/Makefile b/src/Makefile
index 9d5c335..85e91ce 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -15,8 +15,8 @@ CRONSCRIPTS = pmg-hourly pmg-daily
 
 CLI_CLASSES = $(addprefix PMG/CLI/, $(addsuffix .pm, ${CLITOOLS}))
 SERVICE_CLASSES = $(addprefix PMG/Service/, $(addsuffix .pm, ${SERVICES}))
-SERVICE_UNITS = $(addprefix debian/, $(addsuffix .service, ${SERVICES} pmg-pbsbackup@))
-TIMER_UNITS = $(addprefix debian/, $(addsuffix .timer, ${CRONSCRIPTS} pmgspamreport pmgreport))
+SERVICE_UNITS = $(addprefix debian/, $(addsuffix .service, ${SERVICES} pmg-pbsbackup@ pmg-pbsprune))
+TIMER_UNITS = $(addprefix debian/, $(addsuffix .timer, ${CRONSCRIPTS} pmgspamreport pmgreport pmg-pbsprune))
 
 CLI_BINARIES = $(addprefix bin/, ${CLITOOLS} ${CLISCRIPTS} ${CRONSCRIPTS})
 CLI_MANS = $(addsuffix .1, ${CLITOOLS}) pmgsh.1 pmg-system-report.1
-- 
2.20.1





More information about the pmg-devel mailing list