Add Etebase backup tasks.
This commit is contained in:
parent
6a4dd7cd2b
commit
81cd44918e
4 changed files with 73 additions and 33 deletions
1
env.yml
1
env.yml
|
@ -50,6 +50,7 @@ projects:
|
||||||
|
|
||||||
|
|
||||||
projects_to_backup:
|
projects_to_backup:
|
||||||
|
- etebase
|
||||||
- synapse
|
- synapse
|
||||||
- vaultwarden
|
- vaultwarden
|
||||||
|
|
||||||
|
|
30
roles/etebase/tasks/backup.yml
Normal file
30
roles/etebase/tasks/backup.yml
Normal 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 }}"
|
|
@ -1,34 +1,9 @@
|
||||||
- name: "Create {{ etebase_project_dir }} project directory"
|
- name: Include backup tasks
|
||||||
file:
|
include_tasks:
|
||||||
path: "{{ etebase_project_dir }}"
|
file: backup.yml
|
||||||
state: directory
|
when: run_backup | default(false) | bool
|
||||||
|
|
||||||
- name: Template docker-compose.yaml to project directory
|
- name: Include update tasks
|
||||||
template:
|
include_tasks:
|
||||||
src: docker-compose.yaml
|
file: update.yml
|
||||||
dest: "{{ etebase_project_dir }}/docker-compose.yaml"
|
when: run_update | default(false) | bool
|
||||||
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 }}"
|
|
||||||
|
|
34
roles/etebase/tasks/update.yml
Normal file
34
roles/etebase/tasks/update.yml
Normal 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 }}"
|
Loading…
Reference in a new issue