Cannot move a virtual server to another server using Cloudmin, when that server was previously moved then renamed

Please see this forum post: http://virtualmin.com/node/30999#comment-124142--

I copied a virtual server from one server to another using Cloudmin. Then on the target system I renamed the domain, username, password, etc. to make it a new server.

When I go to move the same server again from the source to target server, it says:

"Failed to update Virtualmin domains : The selected domains cannot be moved : The domain mydomain.co.uk already exists on the target system"

But as stated the domain on the target system has been changed, and the username. I cannot see a reference to the domain I want to copy anymore.

Status: 
Active

Comments

If you search for that domain in Cloudmin (at Virtualmin Settings -> Virtualmin Domains), does it show as being on the target system?

It shows the domain on the source server as expected, but thats all. It does not list it on the target server.

I had a closer look at this, and it seems that the real reason is that a domain with the same Virtualmin unique internal ID already exists on the target system.

What was the history of this domain? I'm surprised that two domains with the same ID could exist on two different systems.

Its a virtual server we have a default website on it we use to clone to make other websites. I cannot recall how this virtual server came about, it is totally possible it originally existed as a customer website on another server (maybe even the target server), moved to the server it resides on, and we are trying to clone it back. Although why is its ID maintained when moving around, shouldnt it be given a new ID when moved to a new server, because if this clash issue? And when moving shouldnt it be checking the domain name exists not ID?

So was this domain created on a VM that was later cloned? That would explain why you could end up with multiple domains with the same ID.

At the moment this is a limitation of Virtualmin - once a domain is created, it always keeps the same ID even if backed up and restored.

Yes it would have been a new virtual server created somewhere but I cant say what server, we occasionally move sites to different servers because we use other websites as a basis to develop new ones.

What I would expect is when I move a server it allocates a new ID relevant to the server it is being moved to. What format is the ID in? Because if its just some sequential number like 1, 2 etc. then there is a huge possibility the ID will exist on other servers.

If I clone a server, will it create a new ID then? Because I can get around this bug by cloning the site, then moving that, IF the clone creates a new ID. And what if that ID exists when I move the new cloned site to the new server?

Yes, cloning will allocate a new ID. So you could get around this by cloning the site and then moving it.

But could the ID exist on another server? Or is the ID unique to that server or date/time or something?

I think moving a site to a new server should give it a new ID.

The generated IDs should be globally unique, as they are a combination of a timestamp, PID and random number.

I will look into an option to have a restore / move generate a new ID.