This paper proposes the optimal protection scheme for the reliable distributed storage in the Internet of Things (IoT) scenarios, where the system loses the random number of devices per failure event. We investigate the protection problem with the random number of failures, and model the protection strategies based on a path graph. Furthermore, we devise an algorithm to identify the optimal strategy that achieves the minimum bandwidth use with low complexity. The numerical results show that in a system with 10 nodes, our proposed optimal strategy reduces the protection bandwidth up to more than five times the original data size, and the number of connections as much as 74 %, with respect to a strategy derived from the case of one by one failure.