From e9e27f1f34af2cded25db2d3d2c89cf74cc63198 Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Mon, 28 Mar 2022 08:11:40 -0700 Subject: [PATCH] add systemd timer to run daily backups --- .../bashup-backup-files.sh | 0 .../bashup-backup-mysql.sh | 0 .../bashup-backup-pdns.sh | 0 sbin/bashup-cron.sh | 14 ++++++++++++++ .../bashup-list-backups.sh | 0 .../bashup-restore-files.sh | 0 .../bashup-restore-mysql.sh | 0 .../bashup-restore-pdns.sh | 0 bashup.sh => sbin/bashup.sh | 0 systemd/bashup-cron.service | 10 ++++++++++ systemd/bashup-cron.timer | 15 +++++++++++++++ 11 files changed, 39 insertions(+) rename bashup-backup-files.sh => sbin/bashup-backup-files.sh (100%) rename bashup-backup-mysql.sh => sbin/bashup-backup-mysql.sh (100%) rename bashup-backup-pdns.sh => sbin/bashup-backup-pdns.sh (100%) create mode 100755 sbin/bashup-cron.sh rename bashup-list-backups.sh => sbin/bashup-list-backups.sh (100%) rename bashup-restore-files.sh => sbin/bashup-restore-files.sh (100%) rename bashup-restore-mysql.sh => sbin/bashup-restore-mysql.sh (100%) rename bashup-restore-pdns.sh => sbin/bashup-restore-pdns.sh (100%) rename bashup.sh => sbin/bashup.sh (100%) create mode 100644 systemd/bashup-cron.service create mode 100644 systemd/bashup-cron.timer diff --git a/bashup-backup-files.sh b/sbin/bashup-backup-files.sh similarity index 100% rename from bashup-backup-files.sh rename to sbin/bashup-backup-files.sh diff --git a/bashup-backup-mysql.sh b/sbin/bashup-backup-mysql.sh similarity index 100% rename from bashup-backup-mysql.sh rename to sbin/bashup-backup-mysql.sh diff --git a/bashup-backup-pdns.sh b/sbin/bashup-backup-pdns.sh similarity index 100% rename from bashup-backup-pdns.sh rename to sbin/bashup-backup-pdns.sh diff --git a/sbin/bashup-cron.sh b/sbin/bashup-cron.sh new file mode 100755 index 0000000..64a3ec3 --- /dev/null +++ b/sbin/bashup-cron.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# +# Bashup - A set of bash scripts for managing backups. +# https://git.stack-source.com/msb/bashup +# MIT License Copyright (c) 2022 Matthew Saunders Brown + +# load include file +source /usr/local/sbin/bashup.sh + +for job in "${bashup_jobs[@]}"; do + if [[ -x /usr/local/sbin/bashup-backup-$job.sh ]]; then + /usr/local/sbin/bashup-backup-$job.sh + fi +done diff --git a/bashup-list-backups.sh b/sbin/bashup-list-backups.sh similarity index 100% rename from bashup-list-backups.sh rename to sbin/bashup-list-backups.sh diff --git a/bashup-restore-files.sh b/sbin/bashup-restore-files.sh similarity index 100% rename from bashup-restore-files.sh rename to sbin/bashup-restore-files.sh diff --git a/bashup-restore-mysql.sh b/sbin/bashup-restore-mysql.sh similarity index 100% rename from bashup-restore-mysql.sh rename to sbin/bashup-restore-mysql.sh diff --git a/bashup-restore-pdns.sh b/sbin/bashup-restore-pdns.sh similarity index 100% rename from bashup-restore-pdns.sh rename to sbin/bashup-restore-pdns.sh diff --git a/bashup.sh b/sbin/bashup.sh similarity index 100% rename from bashup.sh rename to sbin/bashup.sh diff --git a/systemd/bashup-cron.service b/systemd/bashup-cron.service new file mode 100644 index 0000000..3b0bc40 --- /dev/null +++ b/systemd/bashup-cron.service @@ -0,0 +1,10 @@ +# Bashup - A set of bash scripts for managing backups. +# https://git.stack-source.com/msb/bashup +# MIT License Copyright (c) 2022 Matthew Saunders Brown +# +[Unit] +Description=Bashup cron for automatic backups + +[Service] +Type=simple +ExecStart=/usr/local/sbin/bashup-cron.sh diff --git a/systemd/bashup-cron.timer b/systemd/bashup-cron.timer new file mode 100644 index 0000000..d32f0b8 --- /dev/null +++ b/systemd/bashup-cron.timer @@ -0,0 +1,15 @@ +# Bashup - A set of bash scripts for managing backups. +# https://git.stack-source.com/msb/bashup +# MIT License Copyright (c) 2022 Matthew Saunders Brown +# +[Unit] +Description=Bashup cron for automatic backups + +[Timer] +# Run daily between 3-5 am +OnCalendar=*-*-* 03:00:00 +RandomizedDelaySec=7200 +Unit=bashup-cron.service + +[Install] +WantedBy=timers.target