mirror of
https://git.lapiole.org/dani/ansible-roles.git
synced 2025-07-27 00:05:44 +02:00
Update to 2022-04-29 11:00
This commit is contained in:
30
roles/squash_tm/templates/pre-backup.j2
Normal file
30
roles/squash_tm/templates/pre-backup.j2
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
{% if squashtm_db_engine == 'postgres' %}
|
||||
{% if squashtm_db_server not in ['localhost', '127.0.0.1'] %}
|
||||
PGPASSWORD={{ squashtm_db_pass | quote }} \
|
||||
/usr/pgsql-14/bin/pg_dump \
|
||||
--clean \
|
||||
--create \
|
||||
--username={{ squashtm_db_user | quote }} \
|
||||
--host={{ squashtm_db_server | quote }} \
|
||||
--port={{ squashtm_db_port }} \
|
||||
{{ squashtm_db_name }} | \
|
||||
{% else %}
|
||||
su - postgres -c "/usr/pgsql-14/bin/pg_dump --clear {{ squashtm_db_name }}" | \
|
||||
{% endif %}
|
||||
zstd -c > {{ squashtm_root_dir }}/backup/{{ squashtm_db_name }}.sql.zst
|
||||
{% else %}
|
||||
/usr/bin/mysqldump \
|
||||
{% if squashtm_db_server not in ['localhost', '127.0.0.1'] %}
|
||||
--user={{ squashtm_db_user | quote }} \
|
||||
--password={{ squashtm_db_pass | quote }} \
|
||||
--host={{ squashtm_db_server | quote }} \
|
||||
--port={{ squashtm_db_port }} \
|
||||
{% endif %}
|
||||
--quick --single-transaction \
|
||||
--add-drop-table {{ squashtm_db_name }} | \
|
||||
zstd -c > {{ squashtm_root_dir }}/backup/{{ squashtm_db_name }}.sql.zst
|
||||
{% endif %}
|
Reference in New Issue
Block a user