From de4b02dae76ea3ed9820ba8624105eae6ec43dbd Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Mon, 13 Nov 2023 13:52:24 -0800 Subject: [PATCH] Fix protected file filter variable The filter was only being set during schedule creation. This meant that no new files created since scheduling the task would be included. To avoid this, the rclone command is now built when the task is run instead via a new script. --- rclone/rootfs/etc/cont-init.d/rclone.sh | 16 +--------------- rclone/rootfs/run_rclone.sh | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 15 deletions(-) create mode 100755 rclone/rootfs/run_rclone.sh diff --git a/rclone/rootfs/etc/cont-init.d/rclone.sh b/rclone/rootfs/etc/cont-init.d/rclone.sh index f610ac3..a729c60 100755 --- a/rclone/rootfs/etc/cont-init.d/rclone.sh +++ b/rclone/rootfs/etc/cont-init.d/rclone.sh @@ -8,19 +8,5 @@ bashio::config.require.password 'credentials.password' bashio::config.suggest.true 'tls.ssl' bashio::config.require.ssl 'tls' 'tls.certfile' 'tls.keyfile' -SYNC_COMMAND=$(bashio::config 'sync_command') -DESTINATION=$(bashio::config 'destination') - -USERNAME=$(bashio::config 'credentials.username') -PASSWORD=$(bashio::config 'credentials.password') - -FILTER='{"IncludeRule": ["*.tar"]}' -if bashio::config.true 'protected_only'; then - FILTER="{\"IncludeRule\": $(find /backup -name "*.tar" -exec tar -xOf "{}" ./backup.json \;| jq -sc 'map(select(.protected) | "/backup/\(.slug).tar")')}" - FILTER= -fi - -command="rclone rc --user \"$USERNAME\" --pass \"$PASSWORD\" sync/$SYNC_COMMAND srcFs=/backup dstFs=$DESTINATION _async=true _filter='$FILTER'" - -echo "$(bashio::config 'cron') $command" >> /etc/crontabs/root +echo "$(bashio::config 'cron') /run_rclone.sh" >> /etc/crontabs/root crontab -l diff --git a/rclone/rootfs/run_rclone.sh b/rclone/rootfs/run_rclone.sh new file mode 100755 index 0000000..8a12ad5 --- /dev/null +++ b/rclone/rootfs/run_rclone.sh @@ -0,0 +1,18 @@ +#! /usr/bin/with-contenv bashio + +bashio::log.info "Running rclone..." + +SYNC_COMMAND=$(bashio::config 'sync_command') +DESTINATION=$(bashio::config 'destination') + +USERNAME=$(bashio::config 'credentials.username') +PASSWORD=$(bashio::config 'credentials.password') + +set +x + +FILTER='{"IncludeRule": ["*.tar"]}' +if bashio::config.true 'protected_only'; then + FILTER="{\"IncludeRule\": $(find /backup -name "*.tar" -exec tar -xOf "{}" ./backup.json \;| jq -sc 'map(select(.protected) | "/backup/\(.slug).tar")')}" +fi + +rclone rc --user "$USERNAME" --pass "$PASSWORD" "sync/$SYNC_COMMAND" srcFs=/backup "dstFs=$DESTINATION" _async=true _filter="$FILTER"