aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/cleanup-backup4
-rw-r--r--system/cleanup-backup.service11
-rw-r--r--system/cleanup-backup.timer10
3 files changed, 25 insertions, 0 deletions
diff --git a/scripts/cleanup-backup b/scripts/cleanup-backup
new file mode 100755
index 0000000..af62b88
--- /dev/null
+++ b/scripts/cleanup-backup
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+
+# Delete files in specified folder, older than "older_than" (in days)
+find $cleanup_folder -type f -atime +$older_than -print -exec rm {} \;
diff --git a/system/cleanup-backup.service b/system/cleanup-backup.service
new file mode 100644
index 0000000..3524b30
--- /dev/null
+++ b/system/cleanup-backup.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Cleanup backups
+ConditionFileIsExecutable=/usr/lib/systemd/scripts/cleanup-backup
+
+[Service]
+EnvironmentFile=/etc/backup-settings
+Nice=19
+IOSchedulingClass=2
+IOSchedulingPriority=7
+ExecStart=/usr/lib/systemd/scripts/cleanup-backup
+
diff --git a/system/cleanup-backup.timer b/system/cleanup-backup.timer
new file mode 100644
index 0000000..9879312
--- /dev/null
+++ b/system/cleanup-backup.timer
@@ -0,0 +1,10 @@
+[Unit]
+Description=Cleanup backups every 3rd and 18th of each month at 05:00
+
+[Timer]
+# Every 3rd and 18th of each month at 5:00
+OnCalendar=*-*-3,18 05:00
+Persistent=true
+
+[Install]
+WantedBy=timers.target