fix: update mode backs up database before making changes

- Creates timestamped backup at /opt/receiptnext/backups/expenses-YYYYMMDD-HHMMSS.db
- rsync only targets templates/ and static/ — database is never touched
This commit is contained in:
Claus Lohmar 2026-06-01 23:20:14 +00:00
parent c386b150c4
commit 5aca6c06a5

View file

@ -68,6 +68,15 @@ if [ "${1:-}" = "-update" ]; then
cd "$INSTALL_DIR"
fi
# Backup the database before making any changes.
if [ -f "$INSTALL_DIR/expenses.db" ]; then
BACKUP_DIR="$INSTALL_DIR/backups"
sudo_if mkdir -p "$BACKUP_DIR"
BACKUP_FILE="$BACKUP_DIR/expenses-$(date +%Y%m%d-%H%M%S).db"
sudo_if cp "$INSTALL_DIR/expenses.db" "$BACKUP_FILE"
info "Database backed up to $BACKUP_FILE"
fi
# Copy updated templates, static assets, and config files.
info "Updating templates and static assets..."
sudo_if rsync -a --delete templates/ "$INSTALL_DIR/templates/" 2>/dev/null || true