#!/bin/bash
################################################################################
# NVR Backup Script
#
# Triggers a backup of the NVR system via the backend container.
# The backup is stored on the VideoStore partition so it survives OS reinstall.
#
# Usage:
#   sudo ./backup-nvr.sh
#
# URL: http://files.dividia.net/software/nvr-docker/backup-nvr.sh
################################################################################

INSTALL_DIR="/opt/dividia"

# Keep the published compatibility entry point, but use the unified command.
# The unified path owns the durable intent check and the shared operation lock.
if [[ ! -x "$INSTALL_DIR/nvr" ]]; then
    echo "ERROR: $INSTALL_DIR/nvr is not installed" >&2
    exit 1
fi

exec "$INSTALL_DIR/nvr" backup
