From 4760360df6697c1d529bb82296f4edf597a16fd8 Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Tue, 7 Nov 2023 09:16:27 -0800 Subject: [PATCH] Add protected_only option to filter out unencrypted files --- rclone/CHANGELOG.md | 1 + rclone/Dockerfile | 2 +- rclone/config.yml | 2 ++ rclone/rootfs/etc/cont-init.d/rclone.sh | 5 +++++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/rclone/CHANGELOG.md b/rclone/CHANGELOG.md index 6db7505..00a6e5a 100644 --- a/rclone/CHANGELOG.md +++ b/rclone/CHANGELOG.md @@ -2,6 +2,7 @@ ## next - Bump rclone version to v1.64.2 +- Add `protected_only` option to filter out unencrypted backups ## 1.5.5 diff --git a/rclone/Dockerfile b/rclone/Dockerfile index 35a300f..3d1818b 100755 --- a/rclone/Dockerfile +++ b/rclone/Dockerfile @@ -11,7 +11,7 @@ COPY install_rclone.sh / RUN /install_rclone.sh "${VERSION}" "${BUILD_ARCH}" # Add timegaps for pruning backups -RUN apk add --no-cache python3 py3-pip && \ +RUN apk add --no-cache python3 py3-pip jq && \ pip install --no-cache-dir timegaps==0.1.1 && \ apk del py3-pip diff --git a/rclone/config.yml b/rclone/config.yml index 4916a29..ac24dae 100755 --- a/rclone/config.yml +++ b/rclone/config.yml @@ -35,6 +35,7 @@ options: ssl: false certfile: fullchain.pem keyfile: privkey.pem + protected_only:: false schema: cron: str destination: str @@ -50,3 +51,4 @@ schema: ssl: bool certfile: str keyfile: str + protected_only: bool diff --git a/rclone/rootfs/etc/cont-init.d/rclone.sh b/rclone/rootfs/etc/cont-init.d/rclone.sh index 8928093..f610ac3 100755 --- a/rclone/rootfs/etc/cont-init.d/rclone.sh +++ b/rclone/rootfs/etc/cont-init.d/rclone.sh @@ -13,7 +13,12 @@ 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'"