How to restore cPanel on your dedicated server!

Discussion in 'Linux & BSD' started by LordOfLA, Apr 14, 2007.

  1. LordOfLA

    LordOfLA Godlike!

    Maidenhead, Berkshire, UK
    I offered in the frontpage team to come up with some hosting targeted guides, so here's one I worked with on one of the customers of the datacentre I work at here in London.

    This will help you out in a number of ways.

    If your server has been hacked (very likely with the current favourite combo of Centos 4.4/cPanel neither of which are very good with security updates and running current patched builds).

    Your disk failed and ext3 keeps locking the machine up.

    I will assume you either have no backup, or an out of date backup or some critical work was recently performed.

    You will see alot of the so-called "third party managment" companies offering this service for around $50 a pop. Now based on what I have seen of the abilities of the so called "leaders" of this industry I think a newborn would stand a strong chance of doing a better job so be careful if you have a dedicated server and you are looking for a third party to assist with the day to day operations of your server.

    Most datacentres will do day to day managment for you but you are looking at a price at least 3 times higher than when left to fend for yourself.

    Any way on to the guide.

    You will need your datacentre to clean install your OS and cpanel on a new disk and install the original as a second disk (if you already have an additional disk they can remove it as you can repurpose your existing disk after following through with this.)

    If you are doing this as a result of a disk failure and the filesystem was ext3, you should mount the partition as ext2 to avoid having the ext3 journal code triggereing a kernel panic and killing the machine.

    The rest is just simple copy and paste (check man pages on commands for a detailed explanation of the options, for this guide I will simply say that the commands perform a recursive copy, overwriting existing files, maintaining permissions and ownership while forcing a yes reply to all "are you sure" prompts) :)

    First backup existing data

    cp -Rfpv --reply=yes /etc /etc_backup
    cp -Rfpv --reply=yes /home /home_backup
    cp -Rfpv --reply=yes /var /var_backup
    cp -Rfpv --reply=yes /usr/share/ssl /usr/share/ssl_backup
    cp -Rfpv --reply=yes /usr/local/apache /usr/local/apache_backup
    cp -Rfpv --reply=yes /usr/local/cpanel /usr/local/cpanel_backup
    cp -Rfpv --reply=yes /usr/local/cpanel-rollback /usr/local/cpanel-rollback_backup

    Now restore cpanel. /old_disk/ is assumed to be where to old disk is mounted adapt accordingly

    cp -Rfpv --reply=yes /old_disk/etc /
    cp -Rfpv --reply=yes /old_disk/home /
    cp -Rfpv --reply=yes /old_disk/var /
    cp -Rfpv --reply=yes /old_disk/usr/share/ssl /usr/share/
    cp -Rfpv --reply=yes /old_disk/usrlocal/apache /usr/local/
    cp -Rfpv --reply=yes /old_disk/usr/local/cpanel /usr/local/
    cp -Rfpv --reply=yes /old_disk/usr/local/cpanel-rollback /usr/local/

    Check that /usr/local/apache/conf/httpd.conf has all the virtual hosts listed. If not run the following:
    /scripts/rebuildhttpdconf >> /usr/local/apache/conf/httpd.conf
    Then do the following:

    /scripts/upcp --force
    /etc/init.d/ipaliases restart
    Login to whm and rebuild apache.

    Check everything works

    You have now saved yourself $50 or you can pay me $50 to perform the same copy and paste job that you can :D
    Last edited: May 25, 2007
    Grandmaster likes this.
  2. Grandmaster

    Grandmaster Electronica Addict Political User Folding Team

    Santa Clara, CA
    Great start Mark :D

    I'm sure there are many people that there that will find this very useful.
  3. LordOfLA

    LordOfLA Godlike!

    Maidenhead, Berkshire, UK
    Glued for easy access in the event the frontpage gets its guides section :p