What happens if you Ctrl+C, Ctrl+V on the Doctor’s data files? Do you duplicate a sentient being?
In “Virtuoso”, Tom & Harry try to reproduce the Doctor but they’re basically trying to make him from scratch, so I don’t think their failure is relevant.
At the end of “Author, Author” we see many repurposed EMH Mk1s working as miners:

…and they seem to be self-aware, so I guess we have to assume that it’s technically feasible.
But then what happens if you Ctrl+Z?


I don’t remember the details, but they definitely mentioned that you can’t just copy the doctor. The real reason is, of course, so that there’s some actual tension when the doctor gets sent off the ship and to avoid having to deal with the ethical and philosophical issues that arise from that (it’s also probably just the writer of an episode shooting from the hip as usual), but if I’m allowed to switch over to my thick-framed glasses and come up with a plausible in-universe reason:
Perhaps in order to properly reproduce human-like intelligence, you need to take advantage of quantum phenomena, so the state of the doctor’s program is in a quantum state. And since it’s not possible to perfectly copy a quantum state without destroying the original (Nebula), even with a Heisenberg compensator that works very well, any movement of the state of the doctor from one device to another would have to be a “transfer” and not a “copy”.
However, even if the state of the program is in a quantum state, the program itself may not be. In present day attempts at quantum computing, the program itself is still written in plain old text. If that’s the case, it would be possible to create copies of the doctor in their initial state, without any memories or experiences, which explains the miners and the EMH on the Enterprise-E.
As for undo, it may be possible to undo removing something from the state of the program if the data doesn’t actually get destroyed but the program is just blocked from accessing it. Similar to how if you delete a file from a drive, it doesn’t actually the destroy the file, it just removes the entry from the file system, and if you’re fast enough you can often still restore the file.