This commit is contained in:
2024-04-03 10:20:37 +02:00
parent 0609ebbb18
commit aa1ae570ac
3 changed files with 4 additions and 50 deletions

View File

@@ -4,6 +4,7 @@ FROM ${BUILD_FROM}
ENV LANG C.UTF-8 ENV LANG C.UTF-8
COPY rootfs / COPY rootfs /
RUN chmod a+x /run.sh
# add aws-cli and deps # add aws-cli and deps
RUN apk add -v --update --no-cache \ RUN apk add -v --update --no-cache \
@@ -14,3 +15,5 @@ RUN apk add -v --update --no-cache \
jq \ jq \
aws-cli aws-cli
#RUN pip3 install --upgrade awscli #RUN pip3 install --upgrade awscli
CMD [ "/run.sh" ]

View File

@@ -1,5 +0,0 @@
#!/usr/bin/execlineb -S1
# ==============================================================================
# Home Assistant Community Add-on: Amazon S3 Backup
# ==============================================================================
s6-svscanctl -t /var/run/s6/services

View File

@@ -1,44 +0,0 @@
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Home Assistant Community Add-on: S3 Backup
# ==============================================================================
#bashio::log.level "info"
bashio::log.info "Starting S3 Backup..."
custom_endpoint="$(bashio::config 'custom_endpoint')"
bucket_name="$(bashio::config 'bucket_name')"
bucket_region="$(bashio::config 'bucket_region' 'minio')"
delete_local_backups="$(bashio::config 'delete_local_backups' 'true')"
local_backups_to_keep="$(bashio::config 'local_backups_to_keep' '3')"
monitor_path="/backup"
jq_filter=".backups|=sort_by(.date)|.backups|reverse|.[$local_backups_to_keep:]|.[].slug"
export AWS_ACCESS_KEY_ID="$(bashio::config 'aws_access_key')"
export AWS_SECRET_ACCESS_KEY="$(bashio::config 'aws_secret_access_key')"
export AWS_REGION="$bucket_region"
bashio::log.debug "Using AWS CLI version: '$(aws --version)'"
bashio::log.debug "Command: 'aws s3 sync $monitor_path s3://$bucket_name/ --no-progress --region $bucket_region'"
aws s3 sync \
$monitor_path \
--endpoint-url $custom_endpoint \
s3://$bucket_name/ \
--no-progress \
--region $bucket_region \
if bashio::var.true "${delete_local_backups}"; then
bashio::log.info "Will delete all the oldest local backups except the '${local_backups_to_keep}' newest ones."
backup_slugs="$(bashio::api.supervisor "GET" "/backups" "false" $jq_filter)"
bashio::log.debug "Backups to delete: '$backup_slugs'"
for s in $backup_slugs; do
bashio::log.info "Deleting Backup: '$s'"
bashio::api.supervisor "DELETE" "/backups/$s"
done
else
bashio::log.info "Will not delete any local backups since 'delete_local_backups' is set to 'false'"
fi
bashio::log.info "Finished S3 Backup."