diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f2228eb --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +*.md +icon.png +logo.svg + +tags diff --git a/DOCS.md b/DOCS.md new file mode 100755 index 0000000..83b4b0a --- /dev/null +++ b/DOCS.md @@ -0,0 +1,15 @@ +# rclone + +## Configuration + +|field|description| +|---|---| +|`cron`|Cron schedule to run the sync job| +|`destination`|The rclone destination in the form `:`| +|`sync_command`|Rclone command to execute (`sync`, `copy`, or `move`)| +|`credentials.username`|Username to view web UI| +|`credentials.password`|Password to view web UI| +|`tls.ssl`|Enable TLS. Recommended if not using ingress| +|`tls.certfile`|TLS cert file to use| +|`tls.keyfile`|TLS key file to use| + diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 0000000..3e8d7d4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +ARG BUILD_FROM=homeassistant/aarch64-base +FROM $BUILD_FROM + +ENV LANG C.UTF-8 + +ARG BUILD_ARCH=aarch64 +ARG VERSION=v1.55.1 + +COPY install_rclone.sh / +RUN /install_rclone.sh "${VERSION}" "${BUILD_ARCH}" + +ENV XDG_CONFIG_HOME=/data + +COPY rootfs / diff --git a/README.md b/README.md new file mode 100755 index 0000000..65349e2 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Rclone addon + +Sync backup snapshots to a different device using rclone + +Note: Drive password must be obscured using `rclone obscure mysecretpass` \ No newline at end of file diff --git a/config.yml b/config.yml new file mode 100755 index 0000000..bcba966 --- /dev/null +++ b/config.yml @@ -0,0 +1,44 @@ +--- +name: Rclone +version: '1.3' +slug: rclone +description: Clone snapshots to another devices +arch: + - armhf + - armv7 + - aarch64 + - amd64 +startup: application +boot: auto +ingress: true +ingress_port: 5572 +#webui: http://[HOST]:[PORT:3000] +ports: + 5572/tcp: null +ports_description: + 5572/tcp: Web configuration GUI (not required for ingress) +map: + - backup:ro + - ssl:ro +options: + cron: "0 * * * *" + destination: ":" + sync_command: sync + credentials: + username: homeassistant + password: homeassistant + tls: + ssl: false + certfile: fullchain.pem + keyfile: privkey.pem +schema: + cron: str + destination: str + sync_command: list(sync|copy|move) + credentials: + username: str + password: str + tls: + ssl: bool + certfile: str + keyfile: str diff --git a/icon.png b/icon.png new file mode 100755 index 0000000..ba2b858 Binary files /dev/null and b/icon.png differ diff --git a/install_rclone.sh b/install_rclone.sh new file mode 100755 index 0000000..07e110b --- /dev/null +++ b/install_rclone.sh @@ -0,0 +1,31 @@ +#! /bin/ash +set -ex + +VERSION="$1" +ARCH="$2" + +# Transform relevant archs +case $ARCH in +armhf) + ARCH=arm + ;; +armv7) + ARCH=arm-v7 + ;; +aarch64) + ARCH=arm64 + ;; +esac + +RCLONE_NAME=rclone-${VERSION}-linux-${ARCH} + +# Download +curl -o rclone.zip https://downloads.rclone.org/${VERSION}/${RCLONE_NAME}.zip + +# Install +unzip rclone.zip +mv ${RCLONE_NAME}/rclone /usr/local/bin/ + +# Clean up +rm rclone.zip +rm -fr ${RCLONE_NAME} diff --git a/logo.svg b/logo.svg new file mode 100755 index 0000000..a49fc74 --- /dev/null +++ b/logo.svg @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/rootfs/etc/cont-init.d/rclone.sh b/rootfs/etc/cont-init.d/rclone.sh new file mode 100755 index 0000000..37934e5 --- /dev/null +++ b/rootfs/etc/cont-init.d/rclone.sh @@ -0,0 +1,14 @@ +#! /usr/bin/with-contenv bashio + +bashio::log.info "Configuring rclone..." + +sync_command=$(bashio::config 'sync_command') +destination=$(bashio::config 'destination') + +username=$(bashio::config 'credentials.username') +password=$(bashio::config 'credentials.password') + +command="rclone rc --user \"$username\" --pass \"$password\" sync/$sync_command srcFs=/backup dstFs=$destination _async=true" + +echo "$(bashio::config 'cron') $command" > /etc/crontabs/root +crontab -l diff --git a/rootfs/etc/services.d/cron/finish b/rootfs/etc/services.d/cron/finish new file mode 100755 index 0000000..8a0b0d4 --- /dev/null +++ b/rootfs/etc/services.d/cron/finish @@ -0,0 +1,5 @@ +#!/usr/bin/execlineb -S0 +if { s6-test ${1} -ne 0 } +if { s6-test ${1} -ne 256 } + +s6-svscanctl -t /var/run/s6/services \ No newline at end of file diff --git a/rootfs/etc/services.d/cron/run b/rootfs/etc/services.d/cron/run new file mode 100755 index 0000000..3a010e8 --- /dev/null +++ b/rootfs/etc/services.d/cron/run @@ -0,0 +1,5 @@ +#! /usr/bin/with-contenv bashio + +bashio::log.info "Starting cron..." + +exec crond -f -l 8 diff --git a/rootfs/etc/services.d/web/finish b/rootfs/etc/services.d/web/finish new file mode 100755 index 0000000..8a0b0d4 --- /dev/null +++ b/rootfs/etc/services.d/web/finish @@ -0,0 +1,5 @@ +#!/usr/bin/execlineb -S0 +if { s6-test ${1} -ne 0 } +if { s6-test ${1} -ne 256 } + +s6-svscanctl -t /var/run/s6/services \ No newline at end of file diff --git a/rootfs/etc/services.d/web/run b/rootfs/etc/services.d/web/run new file mode 100755 index 0000000..b37b973 --- /dev/null +++ b/rootfs/etc/services.d/web/run @@ -0,0 +1,19 @@ +#! /usr/bin/with-contenv bashio + +bashio::log.info "Starting rclone web..." + +# TODO: Something with UN and PASS +# Maybe switch to --rc-no-auth and use proxy +username=$(bashio::config 'credentials.username') +password=$(bashio::config 'credentials.password') + +# TODO: Add cert paths here if ssl is true + +exec rclone rcd \ + --rc-web-gui \ + --rc-serve \ + --rc-addr :5572 \ + --rc-user "$username" \ + --rc-pass "$password" \ + --rc-web-gui-update \ + --rc-web-gui-no-open-browser