The design of self-sustainable base station (BS) deployments is addressed in this paper. We target deployments featuring small BSs with energy harvesting (EH) and storage capabilities. These BSs can use ambient energy to serve the local traffic or store it for later use. A dedicated power packet grid is utilized to transfer energy across them, compensating for imbalance in the harvested energy or in the traffic load. Some BSs are offgrid, i.e., they can only use the locally harvested energy and that transferred from other BSs, whereas others are ongrid, i.e., they can additionally purchase energy from the power grid. Within this setup, an optimization problem is formulated where: harvested energy and traffic processes are estimated (at runtime) at the BSs through Gaussian processes, and a model predictive control framework is devised for the computation of energy allocation and transfer across BSs. The combination of prediction and optimization tools leads to an efficient and online solution that automatically adapts to EH and load dynamics. Numerical results, obtained using real EH and traffic profiles, show substantial improvements with respect to the case where the optimization is carried out without predicting future system dynamics. The main improvements are in the outage probability (zero in most cases), and in the amount of energy purchased from the power grid, that is more than halved for the same served load. Index Terms-Online learning, foresighted optimization, energy harvesting, energy routing, energy self-sustainability, power packet grids, mobile networks. 1 Computed as the ratio between the number of BSs that are unable to serve the users within range due to energy scarcity, and the total number of BSs.