We show how electricity storage is operated optimally when the load net of renewable output is uncertain. We estimate a diurnal Markov-process representation of this residual load in Germany in 2011 to 2015 on an hourly basis and design a simple dynamic stochastic electricity system model with non-intermittent generation technologies and storage. We derive the optimal storage, generator output and capacity levels. If storage capacity replaces some generation capacity, the optimal storage strategy must balance arbitrage (between periods of high and low marginal cost) against precautionary storage to ensure energy is available throughout a long peak in net demand. We then solve the model numerically under realistic conditions and compare the results to perfect foresight findings. We show that a perfect foresight model would over-estimate the cost-saving potential of energy storage by 18%, as it takes up arbitrage opportunities that ignore the need for precautionary storage.