Energy cost from Heating-Ventilation-Air-Conditioners (HVAC) is a significant fraction of the overall operational cost of commercial buildings. Moreover, in developing countries such as India with inadequate grid connectivity and frequent outages, diesel generators (DG) are a common source of backup power. While this may address the problem of outages, power from DGs is highly expensive. While solar power and battery storage present opportunities to offset this high DG cost, they also add significant complexity to the overall infrastructure. This work proposes an optimization framework targeted to reduce the energy costs associated with HVACs in the presence of outages and a mix of energy resources such as grid, diesel generators, solar, and battery. Our framework is novel since it schedules supply resources and optimizes temperature set points by leveraging the inherent thermal storage potential of a building and opportunistic occupancy proxies such as CO2 concentration. Additionally, we develop an algorithm based on closed-form approximation of the optimal solution, which can easily be integrated with existing building management systems. The framework when investigated for real world scenarios such as cell towers and office buildings, results in savings of more than 10% relative to normal operational practices.