diff --git a/README.md b/README.md index 9f6f5a9..86e4608 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Home Assistant Addons: Thomas' repository +# Home Assistant Addons: rarosalion repository -Add-ons for Home Assistant written by Thomas Fritz. +Add-ons for Home Assistant written by rarosalion. To add this repository: 1. Go to your Home Assistant Frontend 2. Open **Supervisor** > **Add-On Store**, @@ -12,4 +12,4 @@ You should now see the add-ons of this repository in your Home Assistant Add-On ## Add-ons provided by this repository -- **[Amazon S3 Backup](/amazon-s3-backup)** - Sync your Home Assistant backups to Amazon S3 \ No newline at end of file +- **[Amazon S3 Backup](/amazon-s3-backup)** - Sync your Home Assistant backups to Amazon S3 (update of thomasfr's plugin) \ No newline at end of file diff --git a/amazon-s3-backup/CHANGELOG.md b/amazon-s3-backup/CHANGELOG.md index 0869c9e..157742b 100644 --- a/amazon-s3-backup/CHANGELOG.md +++ b/amazon-s3-backup/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.2.3 + +- Added `endpoint_url` option to allow the use of non-AWS S3-compatable object stores (e.g. minio) + ## 1.2.2 - Backup Script was running twice since it was still in services.d folder. Removed all unnecessary files. diff --git a/amazon-s3-backup/DOCS.md b/amazon-s3-backup/DOCS.md index 75bf1fd..dfa3ed9 100644 --- a/amazon-s3-backup/DOCS.md +++ b/amazon-s3-backup/DOCS.md @@ -12,7 +12,7 @@ Follow these steps to get the add-on installed on your system: ## How to use 1. Set the `aws_access_key`, `aws_secret_access_key`, and `bucket_name`. -2. Optionally / if necessary, change `bucket_region`, `storage_class`, and `delete_local_backups` and `local_backups_to_keep` configuration options. +2. Optionally / if necessary, change `bucket_region`, `storage_class`, `endpoint_url`, `delete_local_backups` and `local_backups_to_keep` configuration options. 3. Start the add-on to sync the `/backup/` directory to the configured `bucket_name` on Amazon S3. You can also automate this of course, see example below: ## Automation @@ -71,10 +71,16 @@ AWS IAM secret access key used to access the S3 bucket. Amazon S3 bucket used to store backups. ### Option: `bucket_region` (optional, Default: eu-central-1) -AWS region where the S3 bucket was created. See https://aws.amazon.com/about-aws/global-infrastructure/ for all available regions. +AWS region where the S3 bucket was created. See https://aws.amazon.com/about-aws/global-infrastructure/ for all available regions. If you set this to 'other', a custom bucket region (or no region) can be set in bucket_region_other + +### Option: `bucket_region_other` (optional, Default: empty) +If 'bucket_Region' is set to 'other', then a custom region value set here will be used instead. If this value is empty, no region will be requested. + +### Option: `endpoint_url` (optional, Defaault: empty) +If you wish to use a non-AWS S3-compatable server (e.g. minio), you can set the endpoint url (e.g. https://myminioserver.local:9000) here. Leave this value blank if you're using AWS. ### Option: `storage_class` (optional, Default: STANDARD) -Amazon S3 storage class to use for the synced objects, when uploading files to S3. One of STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE. For more information see https://aws.amazon.com/s3/storage-classes/. +Amazon S3 storage class to use for the synced objects, when uploading files to S3. One of STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE. For more information see https://aws.amazon.com/s3/storage-classes/. If you select 'None', no storage class will be specified (leaving the s3 provider to select the default option). ### Option: `delete_local_backups` (optional, Default: true) Should the addon remove oldest local backups after syncing to your Amazon S3 Bucket? You can configure how many local backups you want to keep with the Option `local_backups_to_keep`. Oldest Backups will get deleted first. diff --git a/amazon-s3-backup/config.json b/amazon-s3-backup/config.json index b360dfb..7cc015a 100755 --- a/amazon-s3-backup/config.json +++ b/amazon-s3-backup/config.json @@ -1,6 +1,6 @@ { "name": "Amazon S3 Backup", - "version": "1.2.2", + "version": "1.2.3", "slug": "amazon-s3-backup", "description": "Sync Backups to your Amazon S3 bucket", "url": "https://github.com/thomasfr/hass-addons/tree/main/amazon-s3-backup", @@ -22,6 +22,8 @@ "aws_secret_access_key": "", "bucket_name": "", "bucket_region": "eu-central-1", + "bucket_region_other": "", + "endpoint_url": "", "storage_class": "STANDARD", "delete_local_backups": true, "local_backups_to_keep": 3 @@ -30,8 +32,10 @@ "aws_access_key": "str", "aws_secret_access_key": "password", "bucket_name": "str", - "bucket_region": "list(us-east-1|us-east-2|us-west-1|us-west-2|af-south-1|ap-east-1|ap-south-2|ap-southeast-3|ap-southeast-4|ap-south-1|ap-northeast-3|ap-northeast-2|ap-southeast-1|ap-southeast-2|ap-northeast-1|ca-central-1|eu-central-1|eu-west-1|eu-west-2|eu-south-1|eu-west-3|eu-south-2|eu-north-1|eu-central-2|me-south-1|me-central-1|sa-east-1|us-gov-east-1|us-gov-west-1)", - "storage_class": "list(STANDARD|REDUCED_REDUNDANCY|STANDARD_IA|ONEZONE_IA|INTELLIGENT_TIERING|GLACIER|DEEP_ARCHIVE)", + "bucket_region": "list(us-east-1|us-east-2|us-west-1|us-west-2|af-south-1|ap-east-1|ap-south-2|ap-southeast-3|ap-southeast-4|ap-south-1|ap-northeast-3|ap-northeast-2|ap-southeast-1|ap-southeast-2|ap-northeast-1|ca-central-1|eu-central-1|eu-west-1|eu-west-2|eu-south-1|eu-west-3|eu-south-2|eu-north-1|eu-central-2|me-south-1|me-central-1|sa-east-1|us-gov-east-1|us-gov-west-1|other)", + "bucket_region_other": "str", + "endpoint_url": "str", + "storage_class": "list(None|STANDARD|REDUCED_REDUNDANCY|STANDARD_IA|ONEZONE_IA|INTELLIGENT_TIERING|GLACIER|DEEP_ARCHIVE)", "delete_local_backups": "bool", "local_backups_to_keep": "int" }, diff --git a/amazon-s3-backup/run.sh b/amazon-s3-backup/run.sh index c4027b7..af07066 100755 --- a/amazon-s3-backup/run.sh +++ b/amazon-s3-backup/run.sh @@ -9,6 +9,8 @@ bashio::log.info "Starting Amazon S3 Backup..." bucket_name="$(bashio::config 'bucket_name')" storage_class="$(bashio::config 'storage_class' 'STANDARD')" bucket_region="$(bashio::config 'bucket_region' 'eu-central-1')" +bucket_region_other="$(bashio::config 'bucket_region_other' '')" +endpoint_url="$(bashio::config 'endpoint_url' '')" delete_local_backups="$(bashio::config 'delete_local_backups' 'true')" local_backups_to_keep="$(bashio::config 'local_backups_to_keep' '3')" monitor_path="/backup" @@ -18,9 +20,19 @@ 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" +# Set optional flags +[[ -n "$endpoint_url" ]] && ENDPOINT="--endpoint-url $endpoint_url" +[[ "$storage_class" != "None" ]] && STORAGECLASS="--storage-class $storage_class" +if [ "$bucket_region" == "other" ]; then + [[ -n "$bucket_region_other" ]] && BUCKETREGION="--region $bucket_region_other" +else + BUCKETREGION="--region $bucket_region" +fi + 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 --storage-class $storage_class'" -aws s3 sync $monitor_path s3://"$bucket_name"/ --no-progress --region "$bucket_region" --storage-class "$storage_class" +COMMAND="aws ${ENDPOINT:=} s3 sync $monitor_path s3://$bucket_name/ --no-progress ${BUCKETREGION:=} ${STORAGECLASS:=}" +bashio::log.debug "Command: '$COMMAND'" +$COMMAND if bashio::var.true "${delete_local_backups}"; then bashio::log.info "Will delete local backups except the '${local_backups_to_keep}' newest ones." diff --git a/repository.json b/repository.json index 3224fa5..53c55ad 100755 --- a/repository.json +++ b/repository.json @@ -1,5 +1,5 @@ { - "name": "Thomas Fritz Home Assistant Addons", - "url": "https://github.com/thomasfr/hass-addons", - "maintainer": "Thomas Fritz " + "name": "rarosalion Home Assistant Addons", + "url": "https://github.com/rarosalion/hass-addons", + "maintainer": "rarosalion@github" } \ No newline at end of file