How is it possible to clone a running VM consistently?

Solution 1:

What you're talking about is called "hot-cloning," and doing such a clone will result in some level of inconsistency between the two copies. Every way I'm aware of, including the commercial and native implementations of hot-cloning involve taking a snapshot (in one form or another) and then cloning that. This freezes the disk at a certain point in time, so that your disk is consistent, but it does result in having a clone that's from a point in time in the past.

Solution 2:

By rights, the full process would be:

  1. Create a snapshot of the running machine; this frees up the underlying disk files and causes new data changes to be written to delta files
  2. Copy the main disk files to the new machine
  3. Create another snapshot of the running machine; this frees up the delta files and causes new data changes to be written to new delta files
  4. Copy the old delta files to the new machine
  5. Repeat until the delta files are small enough to copy that the time taken represents negligable changes to the source server
  6. Edit the clone's config file so it is aware of the copied delta files
  7. Merge the clone's delta files back into the clone's main disk file

Depending on the tool used to do the clone, it may not do the delta file loop, so you would end up with a clone based on the how the server looked at the start of the first snapshot.

Even if it does the delta loop, you will still technically end up with a clone that is momentarily behind the source server.

Really, the only way to make a clone that is an exact match of the source server is to take the copy while the source VM is powered down.