From 9ca9f40817e0eb34e99b6c3ea0b636637afaa0a5 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Wed, 5 Jul 2023 13:47:17 +0000 Subject: [PATCH] feat: add dump all cron --- unit-files/dump_all.service | 4 ++++ unit-files/dump_all.timer | 8 ++++++++ utils/dump_all.sh | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 unit-files/dump_all.service create mode 100644 unit-files/dump_all.timer create mode 100644 utils/dump_all.sh diff --git a/unit-files/dump_all.service b/unit-files/dump_all.service new file mode 100644 index 0000000..85b4292 --- /dev/null +++ b/unit-files/dump_all.service @@ -0,0 +1,4 @@ +[Service] +Type=oneshot +Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin +ExecStart=/opt/bin/dump_all.sh diff --git a/unit-files/dump_all.timer b/unit-files/dump_all.timer new file mode 100644 index 0000000..bd56910 --- /dev/null +++ b/unit-files/dump_all.timer @@ -0,0 +1,8 @@ +[Unit] +Description=Run dump all dayly + +[Timer] +OnCalendar=*-*-* 00:15:30 + +[Install] +WantedBy=timers.target diff --git a/utils/dump_all.sh b/utils/dump_all.sh new file mode 100644 index 0000000..2d9bb21 --- /dev/null +++ b/utils/dump_all.sh @@ -0,0 +1,19 @@ +#!/bin/bash -eux + +export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin + +echo BEGIN > /tmp/dump-logs +date > /tmp/dump-logs + +for domain in `ls /data/domains`; do + echo $domain >> /tmp/dump-logs + cd /data/domains/${domain}/ + if [[ -f ./scripts/pre-backup ]]; then + cat ./scripts/pre-backup >> /tmp/dump-logs + ./scripts/pre-backup >> /tmp/dump-logs + fi +done + +date > /tmp/dump +echo END >> /tmp/dump-logs +date >> /tmp/dump-logs -- GitLab