问题排查与运维

各版本如何查看日志、如何备份数据,以及管理员密码找回等高频运维问题。

4 个小节 · 约 8 分钟读完

各版本如何查看日志

BestNav 所有版本运行同一份 Go 程序,启动与运行日志均输出到标准输出(stdout),由各平台的启动方式负责收集:容器版由 Docker 引擎收集、飞牛版由 systemd-journald 收集、群晖 SPK 由启动脚本重定向写入数据目录下的 bestnav.log 文件。按平台查看方式如下:

  • Docker / 群晖 Container Manager / 威联通 / 极空间(容器版):docker logs bestnav,或 docker logs -f bestnav 实时跟踪;只看报错:docker logs bestnav 2>&1 | grep "\[ERROR\]"
  • 群晖 SPK 直装版(非容器):日志在文件 /var/packages/bestnav/target/data/bestnav.log,需用 root 查看:sudo tail -n 100 /var/packages/bestnav/target/data/bestnav.log;实时跟踪:sudo tail -f 同路径
  • 飞牛 fnOS 版:由 systemd 托管(服务名 bestnav,不是已废弃的 bestnav-direct),日志在 journal 不在文件目录。查看:journalctl -u bestnav -n 100 --no-pager;实时跟踪:journalctl -f -u bestnav
  • 排查 Pro 授权 / 插件加载问题(如长时间显示“Pro 功能正在加载中”):在各自日志上 grep "\[Pro\]",会直接给出具体失败原因

注意:应用数据目录下的 data/logs/ 只是启动脚本预建的空目录,BestNav 的程序日志不会写进去;飞牛版的启动日志只在 journalctl 中可见。若 systemctl 提示找不到单元,先确认服务名:ls /etc/systemd/system/ | grep bestnav(老版本残留的 bestnav-direct.service 可直接删除)。

如何备份数据

完整备份只需打包数据即可。Docker 版数据在命名卷 bestnav_data(用下方命令打包);飞牛 fpk / 群晖 SPK 等非容器部署的数据目录由安装时指定(通常位于应用数据盘)。备份内容包含:书签与配置、用户与授权、license.json、auth.json、上传文件、自动备份,以及最关键的 .secrets(加密密钥文件)。

Bash# Docker 版示例:打包命名卷 bestnav_data docker run --rm -v bestnav_data:/data -v $PWD:/backup alpine \ tar -czf /backup/bestnav-data-$(date +%F).tar.gz -C /data . # 飞牛 / 群晖直装示例(目录以实际安装为准) tar -czf bestnav-data-$(date +%F).tar.gz -C /path/to/appdata data
  • .secrets 一旦丢失,已用其加密保存的本地 API Key / 密码 / 密钥将永久无法解密,务必一并备份
  • 也可在「设置 → 数据」中一键导出配置 JSON 作为补充
  • 建议定时脚本化备份(保留最近 7 天),并将备份复制一份到异地或云盘

迁移到新设备:停止旧服务 → 打包 data → 传输到新设备 → 解压到同名 data 目录 → 启动。恢复后 .secrets 与数据将完全一致。

管理员密码找回 / 重置

如果忘记了管理员(创始账号)登录密码,可在服务器上执行命令行重置,无需重装、不会丢失数据,也无需重启应用(服务每次登录都会重读 auth.json,重置立即生效)。子命令固定为 reset-password(不带任何前置减号),执行后交互式隐藏输入两次新密码(至少 6 位)。也可以直接在登录页点「忘记密码」,应用会自动按你的安装方式给出匹配的命令。各平台命令:

