Add Etebase backup tasks.

This commit is contained in:
Viyurz 2024-02-23 12:51:17 +01:00
parent 6a4dd7cd2b
commit 81cd44918e
Signed by: Viyurz
SSH key fingerprint: SHA256:IskOHTmhHSJIvAt04N6aaxd5SZCVWW1Guf9tEcxIMj8
4 changed files with 73 additions and 33 deletions

View file

@ -50,6 +50,7 @@ projects:
projects_to_backup:
- etebase
- synapse
- vaultwarden

View file

@ -0,0 +1,30 @@
- name:
become: true
block:
- name: Backup SQLite database
command:
cmd: |
sqlite3
"{{ volumes['etebase_datadir'] }}/db.sqlite3"
".backup {{ volumes['etebase_datadir'] }}/db-backup.sqlite3"
- name: Create borg backup
command:
cmd: |
borg create
--compression=lzma
"{{ borg_repodir }}::{{ role_name }}-{now:%Y-%m-%d_%H-%M-%S}"
{{ volumes['etebase_datadir'] }}/db-backup.sqlite3
{{ volumes['etebase_datadir'] }}/media
environment:
BORG_PASSCOMMAND: "cat {{ borg_passphrase_file }}"
- name: Prune borg repository
command:
cmd: |
borg prune
--glob-archives='{{ role_name }}-*'
{{ borg_prune_options }}
{{ borg_repodir }}
environment:
BORG_PASSCOMMAND: "cat {{ borg_passphrase_file }}"

View file

@ -1,34 +1,9 @@
- name: "Create {{ etebase_project_dir }} project directory"
file:
path: "{{ etebase_project_dir }}"
state: directory
- name: Include backup tasks
include_tasks:
file: backup.yml
when: run_backup | default(false) | bool
- name: Template docker-compose.yaml to project directory
template:
src: docker-compose.yaml
dest: "{{ etebase_project_dir }}/docker-compose.yaml"
owner: "{{ ansible_env['USER'] }}"
group: "{{ ansible_env['USER'] }}"
mode: '640'
- name: Template etebase-server.ini to project directory
template:
src: etebase-server.ini
dest: "{{ etebase_project_dir }}/etebase-server.ini"
owner: "{{ ansible_env['USER'] }}"
group: "{{ ansible_env['USER'] }}"
mode: '644'
- name: "Create directory {{ volumes['etebase_datadir'] }} with correct permissions"
file:
path: "{{ volumes['etebase_datadir'] }}"
state: directory
owner: "{{ users['etebase'] + uid_shift }}"
group: "{{ users['etebase'] + uid_shift }}"
mode: '770'
become: true
- name: Pull/Create/Restart project services
community.docker.docker_compose:
project_src: "{{ etebase_project_dir }}"
pull: "{{ docker_pull_images | bool }}"
- name: Include update tasks
include_tasks:
file: update.yml
when: run_update | default(false) | bool

View file

@ -0,0 +1,34 @@
- name: "Create {{ etebase_project_dir }} project directory"
file:
path: "{{ etebase_project_dir }}"
state: directory
- name: Template docker-compose.yaml to project directory
template:
src: docker-compose.yaml
dest: "{{ etebase_project_dir }}/docker-compose.yaml"
owner: "{{ ansible_env['USER'] }}"
group: "{{ ansible_env['USER'] }}"
mode: '640'
- name: Template etebase-server.ini to project directory
template:
src: etebase-server.ini
dest: "{{ etebase_project_dir }}/etebase-server.ini"
owner: "{{ ansible_env['USER'] }}"
group: "{{ ansible_env['USER'] }}"
mode: '644'
- name: "Create directory {{ volumes['etebase_datadir'] }} with correct permissions"
file:
path: "{{ volumes['etebase_datadir'] }}"
state: directory
owner: "{{ users['etebase'] + uid_shift }}"
group: "{{ users['etebase'] + uid_shift }}"
mode: '770'
become: true
- name: Pull/Create/Restart project services
community.docker.docker_compose:
project_src: "{{ etebase_project_dir }}"
pull: "{{ docker_pull_images | bool }}"