Mining accidents are sometimes preceded by high levels of crackling noise, which follow universal rules for the collapse of minerals. The archetypal test cases are sandstone and coal. Their collapse mechanism is almost identical to earthquakes: the crackling noise in large, porous samples follows a power law (Gutenberg-Richter) distribution P ~ E -e with energy exponents e for near critical stresses of e = 1.55 for dry and wet sandstone, and e = 1.32 for coal. The exponents of early stages are slightly increased, 1.7 (sandstone) and 1.5 (coal), and appear to represent the collapse of isolated, uncorrelated cavities. A significant increase of the acoustic emission, AE, activity was observed close to the final failure event, which acts as "warning signal" for the impending major collapse. Waiting times between events also follow power law distributions with exponents 2+x between 2 and 2.4. Aftershocks occur with probabilities described by Omori coefficients p between 0.84 (sandstone) and 1 (coal). The "Båth's law" predicts that the ratio between the magnitude of the main event and the largest aftershock is 1.2.Our experimental findings confirm this conjecture. Our results imply that acoustic warning methods are often possible within the context of mining safety measures, although it is not only the increase of crackling noise that can be used as early warning signal but also the change of the energy distribution of the crackling events.