#!/usr/bin/env bash

docker exec -t nightscout-db-1 mongodump --quiet --archive | zstd > nightscout_database_$(date -Is).archive.zst
docker exec -t gitea-db-1 pg_dumpall --clean --if-exists -U gitea | zstd > gitea_database_$(date -Is).dump.zst
docker exec -t paperless-db-1 pg_dumpall --clean --if-exists -U paperless | zstd > paperless_database_$(date -Is).dump.zst
docker exec -t teslamate-db-1 pg_dumpall --clean --if-exists -U teslamate | zstd > teslamate_database_$(date -Is).dump.zst

# ------------------------------------
# To decompress the files use zstd -d:
#
# zstd -d < file.dump.zst > file.dump
# ------------------------------------