This commit is contained in:
2024-04-03 11:30:02 +02:00
parent a97d1531aa
commit dac7cf1be0
3 changed files with 47 additions and 2 deletions

View File

@@ -16,4 +16,26 @@ RUN apk add -v --update --no-cache \
aws-cli aws-cli
#RUN pip3 install --upgrade awscli #RUN pip3 install --upgrade awscli
CMD [ "/run.sh" ] CMD [ "/run.sh" ]
# Build arugments
ARG BUILD_DATE
ARG BUILD_REF
ARG BUILD_VERSION
# Labels
LABEL \
io.hass.name="bitlab S3 backup" \
io.hass.description="Automatically create and transfer HA backups" \
io.hass.arch="${BUILD_ARCH}" \
io.hass.type="addon" \
io.hass.version=${BUILD_VERSION} \
maintainer="Alain Stucki <as@bitlab.ch" \
org.label-schema.description="Automatically create and transfer HA backups" \
org.label-schema.build-date=${BUILD_DATE} \
org.label-schema.name="bitlab S3 Backup" \
org.label-schema.schema-version="1.0" \
org.label-schema.usage="https://git.bitlab.ch/bitlab/ha-addon/-/raw/main/amazon-s3-backup/DOCS.md" \
org.label-schema.vcs-ref=${BUILD_REF} \
org.label-schema.vcs-url="https://git.bitlab.ch/bitlab/ha-addon.git" \
org.label-schema.vendor="bitlab Home Assistant Addons"

View File

@@ -1,6 +1,6 @@
{ {
"name": "bitlab S3 Backup", "name": "bitlab S3 Backup",
"version": "1.0.5", "version": "1.0.6",
"slug": "bitlab-s3-backup", "slug": "bitlab-s3-backup",
"description": "Sync Backups to bitlab S3 storage", "description": "Sync Backups to bitlab S3 storage",
"url": "https://git.bitlab.ch/bitlab/ha-addon", "url": "https://git.bitlab.ch/bitlab/ha-addon",

View File

@@ -4,8 +4,30 @@
# ============================================================================== # ==============================================================================
#bashio::log.level "info" #bashio::log.level "info"
# call Home Assistant to create a local backup
# function fails in case local backup is not created
function create-local-backup {
local -r base_folders="addons/local homeassistant media share ssl"
local data="{\"name\":\"${BACKUP_NAME}\"}"
local bak_type="non-encrypted"
bashio::log.info "Creating ${bak_type} full backup: \"${BACKUP_NAME}\""
if ! SLUG=$(bashio::api.supervisor POST /backups/new/full "${data}" .slug); then
bashio::log.fatal "Error creating ${bak_type} full backup!"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::log.info "Backup created: ${SLUG}"
return "${__BASHIO_EXIT_OK}"
}
bashio::log.info "Starting S3 Backup..." bashio::log.info "Starting S3 Backup..."
create-local-backup || die "Local backup process failed! See log for details."
custom_endpoint="$(bashio::config 'custom_endpoint')" custom_endpoint="$(bashio::config 'custom_endpoint')"
bucket_name="$(bashio::config 'bucket_name')" bucket_name="$(bashio::config 'bucket_name')"
bucket_region="$(bashio::config 'bucket_region' 'minio')" bucket_region="$(bashio::config 'bucket_region' 'minio')"
@@ -20,6 +42,7 @@ export AWS_REGION="$bucket_region"
bashio::log.debug "Using AWS CLI version: '$(aws --version)'" 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'" bashio::log.debug "Command: 'aws s3 sync $monitor_path s3://$bucket_name/ --no-progress --region $bucket_region'"
bashio::log.debug "SLUG: $SLUG"
aws s3 sync \ aws s3 sync \
$monitor_path \ $monitor_path \