Browse Source

Added general maintenance component for running prune/check/cache cleanup/etc instead ;];];];]];;];]

Wazakindjes 2 months ago
parent
commit
18780b4b29

+ 10 - 0
components/maintenance/README.md

@@ -0,0 +1,10 @@
+# The fuck is this
+Recurring maintenance shit breh. ;]
+
+# Usage
+Go to the `conf` dir and copy the sole `*.sh.example` file (remove `.example` 0bv m9). Everything is explained in thur (not that there is a lot to explain lel).
+
+There is a single ~~flying fuck~~ script over hur:
+* `run_maintenance_all.sh`: for actually running that shit, similar to the `run_backup_all.sh` scripts from other components
+
+E Z

+ 11 - 0
components/maintenance/conf/restic.sh.example

@@ -0,0 +1,11 @@
+#!/bin/bash
+# All of restic's functions are run in the same order as the directives bel0w ;]
+
+# Run `restic prune` on every maintenance run
+export MUHRESTIC_MAINTENANCE_PRUNE=1
+
+# Also `check`
+export MUHRESTIC_MAINTENANCE_CHECK=1
+
+# And `cache --cleanup` at the very end, we can do this because `check` downloads a fresh cache anyways =]
+export MUHRESTIC_MAINTENANCE_CACHECLEANUP=1

+ 28 - 0
components/maintenance/run_maintenance_all.sh

@@ -0,0 +1,28 @@
+#!/bin/bash
+SKRIPDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
+wrapname=$(basename "$0")
+source "$SKRIPDIR/../common/functions.sh" || exit 254
+source "$SKRIPDIR/../../conf/restic.sh" || exit 254
+source "$SKRIPDIR/conf/restic.sh" || exit 254
+
+echo "=============== AYY STARTING LOL ==============="
+date
+starttime_grand=`date +%s`
+
+echo ""
+echo "======= Preliminaries ======="
+muhbackup_pre_binaries
+muhrestic_pre_update
+
+echo ""
+echo "======= Maintenance start ======="
+[[ $MUHRESTIC_MAINTENANCE_PRUNE -eq 1 ]] && muhrestic_post_prune
+[[ $MUHRESTIC_MAINTENANCE_CHECK -eq 1 ]] && muhrestic_post_check
+[[ $MUHRESTIC_MAINTENANCE_CACHECLEANUP -eq 1 ]] && muhrestic_post_cachecleanup
+
+echo ""
+echo "======= Finalising ======="
+date
+echo -n "Total maintenance run time: "
+difftime_grand=$((`date +%s` - $starttime_grand))
+muhbackup_sec2h00man $difftime_grand