mirror of
https://github.com/ViViDboarder/hassio-addon-rclone.git
synced 2024-11-01 02:46:35 +00:00
26 lines
873 B
Bash
Executable File
26 lines
873 B
Bash
Executable File
#! /usr/bin/with-contenv bashio
|
|
|
|
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
|
|
FILTER="{\"IncludeRule\": $(find /backup -name "*.tar" -exec tar -xOf "{}" ./backup.json \;| jq -sc 'map(select(.protected) | "\(.slug).tar")')}"
|
|
fi
|
|
|
|
bashio::log.info "Filter: $FILTER"
|
|
|
|
|
|
# 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"
|