From cf426fa33093af4eb4cef8580098e09018db28ea Mon Sep 17 00:00:00 2001 From: abrown38 Date: Thu, 5 Jun 2025 11:22:40 +0100 Subject: [PATCH] restic changes --- .../roles/win_fileserver/tasks/backups.yml | 23 ++++++++++++++----- .../win_fileserver/templates/profiles.yaml | 7 +++--- ansible/roles/win_fileserver/vars/main.yml | 1 + ansible/vars/common.yml | 3 +++ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/ansible/roles/win_fileserver/tasks/backups.yml b/ansible/roles/win_fileserver/tasks/backups.yml index 26d2798..d97f389 100644 --- a/ansible/roles/win_fileserver/tasks/backups.yml +++ b/ansible/roles/win_fileserver/tasks/backups.yml @@ -2,10 +2,6 @@ - name: Install scoop tags: install_scoop block: - #- name: download install script - # ansible.windows.win_powershell: - # script: | - # irm get.scoop.sh -outfile 'C:\eidf\install.ps1' - name: Run install script win_shell: | powershell Invoke-RestMethod -Uri https://get.scoop.sh -outfile 'C:\eidf\install.ps1' @@ -34,14 +30,29 @@ win_shell: scoop install resticprofile tags: install_resticprofile + - name: Ensure parent directory exists + ansible.windows.win_file: + path: "C:\\resticprofile" + state: directory + tags: copy_restickey + + - name: Copy restic key + ansible.windows.win_copy: + content: "{{ restic_password }}" + dest: "C:\\resticprofile\\restic.key" + force: false + tags: copy_restickey + - name: Copy resticprofile ansible.windows.win_template: src: "profiles.yaml" - dest: "C:\\resticprofile" + dest: "C:\\resticprofile\\" force: true tags: copy_resticprofile - name: Schedule resticprofile win_shell: resticprofile -n study_data schedule - tags: schedule_resticprofile + tags: + - schedule_resticprofile + - never when: inventory_hostname in groups['meta-name_fs01'] diff --git a/ansible/roles/win_fileserver/templates/profiles.yaml b/ansible/roles/win_fileserver/templates/profiles.yaml index 47766b6..855706b 100644 --- a/ansible/roles/win_fileserver/templates/profiles.yaml +++ b/ansible/roles/win_fileserver/templates/profiles.yaml @@ -10,13 +10,15 @@ profiles: default: repository: local:C:\eidf\restic-repo password-file: C:\resticprofile\restic.key + insecure-tls: true env: RESTIC_PATH: study_data: inherit: default - repository: local:C:\eidf\restic-repo + repository: rest:https://{{ restic_user }}:{{ restic_rest_password }}@{{ backup_server_ip }}:8000 + initialize: true backup: source: S:\ @@ -30,7 +32,6 @@ profiles: - S:\System Volume Information - S:\DfsrPrivate tag: - - study_data - "{{ os_project }}-{{ win_project }}" retention: @@ -39,5 +40,5 @@ profiles: keep-daily: 14 keep-weekly: 8 tag: - - study_data + - "{{ os_project }}-{{ win_project }}" prune: true diff --git a/ansible/roles/win_fileserver/vars/main.yml b/ansible/roles/win_fileserver/vars/main.yml index 82e010d..539f731 100644 --- a/ansible/roles/win_fileserver/vars/main.yml +++ b/ansible/roles/win_fileserver/vars/main.yml @@ -11,3 +11,4 @@ powershell_path: C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe import_script: scheduled_transfer_import.ps1 export_script: scheduled_transfer_export.ps1 scheduled_task_path: \Transfer +backup_server_ip: 10.24.2.42 diff --git a/ansible/vars/common.yml b/ansible/vars/common.yml index ebe1529..0fe1802 100644 --- a/ansible/vars/common.yml +++ b/ansible/vars/common.yml @@ -10,6 +10,9 @@ app_quantity: %APP_QUANTITY% gpu_quantity: %GPU_QUANTITY% project_zone: %PROJECT_ZONE% vm_initial_password: %VM_INITIAL_PASSWORD% +restic_password: %RESTIC_PASSWORD% +restic_rest_user: %RESTIC_REST_USER% +restic_rest_password: %RESTIC_REST_PASSWORD% ########## Do Not Edit ########## vm_image: 3f193ea7-321d-418b-a233-da64661b08b1