From 1a340d5829307db84214340707a1e4478f9de1e9 Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Thu, 7 Dec 2023 09:47:12 -0800 Subject: [PATCH] Only run timegaps on included files --- rclone/rootfs/etc/cont-init.d/timegaps.sh | 10 ++-------- rclone/rootfs/run_timegaps.sh | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 8 deletions(-) create mode 100755 rclone/rootfs/run_timegaps.sh diff --git a/rclone/rootfs/etc/cont-init.d/timegaps.sh b/rclone/rootfs/etc/cont-init.d/timegaps.sh index 400285d..068de3d 100755 --- a/rclone/rootfs/etc/cont-init.d/timegaps.sh +++ b/rclone/rootfs/etc/cont-init.d/timegaps.sh @@ -1,16 +1,10 @@ #! /usr/bin/with-contenv bashio -bashio::log.info "Configuring pruning with timegaps..." TIMEGAPS_RULES=$(bashio::config 'prune.rules') TIMEGAPS_CRON=$(bashio::config 'prune.cron') -TIMEGAPS_DELETE="" -if bashio::config.true 'prune.delete'; then - TIMEGAPS_DELETE="--delete" -fi if [ -n "$TIMEGAPS_RULES" ] && [ -n "$TIMEGAPS_CRON" ]; then - COMMAND="timegaps $TIMEGAPS_DELETE $TIMEGAPS_RULES /backup/*.tar" - - echo "$TIMEGAPS_CRON $COMMAND" >> /etc/crontabs/root + bashio::log.info "Configuring pruning with timegaps..." + echo "$TIMEGAPS_CRON /run_timegaps.sh" >> /etc/crontabs/root crontab -l fi diff --git a/rclone/rootfs/run_timegaps.sh b/rclone/rootfs/run_timegaps.sh new file mode 100755 index 0000000..7b496ad --- /dev/null +++ b/rclone/rootfs/run_timegaps.sh @@ -0,0 +1,21 @@ +#! /usr/bin/with-contenv bashio + +set +x +set -eo pipefail + +bashio::log.info "Running timegaps..." + +TIMEGAPS_RULES=$(bashio::config 'prune.rules') +TIMEGAPS_DELETE="" +if bashio::config.true 'prune.delete'; then + TIMEGAPS_DELETE="--delete" +fi + +if bashio::config.true 'protected_only'; then + find /backup -name "*.tar" -exec tar -xOf "{}" ./backup.json \; \ + | jq -r 'select(.protected) | "\(.slug).tar"' \ + | timegaps --stdin $TIMEGAPS_DELETE "$TIMEGAPS_RULES" +else + timegaps $TIMEGAPS_DELETE "$TIMEGAPS_RULES" +fi +