Bash# Docker / 群晖 Container Manager / 威联通 / 极空间(官方镜像) docker exec -it bestnav /app/bestnav reset-password # 容器名以 docker ps 实际为准;官网通用 compose(alpine 方案)二进制为 /tmp/bestnav # 群晖 SPK 直装版(非容器,root 执行;二进制按架构自动选择) sudo -i cd /var/packages/bestnav/target DATA_DIR=/var/packages/bestnav/var/data ./server/bestnav-linux-$(uname -m | grep -qE "aarch64|arm64" && echo arm64 || echo amd64) reset-password # 老版本 SPK 数据仍在 target/data 时,把上面 DATA_DIR 改成 ./data # 飞牛 fnOS(应用中心版,2026-09-24 起无 systemd 单元;路径从运行中的进程自动读取) sudo -i PID=$(pgrep -f "server/bestnav" | head -1) BIN=$(readlink /proc/$PID/exe) DD=$(tr "\0" "\n" </proc/$PID/environ | grep "^DATA_DIR=" | cut -d= -f2-) echo "BIN=$BIN DATA_DIR=$DD" # 先确认两个值非空 DATA_DIR="$DD" "$BIN" reset-password # 飞牛 fnOS 旧版(仍以 systemd 托管:存在 /etc/systemd/system/bestnav.service) sudo -i BIN=$(grep ^ExecStart= /etc/systemd/system/bestnav.service | cut -d= -f2) "$BIN" reset-password
  • 子命令必须写成 reset-password——带减号的 -reset-password / --reset-password 不会被识别,会被当作正常启动处理
  • 飞牛新版(2026-09-24 起)没有 systemd 单元,旧文档里的 grep bestnav.service、systemctl stop bestnav 均已失效;必须显式带 DATA_DIR(上方命令从运行进程环境自动读取,与应用真实数据目录一致,通常为 /vol*/@appdata/bestnav/data)
  • 飞牛 fpk 与群晖 SPK 的二进制都不在 /usr/local/bin(旧文档命令已废弃),请按上方真实路径执行
  • 新密码是交互式隐藏输入两遍,不能用管道或脚本喂入(echo xxx | 会失败),请使用可交互的 SSH 终端
  • v1.0.3 起以 root 重置会自动把 auth.json 属主还给服务运行用户;更老版本重置后需手动归还,属主以 ls -l 该 auth.json 显示的为准(群晖 DSM7 一般是 sc-bestnav)
  • 重置只改登录密码,不动书签、已保存的 API Key 与加密密钥(.secrets)
  • 找不到群晖二进制时先确认架构后缀:ls /var/packages/bestnav/target/server/
  • 普通成员密码由管理员在「设置 → 用户」中重置,无需命令行

加密密钥说明

首次启动时自动生成的 .secrets 包含多套密钥:JWT_SECRET(登录会话)、LICENSE_ENC_KEY(用于加密 / 解密你本地保存的 API Key、密码、密钥)、HMAC_SECRET(授权心跳验签)。它们只存在于你的服务器,BestNav 官方无法获取,也不会上传。

妥善保管 .secrets 与 data 目录备份。迁移或重装时务必先恢复 .secrets,否则已加密的凭据将无法使用。

View Logs per Platform

All BestNav editions run the same Go binary; startup and runtime logs go to stdout, collected differently per platform: the Docker engine for container editions, systemd-journald for fnOS, and a bestnav.log file in the data directory for the Synology SPK (redirected by its start script). How to view per platform:

  • Docker / Synology Container Manager / QNAP / ZSpace (container): docker logs bestnav, or docker logs -f bestnav to follow; errors only with docker logs bestnav 2>&1 | grep "\[ERROR\]"
  • Synology SPK (native install, NOT a container): logs live in /var/packages/bestnav/target/data/bestnav.log, view as root: sudo tail -n 100 /var/packages/bestnav/target/data/bestnav.log; follow with sudo tail -f on the same path
  • fnOS: managed by systemd under the service name bestnav (the retired name was bestnav-direct); logs live in the journal, NOT a file. View with journalctl -u bestnav -n 100 --no-pager; follow with journalctl -f -u bestnav
  • Debugging Pro license / plugin issues (e.g. a stuck “Pro features are loading” banner): grep "\[Pro\]" in the respective log — it prints the exact failure reason

Note: the data/logs/ folder under the app data dir is only an empty dir pre-created by the start scripts — BestNav never writes program logs there; on fnOS startup logs appear only in journalctl. If systemd says the unit is not found, check the name with: ls /etc/systemd/system/ | grep bestnav (you can safely delete a leftover bestnav-direct.service).

Back Up Your Data

