In an emergency I simply will not be able to function without coffee. But I was surprised to learn that many people don't know how quickly coffee loses its flavor.
Ground coffee starts to flatten out almost immediately upon being exposed to oxygen. Typically you can expect it to hold its flavor for a few days, maybe two or three weeks at the most. After that it will still resemble "coffee" but the flavor will be significantly weakened. Storing it in mylar with an O2 absorber may help somewhat, but the flavor breakdown is already underway by the time you seal the bag.
Roasted coffee beans will last roughly a year stored at room temperature, away from direct sunlight. Storing them in mylar (with that O2 absorber) should stretch this out somewhat. I'm going to fill and seal two small bags out of my next purchase, and test them at the 3 and 5 year marks.
I see people recommending green (unroasted) beans for long-term storage, but there are two problems there. Roasting isn't an exact science; you'll want to make sure you're a seasoned roaster before you ruin your stash. And when you do roast, that wonderful smell will be travel far and wide. In a SHTF situation, that's a powerful motivator for someone to come pay you a visit.
I'm saying this as a coffee snob who hates instant coffee: instant coffee is the best way to go for long-term storage. There are special "prepper" brands of instant coffee out there but the truth is as long as the container is sealed, it's going to hold its flavor for many years. Go to your local supermarket and buy a few jars of whatever floats your boat, write the purchase date on them, and tuck them away in the back of your pantry. At the minimum they'll be good for many years, probably at least a decade.