Rewrite the integrand:
\[
\frac{x^2 - 1}{x^2 + 4} = \frac{(x^2 + 4) - 5}{x^2 + 4} = 1 - \frac{5}{x^2 + 4}.
\]
Thus,
\[
\int \frac{x^2 - 1}{x^2 + 4} \, dx = \int \left( 1 - \frac{5}{x^2 + 4} \right) dx = \int 1 \, dx - 5 \int \frac{dx}{x^2 + 4}.
\]
Calculate each integral:
\[
\int 1 \, dx = x,
\]
and
\[
\int \frac{dx}{x^2 + 4} = \frac{1}{2} \tan^{-1} \frac{x}{2}.
\]
Therefore,
\[
\int \frac{x^2 - 1}{x^2 + 4} \, dx = x - 5 \times \frac{1}{2} \tan^{-1} \frac{x}{2} + C = x - \frac{5}{2} \tan^{-1} \frac{x}{2} + C.
\]
Final answer:
\[
\boxed{
x - \frac{5}{2} \tan^{-1} \frac{x}{2} + C.
}
\]