As climate changes intensify the frequency of severe outages, the resilience of electricity supply systems becomes a major concern. In order to simultaneously combat the climate problems and ensure electricity supply in isolated areas, renewable energy sources (RES) have been widely implemented in recent years. However, without the use of energy storage, they show low reliability due to their intermittent output. Therefore, this article proposes a methodology to achieve the optimal sizing of an energy storage system (ESS) to ensure predefined periods of safe operation for an ensemble consisting of multiple loads, renewable energy sources and controllable generators, located in a remote microgrid. In this regard, a mixed integer linear programming (MILP) model has been proposed to reduce the outages impact of critical loads by calculating the optimal ESS capacity and defining the proper resources management within the off-grid microgrid, while ensuring a cost-effective operation of its components.