2021-06-14 21:48:31 +00:00
|
|
|
#! /usr/bin/with-contenv bashio
|
|
|
|
|
|
|
|
bashio::log.info "Configuring rclone..."
|
|
|
|
|
2021-06-14 21:48:40 +00:00
|
|
|
bashio::config.require.username 'credentials.username'
|
|
|
|
bashio::config.require.password 'credentials.password'
|
|
|
|
|
|
|
|
bashio::config.suggest.true 'tls.ssl'
|
|
|
|
bashio::config.require.ssl 'tls' 'tls.certfile' 'tls.keyfile'
|
|
|
|
|
2021-11-29 18:39:52 +00:00
|
|
|
SYNC_COMMAND=$(bashio::config 'sync_command')
|
|
|
|
DESTINATION=$(bashio::config 'destination')
|
2021-06-14 21:48:31 +00:00
|
|
|
|
2021-11-29 18:39:52 +00:00
|
|
|
USERNAME=$(bashio::config 'credentials.username')
|
|
|
|
PASSWORD=$(bashio::config 'credentials.password')
|
2023-11-07 17:16:27 +00:00
|
|
|
|
2023-11-07 16:53:08 +00:00
|
|
|
FILTER='{"IncludeRule": ["*.tar"]}'
|
2023-11-07 17:16:27 +00:00
|
|
|
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
|
2021-06-14 21:48:31 +00:00
|
|
|
|
2023-11-07 16:44:29 +00:00
|
|
|
command="rclone rc --user \"$USERNAME\" --pass \"$PASSWORD\" sync/$SYNC_COMMAND srcFs=/backup dstFs=$DESTINATION _async=true _filter='$FILTER'"
|
2021-06-14 21:48:31 +00:00
|
|
|
|
2021-11-29 18:39:52 +00:00
|
|
|
echo "$(bashio::config 'cron') $command" >> /etc/crontabs/root
|
2021-06-14 21:48:31 +00:00
|
|
|
crontab -l
|