As usual, there are probably lots of ways to do it. It depends on how your game works, how long a typical run takes, how many enemies there are, do they exist for the whole run, do they spawn at the same point or do they randomly spawn, do they shoot at you, do you shoot at them, etc.
ROJOhound's method records the Player's X, Y, Animation, Frame, and width every tick. If there isn't randomness to the game you could instead save the player's input and then have everything respond to the input in the same way to recreate what happened. There is also the Game Recorder object that can record a video of the canvas. I think that was meant to allow you to download the video, but it might be a way to play back exactly what happened without having to save all the things that move separately.
The more that happens in your game, the more you have to save - and the more memory required to do that.
One of my favorite games is Jetpack Joyride. At the end of a run they show you a snapshot from the run. Showing an instant replay is a lot trickier...
Thanks for the detailed answer, much appreciated. I'll explore it and will share my experience.