add todoist backup job and role #194
8 changed files with 94 additions and 0 deletions
BIN
keepass_db.kdbx
BIN
keepass_db.kdbx
Binary file not shown.
|
@ -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"
|
||||||
|
|
5
roles/mgrote_todoist_backup/handlers/main.yml
Normal file
5
roles/mgrote_todoist_backup/handlers/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
- name: systemctl daemon-reload
|
||||||
|
become: true
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
daemon_reload: true
|
51
roles/mgrote_todoist_backup/tasks/main.yml
Normal file
51
roles/mgrote_todoist_backup/tasks/main.yml
Normal 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
|
|
@ -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"
|
|
@ -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
|
|
@ -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
|
|
@ -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 }}'
|
Loading…
Reference in a new issue