Only run timegaps on included files

This commit is contained in:
ViViDboarder 2023-12-07 09:47:12 -08:00
parent 7f991c490e
commit 1a340d5829
2 changed files with 23 additions and 8 deletions

View File

@ -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

21
rclone/rootfs/run_timegaps.sh Executable file
View File

@ -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