add todoist backup job and role #194

Merged
mg merged 22 commits from todositb into master 2024-09-27 18:50:18 +02:00
8 changed files with 94 additions and 0 deletions

Binary file not shown.

View file

@ -10,5 +10,7 @@
tags: "smb" tags: "smb"
- role: mgrote_youtubedl - role: mgrote_youtubedl
tags: "youtubedl" tags: "youtubedl"
- role: mgrote_todoist_backup
tags: "todoist"
- role: mgrote_disable_oom_killer - role: mgrote_disable_oom_killer
tags: "oom" tags: "oom"

View file

@ -0,0 +1,5 @@
---
- name: systemctl daemon-reload
become: true
ansible.builtin.systemd:
daemon_reload: true

View file

@ -0,0 +1,51 @@
---
- name: 'Clone "full-offline-backup-for-todoist"'
become: true
ansible.builtin.git:
repo: 'https://github.com/joanbm/full-offline-backup-for-todoist'
dest: /shares_backup/full-offline-backup-for-todoist
- name: Ensure script is present
become: true
ansible.builtin.template:
src: "todoist_backup.sh.j2"
dest: "/usr/bin/todoist_backup.sh"
owner: root
group: root
mode: "0754"
- name: Ensure services are present
become: true
ansible.builtin.template:
src: "{{ item }}.j2"
dest: "/etc/systemd/system/{{ item }}"
owner: root
group: root
mode: "0644"
notify:
- systemctl daemon-reload
loop:
- todoist_backup.service
- todoist_backup.timer
- todoist_backup_mail.service
- name: Ensure timer unit is enabled
become: true
ansible.builtin.systemd:
name: todoist_backup.timer
enabled: true
masked: false
state: started
notify:
- systemctl daemon-reload
- name: Ensure service units are enabled
become: true
ansible.builtin.systemd:
name: "{{ item }}"
masked: false
enabled: true
loop:
- todoist_backup.service
- todoist_backup.timer
- todoist_backup_mail.service

View file

@ -0,0 +1,12 @@
{{ file_header | default () }}
[Unit]
Description=Create Todoist backups.
OnFailure=todoist_backup_mail.service
[Service]
Type=simple
Restart=on-failure
RestartSec=10min
ExecStart="/usr/bin/todoist_backup.sh"

View file

@ -0,0 +1,7 @@
#!/bin/bash
export TODOIST_TOKEN={{ lookup('viczem.keepass.keepass', 'todoist_backup_token', 'password') }}
cd /shares_backup/full-offline-backup-for-todoist || exit
python3 -m full_offline_backup_for_todoist --verbose download --with-attachments

View file

@ -0,0 +1,9 @@
{{ file_header | default () }}
[Unit]
Description=Timer for todoist_backup.
[Timer]
OnCalendar=daily
[Install]
WantedBy=timers.target multi-user.target zfs.target

View file

@ -0,0 +1,8 @@
{{ file_header | default () }}
[Unit]
Description=Send a Mail in case of an error in todoist_backup.service.
[Service]
Type=oneshot
ExecStart=/bin/bash -c '/bin/systemctl status todoist_backup.service | mail -aFROM:todoist_backup@mgrote.net -s "[ERROR] todoist_backup" {{ my_mail }}'