In this paper, resource allocation is studied for a fully sustainable cooperative IoT network, in which a relay powered by renewable energy forwards data to a destination while charging multiple IoT nodes by radio-frequency (RF) signals. An optimal joint time and power allocation problem is formulated to maximize the long-term sum-throughput of IoT nodes, taking into consideration the bounded transmit power of IoT nodes, the stochastic characteristic of energy harvesting (EH) process, and dynamic wireless channel conditions. To solve the formulated problem, we analyze the time allocation for cooperative communications with EH, considering both data and energy dependency of the two hop transmissions in three cases with different network settings. Based on the analysis, we derive the closed-form solutions of optimal time and power allocation in a network with symmetric links. Then, we extend our solution to a general network with asymmetric links. By employing Lyapunov optimization, an online stochastic resource allocation algorithm is proposed to obtain the maximum network throughput. It has been shown that the proposed algorithm can achieve close-to-optimal network throughput while maintaining the stability of the system. Finally, extensive simulations validate the analysis and demonstrate the effectiveness of the proposed algorithm.