You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
958 B

# Immediatly exit on command failure (e)
# and quit on unset variables (u)
set -ue
export BACKUP_REPO=ssh://cttuebak/media/borg/cttue/cloud
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 Nextcloud Database..."
docker exec nextcloud_nc_db_1 mysqldump -u nextcloud -pnextcloud --lock-tables --databases nextcloud |
/usr/bin/borg create --compression zstd --stats ${BACKUP_REPO}::${BACKUP_NAME_DB} -
echo "Starting Backup of Nextcloud Uploaded Files..."
/usr/bin/borg create --compression zstd --stats ${BACKUP_REPO}::${BACKUP_NAME_DATA} /srv/docker-containers/nextcloud/nextcloud-data
echo "Backup done. Pruning backup-repo..."
/usr/bin/borg prune -v --list --keep-daily=7 --keep-weekly=7 --keep-monthly=10 --keep-yearly=5 ${BACKUP_REPO}
echo "Done"