Premelting describes the confluence of phenomena that are responsible for the stable existence of the liquid phase of matter in the solid region of its bulk phase diagram. Here we develop a theoretical description of the premelting of water ice contained in a porous matrix, made of a material with a melting temperature substantially larger than ice itself, to predict the amount of liquid water in the matrix at temperatures below its bulk freezing point. Our theory combines the interfacial premelting of ice in contact with the matrix, grain-boundary melting in the ice, and impurity and curvature induced premelting, with the latter occurring in regions which force the ice-liquid interface into a high curvature configuration. These regions are typically found at points where the matrix surface is concave, along contact lines of a grain boundary with the matrix, and in liquid veins. Both interfacial premelting and curvature induced premelting depend on the concentration of impurities in the liquid, which, due to the small segregation coefficient of impurities in ice are treated as homogeneously distributed in the premelted liquid. Our principal result is an equation for the fraction of liquid in the porous medium as a function of the undercooling, which embodies the combined effects of interfacial premelting, curvature induced premelting, and impurities. The result is analyzed in detail and applied to a range of experimentally relevant settings.