hassio-addon-rclone/rclone/rootfs/run_rclone.sh

26 lines
873 B
Bash
Raw Normal View History

#! /usr/bin/with-contenv bashio
2023-12-07 17:46:36 +00:00
set +x
set -eo pipefail
bashio::log.info "Running rclone..."
SYNC_COMMAND=$(bashio::config 'sync_command')
DESTINATION=$(bashio::config 'destination')
FILTER='{"IncludeRule": ["*.tar"]}'
if bashio::config.true 'protected_only'; then
2023-12-07 17:46:36 +00:00
FILTER="{\"IncludeRule\": $(find /backup -name "*.tar" -exec tar -xOf "{}" ./backup.json \;| jq -sc 'map(select(.protected) | "\(.slug).tar")')}"
fi
2023-11-25 06:26:06 +00:00
bashio::log.info "Filter: $FILTER"
2023-11-25 06:20:04 +00:00
2023-12-07 17:12:19 +00:00
# Maybe add the username and password
if bashio::config.has_value 'credentials.username' && bashio::config.has_value 'credentials.password'; then
rclone_flags+=("--rc-user" "$(bashio::config 'credentials.username')")
rclone_flags+=("--rc-pass" "$(bashio::config 'credentials.password')")
fi
rclone rc "${rclone_flags[@]}" "sync/$SYNC_COMMAND" srcFs=/backup "dstFs=$DESTINATION" _async=true _filter="$FILTER"