Backup of alias servers fail if you rename the admin username

A couple of times I have created a primary server 'foo.bar.com' and the automatic admin username was created as 'foo'. I didn't want 'foo', so I renamed the username to 'fooweb'. The completes successfully and changes the user home directory from '/home/foo' to '/home/fooweb'.

After this backups for the primary server still works fine, however the backups for any aliases fail. This appears to be because the alias backups still try to create the '.backup' folder in the old home folder location that would have existed before the username changed from 'foo' to 'fooweb':

Creating backup for virtual server foo.bar.com ..
.. failed to create temporary backup directory /home/foo/domains/aliasname/.backup : mkdir: cannot create directory '/home/foo/domains/aliasname/.backup': No such file or directory

I guess this is a bug with the username renaming algorithm. I am currently running 6.01-3, but it could have been an slightly older version from a couple months back when I renamed the usernames affected by this problem.

In the meantime, can I manually correct this? Where is the old backup location being stored that the backup script is picking up? I couldn't spot where in /etc/webmin that might be found?

Status: 
Fixed (pending)

Comments

I've just run into this same bug on Centos 7. A few weeks ago I renamed an account and since then backups have been failing with the following:

failed to create temporary backup directory /home/[OLDUSERNAME]/domains/[example.com]/.backup : mkdir: cannot create directory '/home/[OLDUSERNAME]/domains/[example.com]/.backup': No such file or directory

So the fix for this for me was to grep for the old username in /etc (grep -ril "oldusername" /etc) and then go through each of the resulting /etc/webmin/virtual-server/domains/* files, correcting the username in the following values:

group= home= ugroup= creator= user=

and I'd also renamed the domain, so the old domain name was still stored in these:

backup_parent_dom= backup_alias_dom=

There was also the /etc/webmin/virtual-server/map.user file which had the id's of the alias domains still mapped to the old username, so I fixed that too.

Backup now seems to be running correctly.

Ilia's picture
Submitted by Ilia on Thu, 05/06/2021 - 15:29

Hi,

Thanks for your report!

I've just run into this same bug on Centos 7. A few weeks ago I renamed an account and since then backups have been failing

Can you tell us, how exactly did you rename your account?

So, from memory, the steps I took were:

1) Create a new top level server (server1.foo.com, admin username 'foo', home directory /home/foo/). 2) Create an alias sub-server of server1.foo.com (server2.foo.com) 3) Use 'Server Configuration' -> 'Change Domain Name' to change server1.foo.com to server1.bar.com and admin username to 'bar' and the home directory to /home/bar/

After this, the parent server is renamed correcty and the sub-server is still server2.foo.com (as expected) however I would have expected the 'username' of the sub-server to have changed from 'foo' to 'bar' since sub-servers (as far as I know) always share the parent server username. I'd also have expected the other domain configuration file values to have updated (group= home= ugroup= creator= user= backup_parent_dom= backup_alias_dom=) but they all still use the old 'foo' username/group/domains.

Because these weren't updated, the scheduled backup for the sub-servers failed with something like:

failed to create temporary backup directory /home/foo/domains/server2.foo.com/.backup : mkdir: cannot create directory '/home/foo/domains/server2.foo.com/.backup': No such file or directory

The directory it should have course been trying to create would be /home/bar/domains/server2.foo.com/.backup

Looks like maybe something is missing or going wrong in this loop? https://github.com/virtualmin/virtualmin-gpl/blob/master/virtual-server-...

Thanks for the detailed report - I'll looking into the code now.

Ok I see the bug that causes this - it will be fixed in the next Virtualmin release.