From 03edfcef85c977852420d0dff5e593856565baaa Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Tue, 28 Jul 2026 18:10:12 +1000 Subject: [PATCH] fix(bazarr): store data in /var/lib/bazarr instead of inside /opt/bazarr (#16098) * fix(bazarr): store data in /var/lib/bazarr instead of inside /opt/bazarr The installer creates /var/lib/bazarr and update_script() uses it as the "is Bazarr installed" guard, but nothing pointed Bazarr at it. Bazarr defaults its data directory to /data, resolved from its own source file rather than WorkingDirectory, so a stock container kept config/ db/ backup/ cache/ log/ restore/ in /opt/bazarr/data - the directory fetch_and_deploy_gh_release redeploys over - while /var/lib/bazarr stayed empty. Pass -c /var/lib/bazarr in the unit, matching the -data= flag the other *arr scripts use. bazarr.py re-execs its child with sys.argv[1:], so the flag survives the restart Bazarr performs while loading its config. update_script() gains a one-time migration for existing installs. It runs outside the release check so containers already on the latest version are migrated too, is skipped when the unit already names a data directory, refuses (before stopping the service) when both locations hold data, and copies before removing so a failed migration leaves the original database in place. Fixes #16097 * fix(bazarr): drop explanatory comments per review --- ct/bazarr.sh | 25 +++++++++++++++++++++++++ install/bazarr-install.sh | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ct/bazarr.sh b/ct/bazarr.sh index dddd27d9e..538ca16f2 100755 --- a/ct/bazarr.sh +++ b/ct/bazarr.sh @@ -28,6 +28,31 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi + + if ! grep -qE -- "bazarr\.py.*[[:space:]](-c|--config)([[:space:]]|=)" /etc/systemd/system/bazarr.service 2>/dev/null; then + if [[ -d /opt/bazarr/data && ! -L /opt/bazarr/data && -n "$(ls -A /var/lib/bazarr/ 2>/dev/null)" ]]; then + msg_error "/opt/bazarr/data and /var/lib/bazarr both contain data - refusing to merge them. Keep the copy you want in /var/lib/bazarr, remove /opt/bazarr/data, then run the update again." + exit 1 + fi + + msg_info "Moving Bazarr data to /var/lib/bazarr" + systemctl stop bazarr + if [[ -L /opt/bazarr/data ]]; then + rm -f /opt/bazarr/data + elif [[ -d /opt/bazarr/data ]]; then + if ! cp -a /opt/bazarr/data/. /var/lib/bazarr/; then + systemctl start bazarr + msg_error "Could not copy /opt/bazarr/data to /var/lib/bazarr - nothing was removed." + exit 1 + fi + rm -rf /opt/bazarr/data + fi + sed -i -E "s|^(ExecStart=.*bazarr\.py.*)$|\1 -c /var/lib/bazarr|" /etc/systemd/system/bazarr.service + systemctl daemon-reload + systemctl start bazarr + msg_ok "Moved Bazarr data to /var/lib/bazarr" + fi + if check_for_gh_release "bazarr" "morpheus65535/bazarr"; then msg_info "Stopping Service" systemctl stop bazarr diff --git a/install/bazarr-install.sh b/install/bazarr-install.sh index 1ff43032e..3a2cd01d8 100755 --- a/install/bazarr-install.sh +++ b/install/bazarr-install.sh @@ -36,7 +36,7 @@ UMask=0002 Restart=on-failure RestartSec=5 Type=simple -ExecStart=/opt/bazarr/venv/bin/python3 /opt/bazarr/bazarr.py +ExecStart=/opt/bazarr/venv/bin/python3 /opt/bazarr/bazarr.py -c /var/lib/bazarr KillSignal=SIGINT TimeoutStopSec=20 SyslogIdentifier=bazarr