diff --git a/README.md b/README.md index 73d28cc..01c87be 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ +Sets up backups to Cloudflare R2 + + + + # Instalation In requirements.yml: @@ -8,3 +13,9 @@ roles: version: master name: setup-backups ``` + + + +# Setup + +Create a Cloudflare R2 account and create an admin token. diff --git a/tasks/main.yml b/tasks/main.yml index 99c73a6..87999b3 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -69,7 +69,7 @@ failed_when: "command_result.rc!=0 and 'repository master key and config already initialized' not in command_result.stderr" changed_when: "false" environment: - RESTIC_REPOSITORY: "s3:{{ cloudflare_r2_endpoint }}/icd-backup-{{ inventory_hostname }}" + RESTIC_REPOSITORY: "s3:{{ cloudflare_r2_endpoint }}/{{ backup_bucket_prefix }}-{{ inventory_hostname }}" AWS_ACCESS_KEY_ID: "{{ cloudflare_r2_access_key }}" AWS_SECRET_ACCESS_KEY: "{{ cloudflare_r2_secret_key }}" tags: diff --git a/templates/backup-vars.sh.j2 b/templates/backup-vars.sh.j2 index 2eebe4d..b825e9d 100644 --- a/templates/backup-vars.sh.j2 +++ b/templates/backup-vars.sh.j2 @@ -1,5 +1,5 @@ declare -a DIRS_TO_BACKUP=({% for item in all_backup_paths %}"{{ item }}"{% if not loop.last %} {% endif %}{% endfor %}) export DIRS_TO_BACKUP_STR=$(declare -p DIRS_TO_BACKUP) -export RESTIC_REPOSITORY="rclone:cloudflare-r2:icd-backup-{{ inventory_hostname }}" +export RESTIC_REPOSITORY="rclone:cloudflare-r2:{{ backup_bucket_prefix }}-{{ inventory_hostname }}" export PWD_FILE=/backup-pwd export RESTIC=/usr/bin/restic