A full backup is just a tar of the data. Docker keeps data in the named volume bestnav_data (pack it with the command below); native installs (fnOS / Synology) use the data dir chosen at install time (usually on the app data disk). The backup contains bookmarks & config, users & license, license.json, auth.json, uploaded files, auto-backups, and most importantly .secrets (the encryption key file).

Bash# Docker example: tar the named volume bestnav_data docker run --rm -v bestnav_data:/data -v $PWD:/backup alpine \ tar -czf /backup/bestnav-data-$(date +%F).tar.gz -C /data . # fnOS / Synology native example (use your actual path) tar -czf bestnav-data-$(date +%F).tar.gz -C /path/to/appdata data
  • If .secrets is lost, locally encrypted API Keys / passwords / keys become permanently undecryptable — back it up too
  • Also export config JSON from Settings → Data as a supplement
  • Schedule scripted backups (keep last 7 days) and copy one copy offsite or to cloud

To migrate: stop the old service → tar data → transfer to the new device → extract to the same-name data dir → start. After restore, .secrets and data are identical.

Recover / Reset Admin Password

If you forget the admin (founder) password, reset it from the command line — no reinstall, no data loss, and no restart needed (the service re-reads auth.json on every login, so the reset takes effect immediately). The subcommand is always reset-password (no leading dashes); type the new password twice when prompted (hidden input, min 6 chars). The "Forgot password" link on the login page also prints the matching command for your install method. Per platform:

Bash# Docker / Synology Container Manager / QNAP / ZSpace (official image) docker exec -it bestnav /app/bestnav reset-password # Use the actual name from docker ps; for the generic compose (alpine variant) the binary is /tmp/bestnav # Synology SPK (native install, not a container; run as root, arch auto-selected) sudo -i cd /var/packages/bestnav/target DATA_DIR=/var/packages/bestnav/var/data ./server/bestnav-linux-$(uname -m | grep -qE "aarch64|arm64" && echo arm64 || echo amd64) reset-password # On very old SPK builds where data still lives in target/data, use DATA_DIR=./data instead # fnOS (app-center edition, no systemd unit since 2026-09-24; paths auto-read from the running process) sudo -i PID=$(pgrep -f "server/bestnav" | head -1) BIN=$(readlink /proc/$PID/exe) DD=$(tr "\0" "\n" </proc/$PID/environ | grep "^DATA_DIR=" | cut -d= -f2-) echo "BIN=$BIN DATA_DIR=$DD" # both values must be non-empty DATA_DIR="$DD" "$BIN" reset-password # fnOS legacy (still systemd-managed: /etc/systemd/system/bestnav.service exists) sudo -i BIN=$(grep ^ExecStart= /etc/systemd/system/bestnav.service | cut -d= -f2) "$BIN" reset-password
  • The subcommand must be exactly reset-password — -reset-password / --reset-password is not recognized and the program just starts normally
  • New fnOS installs (since 2026-09-24) have no systemd unit — the old grep bestnav.service / systemctl stop bestnav commands no longer apply; DATA_DIR must be set explicitly (the command above reads it from the running process env; usually /vol*/@appdata/bestnav/data)
  • On fnOS / Synology SPK the binary is NOT in /usr/local/bin (legacy commands are deprecated) — use the real paths above
  • The new password is typed interactively (hidden, twice, min 6 chars); piping it in (echo xxx |) will NOT work — use an interactive SSH terminal
  • Since v1.0.3 running the reset as root automatically hands auth.json back to the service user; on older versions chown it manually — the owner shown by ls -l is authoritative (sc-bestnav on DSM 7)
  • Reset affects only the login password; bookmarks, stored API Keys and the .secrets encryption key are untouched
  • If the Synology binary name is unclear, check the arch suffix: ls /var/packages/bestnav/target/server/
  • Member passwords are reset by the admin in Settings → Users, no CLI needed

About the Encryption Key

The auto-generated .secrets holds several keys: JWT_SECRET (login sessions), LICENSE_ENC_KEY (encrypts/decrypts your locally stored API Keys, passwords, keys), and HMAC_SECRET (license heartbeat signing). They exist only on your server — BestNav cannot access or upload them.

Keep .secrets and the data backup safe. On migration or reinstall, always restore .secrets first, or encrypted credentials will be unusable.