Doesn't backup MYSQL on server backup

Virtualmin developers,

This might be a missconfig, but might be a bug too - in latest VM 3.65 GPL.

I am in the process of migrating my dedicated server to another one. So for first time, I decided to use VM gpl backup (so far I was using my own custom one).

I was running some pretty old VM gpl (didn’t notice what version), but all functions I needed were running just fine.

When I backed up for first time yesterday, I got no error messages.
The I successfully restored on the new server (VM 3.65 gpl).

Then I checked - all seemed to be fine except for the MYSQL database part of that virt.server. It was not there at all.

I thought might be my VM on the old server is too old and it doesn’t backup MYSQL at all.

So I read a lot, but since there is no clear instructions (step by step) how to upgrade VM gpl from old to latest version, I installed VM 3.65 gpl over the old version on the old server.

I backed up again - the same issue.

Maybe a config settting somewhere, but I couldn’t find it (and I don’t expect to have a problem considering the automated VM install via the Webmin admin).

So I dove deep into the code and found that in …/virtual-server/, sub backup_mysql(), you are using two "techniques" to match which databases belong to the virt.server being backed up:

#1: Not sure what exactly is this "Wildcard for additional allowed MySQL databases":

[code:1]local $wild = &substitute_domain_template($tmpl->{‘mysql_wild’}, $[0]);
if ($wild) {
$wild =~ s/%/.*/g;
$wild =~ s/
@dbs = grep { /^$wild$/i } @alldbs;

#2: [code:1]push(@dbs, split(/\s+/, $_[0]->{‘db_mysql’}));[/code:1]

In my case, I don’t have #1, and in #2, $_[0]->{‘db_mysql’} is empty, so that is no MYSQL database gets backed up.

I am not sure exactly how $_[0]->{‘db_mysql’} is formed. Are you actually reading the “db” table in “mysql” database to obtain which database belongs to the virt.server account?

Because that is the best way to get the correct list of databases.

Post edited by: kvguser, at: 2009/02/17 01:21

Post edited by: kvguser, at: 2009/02/17 01:38<br><br>Post edited by: kvguser, at: 2009/02/17 01:39

Virtualmin keeps a list of the databases owned by a given Virtual Server. As the backup loops through each Virtual Server, it backs up all the associated databases.

When you log into Virtualmin, and choose the Virtual Server that owns the database from the select list on the top-left, and then click “Edit Databases” – does that database that’s not backed up show up there?

You are completely right - it is my fault.

My databases were created from within "MYSQL Database Server", as opposed to being created from the particular virt.server screen with "Edit databases".

Thus they have never been associated with the particular virt.server.

I should have paid more attention.

Thank you for your timely support - it is really amazing you do all this.

In aces you make my mistake - creating databases you "think" belonging to particular virtual server, but actually disassocaited (not visible in the particular virt.server "Edit Databases" list), or you by mistake disassociate a DB froma domain, here is to fix it very easily and quickly:

  1. in VM – MYSQL Server – copy the name of the DB you want to associate with a particular domain

  2. find /etc/webmin/virtual-server/domains -name "*"|xargs grep -i ""
    The resulting file (e.g. /etc/webmin/virtual-server/domains/11702163329455546 ) is the name of the config file for the desird domain in VM

  3. edit this file by adding the name of the DB on line
    (if some domain names already - separate by space)

  4. save the file