From a291a09cce8b281a1aa0074257ea2d5b32f3de00 Mon Sep 17 00:00:00 2001 From: Usman Iqbal Date: Wed, 23 Aug 2023 20:54:30 +0100 Subject: [PATCH] Add Azure Blob Storage support, based on restic documentation --- README.md | 2 +- tasks/configure.yml | 4 ++++ templates/restic_access_Linux.j2 | 12 ++++++++++++ templates/restic_script_Linux.j2 | 12 ++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4dc5910..317c1b6 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ Available variables: | Name | Required | Description | | ----------------------- |:--------:| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `location` | yes | The location of the Backend. Currently, [Local](https://restic.readthedocs.io/en/stable/030_preparing_a_new_repo.html#local), [SFTP](https://restic.readthedocs.io/en/stable/030_preparing_a_new_repo.html#sftp), [S3](https://restic.readthedocs.io/en/stable/030_preparing_a_new_repo.html#amazon-s3) and [B2](https://restic.readthedocs.io/en/stable/030_preparing_a_new_repo.html#backblaze-b2) are supported | +| `location` | yes | The location of the Backend. Currently, [Local](https://restic.readthedocs.io/en/stable/030_preparing_a_new_repo.html#local), [SFTP](https://restic.readthedocs.io/en/stable/030_preparing_a_new_repo.html#sftp), [S3](https://restic.readthedocs.io/en/stable/030_preparing_a_new_repo.html#amazon-s3), [Azure Blob](https://restic.readthedocs.io/en/stable/030_preparing_a_new_repo.html#microsoft-azure-blob-storage) and [B2](https://restic.readthedocs.io/en/stable/030_preparing_a_new_repo.html#backblaze-b2) are supported | | `password` | yes | The password used to secure this repository | | `init` | no | Describes if the repository should be initialized or not. Use `false` if you are backuping to an already existing repo. | diff --git a/tasks/configure.yml b/tasks/configure.yml index 2d4aae0..87235af 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -7,6 +7,10 @@ AWS_ACCESS_KEY_ID: '{{ item.value.aws_access_key | default("") }}' AWS_SECRET_ACCESS_KEY: '{{ item.value.aws_secret_access_key | default("") }}' AWS_DEFAULT_REGION: '{{ item.value.aws_default_region | default("") }}' + AZURE_ACCOUNT_NAME: '{{ item.value.azure_account_name | default("") }}' + AZURE_ACCOUNT_KEY: '{{ item.value.azure_account_key | default("") }}' + AZURE_ACCOUNT_SAS: '{{ item.value.azure_account_sas | default("") }}' + AZURE_ENDPOINT_SUFFIX: '{{ item.value.azure_endpoint_suffix | default("") }}' B2_ACCOUNT_ID: '{{ item.value.b2_account_id | default("") }}' B2_ACCOUNT_KEY: '{{ item.value.b2_account_key | default("") }}' no_log: "{{ restic_no_log }}" diff --git a/templates/restic_access_Linux.j2 b/templates/restic_access_Linux.j2 index edcaf8e..6ac0875 100644 --- a/templates/restic_access_Linux.j2 +++ b/templates/restic_access_Linux.j2 @@ -14,6 +14,18 @@ export AWS_SECRET_ACCESS_KEY='{{ restic_repos[item.repo].aws_secret_access_key | {% if restic_repos[item.repo].aws_default_region is defined %} export AWS_DEFAULT_REGION={{ restic_repos[item.repo].aws_default_region }} {% endif %} +{% if restic_repos[item.repo].azure_account_name is defined %} +export AZURE_ACCOUNT_NAME={{ restic_repos[item.repo].azure_account_name }} +{% endif %} +{% if restic_repos[item.repo].azure_account_key is defined %} +export AZURE_ACCOUNT_KEY={{ restic_repos[item.repo].azure_account_key }} +{% endif %} +{% if restic_repos[item.repo].azure_account_sas is defined %} +export AZURE_ACCOUNT_SAS={{ restic_repos[item.repo].azure_account_sas }} +{% endif %} +{% if restic_repos[item.repo].azure_endpoint_suffix is defined %} +export AZURE_ENDPOINT_SUFFIX={{ restic_repos[item.repo].azure_endpoint_suffix }} +{% endif %} {% if restic_repos[item.repo].b2_account_id is defined %} export B2_ACCOUNT_ID={{ restic_repos[item.repo].b2_account_id }} {% endif %} diff --git a/templates/restic_script_Linux.j2 b/templates/restic_script_Linux.j2 index 81c4dfa..03d351e 100644 --- a/templates/restic_script_Linux.j2 +++ b/templates/restic_script_Linux.j2 @@ -57,6 +57,18 @@ export AWS_SECRET_ACCESS_KEY='{{ restic_repos[item.repo].aws_secret_access_key | {% if restic_repos[item.repo].aws_default_region is defined %} export AWS_DEFAULT_REGION={{ restic_repos[item.repo].aws_default_region }} {% endif %} +{% if restic_repos[item.repo].azure_account_name is defined %} +export AZURE_ACCOUNT_NAME={{ restic_repos[item.repo].azure_account_name }} +{% endif %} +{% if restic_repos[item.repo].azure_account_key is defined %} +export AZURE_ACCOUNT_KEY={{ restic_repos[item.repo].azure_account_key }} +{% endif %} +{% if restic_repos[item.repo].azure_account_sas is defined %} +export AZURE_ACCOUNT_SAS={{ restic_repos[item.repo].azure_account_sas }} +{% endif %} +{% if restic_repos[item.repo].azure_endpoint_suffix is defined %} +export AZURE_ENDPOINT_SUFFIX={{ restic_repos[item.repo].azure_endpoint_suffix }} +{% endif %} {% if restic_repos[item.repo].b2_account_id is defined %} export B2_ACCOUNT_ID={{ restic_repos[item.repo].b2_account_id }} {% endif %}