From 308b068f2044311a83a64d5603c109c4ed9fca81 Mon Sep 17 00:00:00 2001 From: Luca Zorzi Date: Tue, 8 Sep 2020 10:17:46 +0200 Subject: [PATCH] Added support for Backblaze B2 (#18) authored-by: Luca Zorzi --- CHANGELOG.md | 1 + README.md | 4 +++- tasks/configure.yml | 2 ++ templates/restic_access_Linux.j2 | 6 ++++++ templates/restic_script_Linux.j2 | 6 ++++++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23de919..49ef5a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ and [human-readable changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased ### Added * Sanity check for restic binary +* Support for the Backblaze B2 backend ## [0.2.7] 2020-08-05 ### Added diff --git a/README.md b/README.md index 433cfbf..12725a7 100644 --- a/README.md +++ b/README.md @@ -87,12 +87,14 @@ 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) and [S3](https://restic.readthedocs.io/en/stable/030_preparing_a_new_repo.html#amazon-s3) 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) 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. | | `aws_access_key` | no | The access key for the S3 backend | | `aws_secret_access_key` | no | The secret access key for the S3 backend | | `aws_default_region` | no | The desired region for the S3 backend | +| `b2_account_id` | no | The account ID for Backblaze B2 backend | +| `b2_account_key` | no | The account key for Backblaze B2 backend | Example: ```yaml diff --git a/tasks/configure.yml b/tasks/configure.yml index 70d37e1..cc2d7da 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -10,6 +10,8 @@ | default("") }}' AWS_DEFAULT_REGION: '{{ item.value.aws_default_region | default("") }}' + B2_ACCOUNT_ID: '{{ item.value.b2_account_id | default("") }}' + B2_ACCOUNT_KEY: '{{ item.value.b2_account_key | default("") }}' no_log: true register: restic_init changed_when: "'created restic repository' in restic_init.stdout" diff --git a/templates/restic_access_Linux.j2 b/templates/restic_access_Linux.j2 index f9b62dd..edcaf8e 100644 --- a/templates/restic_access_Linux.j2 +++ b/templates/restic_access_Linux.j2 @@ -14,6 +14,12 @@ 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].b2_account_id is defined %} +export B2_ACCOUNT_ID={{ restic_repos[item.repo].b2_account_id }} +{% endif %} +{% if restic_repos[item.repo].b2_account_key is defined %} +export B2_ACCOUNT_KEY={{ restic_repos[item.repo].b2_account_key }} +{% endif %} BACKUP_NAME={{ item.name }} {% if item.src is defined %} BACKUP_SOURCE={{ item.src }} diff --git a/templates/restic_script_Linux.j2 b/templates/restic_script_Linux.j2 index a20cf6e..da2985e 100644 --- a/templates/restic_script_Linux.j2 +++ b/templates/restic_script_Linux.j2 @@ -15,6 +15,12 @@ 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].b2_account_id is defined %} +export B2_ACCOUNT_ID={{ restic_repos[item.repo].b2_account_id }} +{% endif %} +{% if restic_repos[item.repo].b2_account_key is defined %} +export B2_ACCOUNT_KEY={{ restic_repos[item.repo].b2_account_key }} +{% endif %} {% if item.src is defined %} BACKUP_SOURCE={{ item.src }} {% endif %}