/
/
/
Ansible role that provisions my storage server.
1---
2
3- name: Create Restic backup server directory structure
4 file:
5 path: "{{ item }}"
6 state: directory
7 owner: "{{ storage_user }}"
8 group: "{{ storage_group }}"
9 mode: '2775'
10 loop:
11 - "{{ restic_backup_config_dir }}"
12 - "{{ restic_backup_data_dir }}"
13
14
15
16- name: Remove htpasswd file if present
17 ansible.builtin.file:
18 path: "{{ restic_backup_data_dir }}/.htpasswd"
19 state: absent
20 notify: restart restic-server
21
22- name: Deploy Restic server Docker Compose file
23 template:
24 src: restic-server-compose.yml.j2
25 dest: "{{ restic_backup_config_dir }}/docker-compose.yml"
26 owner: "{{ storage_user }}"
27 group: "{{ storage_group }}"
28 mode: '0664'
29 notify: restart restic-server
30
31- name: Check if Restic directory exists
32 stat:
33 path: "{{ restic_backup_config_dir }}"
34 register: restic_dir_stat
35 changed_when: false
36
37- name: Start Restic backup server
38 community.docker.docker_compose_v2:
39 project_src: "{{ restic_backup_config_dir }}"
40 state: present
41 register: restic_start_result
42 check_mode: no
43 when: restic_dir_stat.stat.exists
44
45
46- name: Display Restic backup server deployment summary
47 debug:
48 msg: |
49 Restic Backup Server Deployment:
50 - Status: {{ 'Started' if restic_start_result is changed else 'Already running' }}
51 - Server URL: http://{{ ansible_default_ipv4.address }}:{{ restic_backup_host_port }}/
52 - Data Directory: {{ restic_backup_data_dir }}
53 - Configuration: {{ restic_backup_config_dir }}
54 - Authentication: Disabled (no-auth, repo encryption via RESTIC_PASSWORD)
55
56 Client Setup:
57 1. Install restic on client machines
58 2. Export RESTIC_REPOSITORY=rest:http://{{ ansible_default_ipv4.address }}:{{ restic_backup_host_port }}/backup
59 3. Export RESTIC_PASSWORD=<repo encryption key>
60 4. Initialize repository: restic init
61 5. Create backup: restic backup /path/to/backup
62