Name clash when restoring virtual server

I think I need a better understanding of the backup/restore process. But I cannot find it in the documentation.
This is the situation.
I run a mail server. One of the domains hosted is abc.com
I have a live backup server. I make backups on the mail server and send them to the backup server.

When I installed and tested the backup/restore I created a backup on the mail server. Sent it over to the backup server.
Then I restored the domain on the backup server. All went fine.

Now in the process of regularly testing your backup and restore procedure I tried to restore the back again. This resulted in the infamous error message while restoring the domain abc:

a clash was detected : A unix user named abc already exists - try selecting a different administration username

I assume that at the original test restore I selected the option Re-allocate UIDs and GID. Because on both systems the users exist, but with different UID and GID:

On the mail server:

drwxr-x— 13 1016 1005 4096 Jun 15 07:00 abc

And on the backup server:

drwxr-x— 12 1011 1003 4096 May 24 2016 abc

This is somewhat understandable. The user abc must exist on both systems because the domains exist. I assume this administrative user must exist when the domain exist.

It is also logical that the UID and GID are different. The domains on both servers were created in a different sequence.

What I actually want is this. I have the backup server running. Fully configured with all users and all domains. When the main server crashes, I want to do a restore of the latest backup, switch the DNS entry at the name server and continue.

So how do I achieve that? Should I delete all the domains on the backup server and all the administrative users? And then do a restore while not re-allocating UID’s?

Or must I keep the back-up server without any domains and just restore and create the domains when the main server crashed? But how to I make sure the backup/restore can be tested?

How can I overcome the current situation? Delete the domains? Will that delete the administrative users as well? Or delete the domains and the users by hand? And then recreate the domains? Is this the same as the restore option Delete and recreate virtual servers?

I have some created some users outside Virtualmin on the mail server. Not all of them exist on the backup server. In other words: if I do a restore using the same UID on the backup server, there will be no conflict with non-virtualmin users.

Since this should be a common problem with the setup I have, and I don’t see many problem reports, do I do something unusual or stupid?

jlinkels

So, restoring a domain expects that domain doesn’t already exist on the system. So, yes, you’d need to delete the domain before doing another test of your restore process.

In other words: Yes to your question about deleting the domain before restore. You can’t restore over an existing domain on your backup system.

Re-allocate UIDs and GIDs is orthogonal to your problem. You can decide whether you want your UID/GIDs to match on the restored server (I like for them to, because sometimes I have other archives or backups of things not under the control of Virtualmin that expect the UID/GID to match). But, Virtualmin restored domains should work fine either way (that’s why it has the feature, so you can restore onto a system that may already have allocated the UID/GID you want. They don’t matter much.

But, UID/GID is not what is clashing here, so it isn’t related to your problem. The clash is that you already have an abc user; UID/GID could be anything and that clash would still exist.

So…for testing backups, I delete the domain and then restore it again on my test machine.

If I want a “hot spare” or a load balanced identical system, I’ll come up with another method for keeping the data in sync. There are so many sevices on a stock Virtualmin system that can be problematic with data syncing.

e.g. you can’t simply copy a live/active MySQL database; you can’t rsync it, either. To have a live duplicate of a MySQL database you have to use the MySQL replication features (which is beyond the scope of Virtualmin at this time, maybe forever, because it’s always so specific to the deployment and messing it up can be dangerous). This is true of any database, really. You need a plan for the database that accounts for this fact, if you want a hot spare or a load balanced replica.

Likewise, while Maildir can be rsync’ed safely (one of the reasons it’s so great as a mail spool format), you might lose recent mail if you switch to a backup server after the last sync (though you may be able to recover it if your primary can be brought back online).

Hmmm, I expected to receive an e-mail notification when a comment was posted, but I didn’t see anything. Hence my late reply.

OK, so bottom line is to delete the domain before restoring. It is the user “abc” which clashes. Not because the UID is different. I am going to try that.

I wonder what then will happen when I restore an incremental backup. Then there can be no deleting the domain before restoring. Apparently that information is contained in the incremental backup data?

The problem is not to keep a hot standby to which I can switch over seamlessly. Even if I did, I still would need the backup/restore in place like I have it now. If a user accidentally deletes his/her mail it should not be deleted at the same time on the standby server. I think I have seen VM making a MYSql dump while backing up, so that is fine for the periodic backups.

OT: I have been using MYSql replication to keep live databases in sync. Not in this project. That works fine. Even master-master replication can be set up. Which works fine. But while loss of sync in master-slave can be resolved easily, it is a nightmare in master-master replication. But that is beyond VM anyway.

Let me try your suggestions. Thanks for replying.

Delete the domain before restoring. As simple as that.

jlinkels