mirror of
https://git.lapiole.org/dani/ansible-roles.git
synced 2025-04-12 00:03:17 +02:00
15 lines
849 B
Django/Jinja
15 lines
849 B
Django/Jinja
#!/bin/bash -e
|
|
|
|
cd /opt/wh/{{ item.0.name }}/apps/{{ item.1.name }}
|
|
# Remove old archives
|
|
find archives/ -type f -mtime +2 -exec rm -f "{}" \;
|
|
# Create the new daily archive, with a dump of the DB and the web, data and logs dir
|
|
TS=$(date +%Y-%m-%d_%Hh%M)
|
|
mysqldump --add-drop-table --single-transaction \
|
|
--host={{ (wh_default_app | combine(item.1)).database.server | default(mysql_server) }} \
|
|
--user={{ item.0.name[0:7] }}_{{ item.1.name[0:7] }} \
|
|
--password="{{ (wh_default_app | combine(item.1)).database.pass | default((wh_pass_seed | password_hash('sha256', 65534 | random(seed=item.0.name + item.1.name) | string))[9:27] ) }}" \
|
|
{{ item.0.name[0:7] }}_{{ item.1.name[0:7] }} | \
|
|
zstd -c > archives/$TS.sql.zst
|
|
ZSTD_CLEVEL=15 ZSTD_NBTHREADS=0 nice -n 9 tar cf archives/$TS.tar.zst --use-compress-program=zstd data web logs
|