Use s3 url

This commit is contained in:
Kuba Orlik 2026-06-04 00:02:45 +02:00
parent 15f3ba88f2
commit fcf256a933
2 changed files with 4 additions and 2 deletions

View File

@ -1,13 +1,13 @@
- set_fact:
endpoint_without_bucket: "{{ cloudflare_r2_endpoint | urlsplit('scheme') ~ '://' ~ cloudflare_r2_endpoint | urlsplit('netloc') }}"
endpoint_path: "{{ cloudflare_r2_endpoint | urlsplit('path') }}"
restic_repository_name: "rclone:cloudflare-r2:backup-{{inventory_hostname}}"
bucket_name: >-
{{
(cloudflare_r2_endpoint | urlsplit('path') | default('', true) | regex_replace('^/', ''))
if (cloudflare_r2_endpoint | urlsplit('path') | default('') | length > 1)
else (backup_bucket_prefix ~ '-' ~ inventory_hostname)
}}
restic_repository: "s3:{{ endpoint_without_bucket }}/{{ bucket_name }}"
- name: create the /backup-dirs file # this also runs on main in case someone doesn't run the backup.yml
file:
@ -84,7 +84,7 @@
until: "command_result.rc==0 or 'repository master key and config already initialized' in command_result.stderr"
failed_when: "command_result.rc!=0 and 'repository master key and config already initialized' not in command_result.stderr"
environment:
RESTIC_REPOSITORY: "{{ restic_repository_name }}"
RESTIC_REPOSITORY: "{{ restic_repository }}"
AWS_ACCESS_KEY_ID: "{{ cloudflare_r2_access_key }}"
AWS_SECRET_ACCESS_KEY: "{{ cloudflare_r2_secret_key }}"
tags:

View File

@ -1,3 +1,5 @@
export RESTIC_REPOSITORY="{{ restic_repository_name }}"
AWS_ACCESS_KEY_ID="{{ cloudflare_r2_access_key }}"
AWS_SECRET_ACCESS_KEY="{{ cloudflare_r2_secret_key }}"
export PWD_FILE=/backup-pwd
export RESTIC=/usr/bin/restic