#!/bin/bash source /opt/scripts/restic/restic.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 su - postgres --session-command 'pg_dump "{{ matrix_db_name }}" -f /opt/db_dumps/db-dump-{{ matrix_db_name }}.sql' su - postgres --session-command 'pg_dump "mautrix_googlechat" -f /opt/db_dumps/db-dump-mautrix_googlechat.sql' su - postgres --session-command 'pg_dump "mautrix_slack" -f /opt/db_dumps/db-dump-mautrix_slack.sql' restic backup --verbose \ /etc/matrix-synapse \ /opt \ /var/lib/matrix-synapse echo "done! :)"