Migration from cPanel Backups fail (in migration-cpanel.pl)

Recently I installed the latest versions Webmin/VM GPL and attempted to migrate around 50 sites from cpmove-.tar.gz files. Initially, none of them worked. I tried from shell too. Seems like the script hangs forever and take up 95% or more memory and CPU, as watched with "top". I tried the larger ones (5 GB) as well as smallest ones (50 KB). Everytime, it seems like an infinite loop.

Finally, I ended up at in the migration-cpanel.pl script. By using echo/comment method, I was able to trace that the following commented out lines, around line 483, are causing the import process hang forever:

elsif ($got{'web'}) {
    # Just adjust cgi-bin directory to match cPanel
    local $conf = &apache::get_config();
    local ($virt, $vconf) = &get_apache_virtual($dom, undef);
#   &apache::save_directive("ScriptAlias",
#       [ "/cgi-bin $dom{'home'}/public_html/cgi-bin" ], $vconf, $conf);
#   &flush_file_lines($virt->{'file'});
    &register_post_action(\&restart_apache) if (!$got{'ssl'});
    &save_domain(\%dom);
    &add_script_language_directives(\%dom, $tmpl, $dom{'web_port'});
    }

Commenting out these three lines allowed me to migrate all of the accounts, although I had some problems with incomplete databases (restored).

I didn't try debugging the apache module/function because that is after all working for calls made from other parts of the system. What I think is that there are something wrong with the parameters being passed from here.

Please let me know how I can assist you further.

Status: 
Active

Comments

Sounds like Virtualmin is hitting a bug while parsing the Apache config for that domain.

Would it be possible for you to email me one of the cPanel backups that is failing to jcameron@virtualmin.com ? That way I can re-produce and fix the bug ..

Thanks for that backup file - however, I was able to restore it just fine on my system.

Have you made any other changes to the Apache config template, or are you just using the Virtualmin default?

Also, after the migration is complete, what is the output from the following command :

virtualmin validate-domains --domain whatever.com --all-features
Shanto's picture
Submitted by Shanto on Sun, 12/06/2009 - 13:03

At the time of occurance(s), I had the default Apache template (virtual-servers). Rest of the settings were in default state as far as I can recall.

At that time, I didn't have enough time to wait for reporting and getting this fixed. So, I went ahead to debug the scripts and then finally turned off those 3 lines. Thus, I was able to import around 50 sites. I still remember that I tried to migrate several cPanel backups (big and small) earlier and failed before I went ahead to debug this.

The problem went away later when I had customized the entire system which included the removal of cgi-bin rules and port 10000/20000 redirection rules in Apache template. I myself cannot reproduce the problem as of now.

Shanto's picture
Submitted by Shanto on Sun, 12/06/2009 - 13:05

The rules I removed from the template are as follows:

ServerAlias webmail.*
ServerAlias admin.*

(I think, having these in global config, and only once for all vhosts is more appropriate. This also prevents domain administrators from messing up their access to webmin. You can consider this for your upcoming builds, by the way.)

ScriptAlias /cgi-bin/ /home/*/cgi-bin/
<Directory /home/*/cgi-bin>
allow from all
</Directory>

(I don't need that.)

RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.*.com
RewriteRule ^(.*) https://*.com:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.*.com
RewriteRule ^(.*) https://*.com:10000/ [R]

(I made similar rules in /etc/httpd/conf.d/webmin.conf to serve all domains and to proxy port 10000/20000 for users behind nasty firewalls. Access to the control panel from firewalled hosts is something that cPanel offers. Please consider this for future builds as well.)

Please note, ScriptAlias is the directive that migration-cpanel.pl is getting stuck with. I will add this rule back in template when I get some idle time and report back if doing so reproduces the problem.

Ok, I would be interested to know if you can re-produce this, and if so exactly which template directive triggers it.