# Immediatly exit on command failure (e) # and quit on unset variables (u) set -ue export BACKUP_REPO=ssh://cttuebak/media/borg/cttue/gitea export BACKUP_NAME_DB="db_$(date -u +'%Y-%m-%dT%H:%M%Z')" export BACKUP_NAME_DATA="data_$(date -u +'%Y-%m-%dT%H:%M%Z')" export BORG_PASSPHRASE=$(cat "$(dirname $0)/borg_passphrase.txt") # Dump the database into borg create echo "Starting Backup of Gitea Database..." docker exec gitea_db_1 pg_dump gitea -U gitea | /usr/bin/borg create --compression zstd --stats ${BACKUP_REPO}::${BACKUP_NAME_DB} - echo "Backup done. Pruning Gitea Database..." /usr/bin/borg prune -v --list --keep-daily=7 --keep-weekly=7 --keep-monthly=10 --keep-yearly=5 -a "db_*" ${BACKUP_REPO} echo "Starting Backup of Gitea Data..." /usr/bin/borg create --compression zstd --stats ${BACKUP_REPO}::${BACKUP_NAME_DATA} /srv/docker-containers/gitea/gitea-data echo "Backup done. Pruning Gitea Data..." /usr/bin/borg prune -v --list --keep-daily=7 --keep-weekly=7 --keep-monthly=10 --keep-yearly=5 -a "data_*" ${BACKUP_REPO} echo "Done"