ansible/roles/unhb_backup_scripts/templates/restic-backup_unhb4.sh.j2

42 lines
2.2 KiB
Plaintext
Raw Permalink Normal View History

2023-10-10 12:40:22 +02:00
#!/bin/bash
#
#
# This file is managed via Ansible, do not edit manually. Changes might get overwitten.
#
#
source /opt/scripts/restic/restic.env
source /opt/scripts/restic/restic_db_passwords.env
#We will have to find out whether or not we need to initialize the repo. A non-zero exit code indicates that it has not yet been initialized.
restic snapshots
if [ "$?" -eq "0" ]
then
echo "Repo is already initialized, no need to do that."
else
echo "We need to initialize the repo first." && restic init
fi
echo "Now dumping databases, this might take a while..."
set -x
docker exec -t matrix_sql.server4 pg_dump -Z0 -c -U user_synapse_unhb -d synapse_db > /opt/db_dumps/db-dump-synapse_db.sql
docker exec -t authentik-postgresql-1.server4 pg_dumpall -c -U authentik > /opt/db_dumps/db-dump-authentik_db.sql
docker exec -t hedgedoc_sql15.server4 pg_dumpall -c -U md > /opt/db_dumps/db-dump-hedgedoc_db.sql
docker exec -t tandoor-tandoor_recipes_db-1 pg_dumpall -c -U djangouser > /opt/db_dumps/db-dump-tandoor_db.sql
docker exec -t wikijs-wikijs-db-1 pg_dumpall -c -U wikijs > /opt/db_dumps/db-dump-wikijs_db.sql
docker exec -t nextcloud_sql.server4 sh -c "exec mariadb-dump --all-databases -uroot --password=$MARIADB_PASSWORD_NEXTCLOUD" > /opt/db_dumps/db-dump-nextcloud_db.sql
docker exec -t etherpad_sql.server4 sh -c "exec mariadb-dump --all-databases -uroot --password=$MARIADB_PASSWORD_ETHERPAD" > /opt/db_dumps/db-dump-etherpad_db.sql
docker exec -t jverein_sql.server4 sh -c "exec mariadb-dump --all-databases -uroot --password=$MARIADB_PASSWORD_JVEREIN" > /opt/db_dumps/db-dump-jverein_db.sql
docker exec -t url-shortener_sql.server4 sh -c "exec mariadb-dump --all-databases -uroot --password=$MARIADB_PASSWORD_URLSHORTENER" > /opt/db_dumps/db-dump-urlshortener_db.sql
docker exec -t wiki_sql.server4 sh -c "exec mariadb-dump --all-databases -uroot --password=$MARIADB_PASSWORD_WIKI" > /opt/db_dumps/db-dump-wiki_db.sql
docker exec -t wordpress_sql.server4 sh -c "exec mysqldump --all-databases -uroot --password=$MARIADB_PASSWORD_WORDPRESS" > /opt/db_dumps/db-dump-wordpress_db.sql
2023-10-10 12:40:22 +02:00
set +x
2024-08-27 11:08:18 +02:00
restic backup --host="{{ inventory_hostname }}" --verbose \
2023-10-10 12:40:22 +02:00
/etc \
/home \
/opt \
/root \
/srv
# /var/lib/docker/volumes/ \
2023-10-10 12:40:22 +02:00
echo "done! :)"