The uniaxial compression and uniaxial cyclic loading and unloading tests were carried out on sandstone, and the variation laws of residual deformation, deformation modulus and lateral expansion coefficient under cyclic loading were obtained. In addition, the evolution laws of the rock input energy, elastic energy, dissipation energy, damping energy, damage energy and other energy indicators were determined. The normalized damage energy was used to characterize the damage evolution of the rock and analyze the failure modes from the macro and micro perspectives. Studies have shown that: under cyclic loading and unloading, the residual deformation exhibits a trend of deceleration-stabilization-acceleration increase. The deformation modulus of sandstone first increases and then decreases, and the lateral expansion coefficient is basically positively correlated with the number of cycles. The input energy, damage energy and the proportion of damage energy to the dissipation energy have the U-shaped distribution. Moreover, a decrease is first observed in the damping energy followed by an increase, and the proportion of damping energy to dissipation energy has the inverted U-shaped distribution. Additionally, the elastic energy generally grows slowly, and the proportion of elastic energy to input energy has the inverted U-shaped distribution. The damping energy increases with the increase of stress ratio, while the proportion of damping energy decreases. The damage of sandstone develops in three stages: deceleration-stabilization-acceleration. The compound failure mode combining shear failure and tension failure in the conjugate inclined plane is generally found in the sandstone, and the failure transforms from unstable damage to failure damage.