Earlier quoted context omitted.
I sure hope the haircut function mutates it's input, and doesn't return a clone whose hair is cut.
Reminds me of a YouTube video which said every time someone gets beamed in Star Trek they are killed and someone else is created with their body and mind somehow. If that were possible, why wouldn’t they just store backups and “restore” from backup when someone died?
There are 3 broad cases:
1. Something goes wrong during transport and the person cannot be rematerialised. Typically they end up "stuck" in the pattern buffer of the transporter. Some fiddling and plot tension allows them to complete transport by the end of the episode
2. A partial transport leaves some part of the person behind. This is where you can end up with weird things like piles of sludge on each end, or evil doppelgängers who are mostly the same, but only some features were transported
3. Unknown phenomenon that creates a duplicate. The original has general "failed to transport" experience, while the clone has a complete experience and is so none the wiser that "they" also got left behind.
From this we know that the pattern buffers can absolutely be used to store "backups". This is even discussed at some points after a crew member unexpectedly dies. However what complicates matters is that typically the patterns rapidly lose coherence in the buffers. Whether this happens immediately or after many years is left up to the plot requirements. Generally it seems that unused transporters will hold the last pattern they transported as long as their power supply is stable and are not travelling through space. Anything involving warp, fluctuating power, or transporting other people immediately clears the buffers (and can even cause transporter failures)