Compare commits
1 Commits
99a8c19aa3
...
0aba4024de
Author | SHA1 | Date | |
---|---|---|---|
0aba4024de |
@ -20,8 +20,8 @@ restic_policy_backup_frequency: hourly
|
||||
|
||||
restic_base_environment:
|
||||
RESTIC_REPOSITORY: "{{ restic_repo_url }}"
|
||||
RESTIC_PASSWORD: "{{ restic_password }}"
|
||||
RESTIC_JOBNAME: "{{ restic_job_name | default('unknown') }}"
|
||||
RESTIC_PASSWORD: "{{ restic_repo_password }}"
|
||||
RESTIC_JOBNAME: "{{ restic_job_name }}"
|
||||
RESTIC_FORGET_KEEP_WITHIN: "{{ restic_policy_keep_all_within }}"
|
||||
RESTIC_FORGET_KEEP_HOURLY: "{{ restic_policy_keep_hourly }}"
|
||||
RESTIC_FORGET_KEEP_DAILY: "{{ restic_policy_keep_daily }}"
|
||||
|
@ -13,3 +13,4 @@ restic_job_directory: "/etc/restic"
|
||||
|
||||
restic_package_name: restic
|
||||
restic_script_generate_snapshot_metrics: "/opt/restic-generate-snapshot-metrics.sh"
|
||||
restic_start_job_on_unit_change: true
|
||||
|
@ -1,7 +1,16 @@
|
||||
---
|
||||
restic_systemd_job_name: ~
|
||||
restic_systemd_job_description: "Restic backup job for {{ restic_job_name }}"
|
||||
restic_systemd_job_description: "Restic backup service"
|
||||
restic_systemd_unit_naming_scheme: "restic-{{ restic_job_name }}"
|
||||
restic_systemd_timer_naming_scheme: >-2
|
||||
{{ restic_systemd_unit_naming_scheme }}.timer
|
||||
restic_systemd_timer_state_map:
|
||||
present: "started"
|
||||
absent: "stopped"
|
||||
masked: "started"
|
||||
restic_systemd_timer_state: >-2
|
||||
{{ restic_systemd_timer_state_map[restic_job_state] }}
|
||||
|
||||
restic_systemd_syslog_identifier: "restic@%i"
|
||||
restic_systemd_working_directory: /tmp
|
||||
restic_systemd_install_wanted_by: "basic.target"
|
||||
restic_systemd_install_default_instance: "default"
|
||||
|
@ -6,7 +6,7 @@ echo $RESTIC_JSON | jq -r '.[]
|
||||
| {
|
||||
"hostname": .hostname,
|
||||
"username": .username,
|
||||
"short_id": .short_id,
|
||||
"short_id": .short_id,
|
||||
"time": ((((.time | split(".")[0]) + "Z") | fromdate) - (3600 * (.time | split("+")[1] | split(":")[0] | tonumber + 1))),
|
||||
"paths": .paths[]
|
||||
} | "restic_snapshots{hostname=\"\(.hostname)\",username=\"\(.username)\",short_id=\"\(.short_id)\",paths=\"\(.paths)\"} \(.time)"'
|
||||
|
@ -1,13 +1,12 @@
|
||||
---
|
||||
|
||||
- name: Ensure system daemon is reloaded
|
||||
listen: reload-systemd
|
||||
systemd:
|
||||
ansible.builtin.systemd:
|
||||
daemon_reload: true
|
||||
|
||||
- name: Ensure systemd service for '{{ restic_job_name }}' is started immediately
|
||||
listen: trigger-restic
|
||||
systemd:
|
||||
name: "{{ restic_systemd_unit_naming_scheme }}.service"
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ restic_systemd_timer_naming_scheme }}"
|
||||
state: started
|
||||
when: restic_start_job_on_unit_change
|
||||
when: (not ansible_check_mode) and restic_start_job_on_unit_change
|
||||
|
@ -1,12 +1,13 @@
|
||||
---
|
||||
- name: Ensure systemd timer file for '{{ restic_job_name }}' is {{ restic_state }}'
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
dest: "/etc/systemd/system/{{ restic_systemd_unit_naming_scheme }}.timer"
|
||||
src: restic.timer.j2
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0640"
|
||||
when: restic_state == 'present'
|
||||
register: restic_systemd_timer_info
|
||||
notify:
|
||||
- reload-systemd
|
||||
|
||||
@ -27,5 +28,3 @@
|
||||
|
||||
- name: Flush handlers to ensure systemd knows about '{{ restic_job_name }}'
|
||||
meta: flush_handlers
|
||||
|
||||
|
||||
|
@ -21,10 +21,19 @@
|
||||
|
||||
- name: Ensure systemd timer for '{{ restic_job_name }}' is activated
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ restic_systemd_unit_naming_scheme }}.timer"
|
||||
name: "{{ restic_systemd_timer_naming_scheme }}"
|
||||
enabled: true
|
||||
when:
|
||||
- restic_systemd_timer_info.changed
|
||||
- not restic_systemd_timer_info.failed
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Ensure systemd timer for '{{ restic_job_name }}' is {{ restic_job_state }}
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ restic_systemd_unit_naming_scheme }}.timer"
|
||||
state: started # TODO: mask a timer?
|
||||
name: "{{ restic_systemd_timer_naming_scheme }}"
|
||||
state: "{{ restic_job_state }}"
|
||||
masked: "{{ (restic_job_state == 'masked') | ternary('true', omit) }}"
|
||||
when:
|
||||
- restic_systemd_timer_info.changed
|
||||
- not restic_systemd_timer_info.failed
|
||||
- not ansible_check_mode
|
||||
|
Loading…
x
Reference in New Issue
Block a user