We describe a multi-mode quantum memory for propagating microwave photons that combines a solid-state spin ensemble resonantly coupled to a frequency tunable single-mode microwave cavity. We first show that high efficiency mapping of the quantum state transported by a free photon to the spin ensemble is possible both for strong and weak coupling between the cavity mode and the spin ensemble. We also show that even in the weak coupling limit unit efficiency and faithful retrieval can be obtained through time reversal inhomogeneous dephasing based on spin echo techniques. This is possible provided that the cavity containing the spin ensemble and the transmission line are impedance matched. We finally discuss the prospects for an experimental implementation using a rare-earth doped crystal coupled to a superconducting resonator.