ansible-roles/roles/unmaintained/mayan_edms/templates/pre_backup.sh.j2
2021-12-01 19:13:34 +01:00

30 lines
1.1 KiB
Django/Jinja

#!/bin/sh
set -eo pipefail
{% if mayan_db_engine == 'mysql' %}
/usr/bin/mysqldump --user={{ mayan_db_user | quote }} \
--password={{ mayan_db_pass | quote }} \
--host={{ mayan_db_server | quote }} \
--quick --single-transaction \
--add-drop-table {{ mayan_db_name | quote }} | zstd -c > {{ mayan_root_dir }}/backup/{{ mayan_db_name }}.sql.zst
{% else %}
PGPASSWORD={{ mayan_db_pass | quote }} /usr/pgsql-14/bin/pg_dump \
--clean \
--create \
--username={{ mayan_db_user | quote }} \
--host={{ mayan_db_server | quote }} \
{{ mayan_db_name | quote }} | \
zstd -c > "{{ mayan_root_dir }}/backup/{{ mayan_db_name }}.sql.zst"
{% endif %}
# Use FUSE to export indexes as a file tree
set -o allexport
. /opt/mayan-edms/config/.env
set +o allexport
{% for index in mayan_index_as_fuse %}
mkdir -p {{ mayan_root_dir }}/fuse/{{ index }}
{{ mayan_root_dir }}/venv/bin/python {{ mayan_root_dir }}/venv/bin/mayan-edms.py mountindex --background {{ index }} {{ mayan_root_dir }}/fuse/{{ index }}
{% endfor %}