The mechanics of cohesive or cemented granular materials is complex, combining the heterogeneous responses of granular media, like force chains, with clearly defined material properties. Here, we use a discrete element model (DEM) simulation, consisting of an assemblage of elastic particles connected by softer but breakable elastic bonds, to explore how this class of material deforms and fails under uniaxial compression. We are particularly interested in the connection between the microscopic interactions among the grains or particles and the macroscopic material response. To this end, the properties of the particles and the stiffness of the bonds are matched to experimental measurements of a cohesive granular media with tunable elasticity. The criterion for breaking a bond is also based on an explicit Griffith energy balance, with realistic surface energies. By varying the initial volume fraction of the particles we show that this simple model reproduces a wide range of experimental behaviors, both in the elastic limit and beyond it. These include quantitative details of the distinct failure modes of shear-banding, ductile failure and compaction banding or anti-cracks, as well as the transitions between these modes. The present work, therefore, provides a unified framework for understanding the failure of porous materials such as sandstone, marble, powder aggregates, snow and foam.