mirror of
https://git.lapiole.org/dani/ansible-roles.git
synced 2025-10-07 06:54:55 +02:00
Update to 2021-12-01 19:13
This commit is contained in:
33
roles/mailman/templates/pre-backup.sh.j2
Normal file
33
roles/mailman/templates/pre-backup.sh.j2
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
{% for db in mailman_db_name.keys() | list %}
|
||||
{% if mailman_db_engine == 'postgres' %}
|
||||
{% if mailman_db_server not in ['localhost', '127.0.0.1'] %}
|
||||
PGPASSWORD={{ mailman_db_pass | quote }} \
|
||||
/usr/pgsql-14/bin/pg_dump \
|
||||
--clean \
|
||||
--create \
|
||||
--username={{ mailman_db_user | quote }} \
|
||||
--host={{ mailman_db_server | quote }} \
|
||||
--port={{ mailman_db_port }} \
|
||||
{{ mailman_db_name[db] }} | \
|
||||
zstd -c > {{ mailman_root_dir }}/backup/{{ mailman_db_name[db] }}.sql.zst
|
||||
{% else %}
|
||||
su - postgres -c "/usr/pgsql-14/bin/pg_dump --clear {{ mailman_db_name[db] }}" | \
|
||||
{% endif %}
|
||||
zstd -c > {{ mailman_root_dir }}/backup/{{ mailman_db_name[db] }}.sql.zst
|
||||
{% else %}
|
||||
/usr/bin/mysqldump \
|
||||
{% if mailman_db_server not in ['localhost', '127.0.0.1'] %}
|
||||
--user={{ mailman_db_user | quote }} \
|
||||
--password={{ mailman_db_pass | quote }} \
|
||||
--host={{ mailman_db_server | quote }} \
|
||||
--port={{ mailman_db_port }} \
|
||||
{% endif %}
|
||||
--quick --single-transaction \
|
||||
--add-drop-table {{ mailman_db_name[db] }} | \
|
||||
zstd -c > {{ mailman_root_dir }}/backup/{{ mailman_db_name[db] }}.sql.zst
|
||||
{% endif %}
|
||||
{% endfor %}
|
Reference in New Issue
Block a user