Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Page 1 of 4 1 2 3 ... LastLast
Results 1 to 15 of 57
  1. #1
    Member
    Join Date
    May 2004
    Posts
    48

    Question Clone Server-A to Server-B

    I have some very old server hardware that runs my cPanel instance, and it's giving me major problems. I will be installing a new server this weekend. What is the proper proceedure for cloning an entire cpanel server? I don't mean just the accounts, I mean all the DNS, mail, http etc info as well. I don't want to lose anything. This server is also my primary and secondary nameserver for all my customer domains.

    -Should I use Ghost to image the drive?
    -Should I install the OS & cPanel on the new server, and copy over specific directories?
    -Should I do something else?

    All comments appreciated.

    Thanks,

    Sean

  2. #2
    cPanel Partner NOC cPanel Partner NOC Badge cyon's Avatar
    Join Date
    Jan 2003
    Posts
    323

    Default

    I wouldn't recommend to clone your harddrive 1:1, because you have different hardware installed and so on.
    I would install a fresh OS, then install cPanel, then do all settings like you have on your current machine (same dns settings and so on.)
    Then I would use the account copy function and copy all accounts over.
    DNS entries, httpd.conf entries etc will be created on the new machine during the copy process.

  3. #3
    Member
    Join Date
    May 2004
    Posts
    48

    Default

    How am I to know which files need to be copied in order to duplicate my system though? I mean, what if I forget somebody's SSL key or something? There is no list of directories that need to be copied anywhere? I find it hard to believe that I am the only person that has run into a problem before where a component has died and you need to build a new server!

  4. #4
    Member
    Join Date
    Jan 2005
    Posts
    30

    Default

    Hi -

    I would take the same road as cyon. I have done this several times as I evolve my hosting platforms and other than a few hicups such as losing a whm package or a lost dns zone I have had not had any problems at all!

    Cloning the drive and OS would be a VERY bad idea in my opinion and the account importation feature will definitely cause you much less aggro as apposed to cloning. If there are any account importation problems such as a "missing ssl key" as you suggest then I'm sure these hicups will be nothing that can't be fixed by a competent system administrator in which I must stress that cPanel/WHM is no substitute.

    Good luck!!

  5. #5
    Member
    Join Date
    Sep 2004
    Posts
    422

    Default

    Hello,

    If you run cPanel backups, you will see

    /$backup/cpbackup/daily/files

    /$backup/cpbackup/daily/dirs

    These 2 directories contain all the config files required to restore the accounts onto another server, once cpanel has been installed onto it.

    Simply untarring those files and dirs or rsync them directly from the root file system, and use rsync to transfer them to the new server.
    This is much quicker and less errors than using the whm account copies.

    The users /home files can be extracted from /$backup/cpbackup/daily/user.tar.gz or directly from /home of course

    Then copy the $user/homedir to /home/$user

    I have written and posted scripts to do this on this forum

    Will you be using the same IP's on the new box?

  6. #6
    Member
    Join Date
    May 2004
    Posts
    48

    Default

    Quote Originally Posted by DigitalN
    Hello,

    If you run cPanel backups, you will see

    /$backup/cpbackup/daily/files

    /$backup/cpbackup/daily/dirs

    These 2 directories contain all the config files required to restore the accounts onto another server, once cpanel has been installed onto it.

    Simply untarring those files and dirs or rsync them directly from the root file system, and use rsync to transfer them to the new server.
    This is much quicker and less errors than using the whm account copies.

    The users /home files can be extracted from /$backup/cpbackup/daily/user.tar.gz or directly from /home of course

    Then copy the $user/homedir to /home/$user

    I have written and posted scripts to do this on this forum

    Will you be using the same IP's on the new box?

    Yes, I will be using the same IP. It's just odd to me that there isn't a already a defined process that everyone can follow. Thanks and I will look for your scripts

  7. #7
    Member
    Join Date
    Sep 2004
    Posts
    422

    Default

    You should be able to modify this for your needs - I usually have 2 machines online, the new machine up on an IP that isn't used on the old server.

    Then once copied over, I just switch the main IP on the 2 servers, then reboot them (at the same time), so they have the correct eth0 IP and are still online and you can access both servers still. Make sure to disable ipaliases (chkconfig ipaliases off) or remove the additional IP's on the source server too before rebooting. /etc/ips contains them usually, check for any ifcfg-eth0$alias) files in /etc/sysconfig/network-scripts/ though to be sure.

    /etc/sysconfig/network-scripts/ifcfg-eth0
    /etc/sysconfig/network
    /etc/hosts
    /etc/resolv.conf
    are the files needed to switch and make sure are correct before rebooting.

    Code:
    #!/bin/sh
    # /////////////////////////////////////////
    # //      SG 09/2004 CPanel              //
    # //    CPanel transfer config script    //
    # /////////////////////////////////////////
    #
    # HOST = User + IP / Hostname to copy files TO.
    # All files copied from this server to the destinations server.
    # Use this iscript to transfer THIS server to a new server.
    HOST="root@$1"
    EMAIL="your@email.com"
    if [ "$1" == "" ]; then
    echo "Usage: $0 IP"
    echo "Example: $0 123.123.123.123"
    echo "Will remotely transfer all files from THIS server over to this server IP 123.123.123.123"
    exit 1
    fi
    echo "	WARNING - YOU ARE GOING TO COPY FILES FROM THIS SERVER TO $1"
    echo "  THIS WILL OVERWRITE THE FILES ON THE REMOTE HOST AT $1 !!"
    echo ""
    echo "	Is this correct? Enter y/n"
    read confirm
    if [ "$confirm" == "n" ]; then
    echo "	User aborted. Type y to transfer files."
    exit 1
    elif [ "$confirm" == "N" ]; then
    echo "  User aborted. Type y to transfer files."
    exit 1
    elif [ "$confirm" != "y" ]; then
    echo "	Sorry I don't know what you neeed, enter y or n"
    exit 1
    else
    # /etc User / IP's + passwd files
    rsync -avz -e ssh /etc/passwd $HOST:/etc/
    rsync -avz -e ssh /etc/shadow $HOST:/etc/
    rsync -avz -e ssh /etc/group $HOST:/etc/
    rsync -avz -e ssh /etc/wwwacct.conf $HOST:/etc/
    rsync -avz -e ssh /etc/quota.conf $HOST:/etc/
    rsync -avz -e ssh /etc/domainalias $HOST:/etc/
    rsync -avz -e ssh /etc/remotedomains $HOST:/etc/
    rsync -avz -e ssh /etc/reservedipreasons $HOST:/etc/
    rsync -avz -e ssh /etc/reservedips $HOST:/etc/
    rsync -avz -e ssh /etc/secondarymx $HOST:/etc/
    rsync -avz -e ssh /etc/localdomains $HOST:/etc/
    rsync -avz -e ssh /etc/userdomains $HOST:/etc/
    rsync -avz -e ssh /etc/valiases $HOST:/etc/
    rsync -avz -e ssh /etc/vfilters $HOST:/etc/
    rsync -avz -e ssh /etc/vmail $HOST:/etc/
    rsync -avz -e ssh /etc/tru* $HOST:/etc/
    rsync -avz -e ssh /etc/ips $HOST:/etc/
    rsync -avz -e ssh /etc/domainips $HOST:/etc/
    rsync -avz -e ssh /etc/services $HOST:/etc/
    # ftpd files
    rsync -avz -e ssh /etc/sysconfig/pure-ftpd $HOST:/etc/sysconfig/
    rsync -avz -e ssh /etc/pure-ftpd.conf $HOST:/etc/
    rsync -avz -e ssh /etc/pure-ftpd $HOST:/etc/
    rsync -avz -e ssh /etc/proftpd $HOST:/etc/
    rsync -avz -e ssh /etc/proftpd.* $HOST:/etc/
    # /var
    rsync -avz -e ssh /var/cpanel $HOST:/var/
    rsync -avz -e ssh /var/spool/cron $HOST:/var/spool/
    
    # /usr config - 3rdparty
    rsync -avz -e ssh /usr/share/ssl $HOST:/usr/share/
    rsync -avz -e ssh /usr/local/cpanel $HOST:/usr/local/
    
    # Apache
    rsync -avz -e ssh /usr/local/apache/conf $HOST:/usr/local/apache/
    rsync -avz -e ssh /usr/local/frontpage $HOST:/usr/local/
    
    # Mysql config
    rsync -avz -e ssh /root/.my.cnf $HOST:/root/
    rsync -avz -e ssh /etc/my.cnf $HOST:/etc/
    
    # Named
    rsync -avz -e ssh /var/named $HOST:/var/
    rsync -avz -e ssh /etc/named.conf $HOST:/etc/
    rsync -avz -e ssh /etc/rndc.conf $HOST:/etc/
    
    #User Files
    # Mysql
    rsync -avz -e ssh /var/lib/mysql $HOST:/var/lib/
    #rsync -avz -e ssh $HOST:/var/lib/pgsql $DIR/var/lib/
    
    for SITE in `ls /var/cpanel/users`
    do
    rsync -avz -e ssh /home/$SITE $HOST:/home/
    done
    date | mail -s "Restore completed for $HOST" $EMAIL
    fi
    exit 0
    If you are doing the scenario above, have 2 machines online at once then transfer the files, this would be the best method (for me anyways)

    You need to install cPanel, any custom apache modules, update php with your options etc on the new server first - then run the script on the source server, to copy the files from the source server to the destination server.

    chmod +x script

    ./script 123.123.123.123 (your destination servers IP)

    You may also want to setup ssh keys on the servers too - to save the password prompts while transferring files

    on the source server

    ssh-keygen -t dsa

    Accept the defaults

    Then

    scp /root/.ssh/id_dsa.pub root@123.123.123.123:/root/.ssh/authorized_keys (make the directory /root/.ssh on 123.123.123.123 if it doesn't exist, and chmod it 700)

    Then ssh into the box at 123.123.123.123 - no password.

    A /scripts/upcp is probably recomended after the transfer of files and one more reboot won't hurt, to make sure all services are running correctly.
    Last edited by DigitalN; 12-05-2006 at 03:09 AM.

  8. #8
    Member
    Join Date
    May 2004
    Posts
    48

    Default

    Awesome!
    Thank you very much for posting this. I will try this out over the weekend and then post my response here!

    -Sean

  9. #9
    Member
    Join Date
    May 2004
    Posts
    48

    Thumbs up Success!

    This script worked GREAT. Everything went a lot smoother than I thought. It took about 2 hours total. Here's exactly what I did:

    1) Install cPanel on new server (server2) - don't run the web config wizard yet.
    2) Set cPanel IP on server2 and give server1 a different one.
    3) Set up some ssh keys for server1 > server2 using ssh-keygen.
    4) Run the script from server1.
    5) Run the web config wizard on server2.
    6) Update Kernel using up2date
    7) Check /etc/localdomains /etc/hosts and /etc/resolv.conf for consistancy
    8) Reboot

    That's it!
    Thanks so much for this script. I didn't have to change it at all.
    This should be a sticky!!!

    -Sean

  10. #10
    Member
    Join Date
    Sep 2004
    Posts
    422

    Default

    I'm glad that went smoothly for you Sean.

  11. #11
    Registered User
    Join Date
    Mar 2004
    Posts
    4

    Default Switching IP's

    I'm interested in migrating servers in this method as well, however, I don't have the ability to swap ip's.. is this needed, or is there any way around this?

  12. #12
    Member
    Join Date
    May 2004
    Posts
    48

    Default

    Quote Originally Posted by hyborian
    I'm interested in migrating servers in this method as well, however, I don't have the ability to swap ip's.. is this needed, or is there any way around this?
    When you set up cPanel, just set it up with whatever new IP you're going to use. I suppose you'll have to run through all the files you copied and replace the old IP with the new one.

    -Sean

  13. #13
    Registered User
    Join Date
    Mar 2004
    Posts
    4

    Default

    alas I didn't set up cpanel, the colo provide did. :-/

  14. #14
    Member
    Join Date
    Jul 2004
    Posts
    41

    Default

    Quote Originally Posted by DigitalN
    You may also want to setup ssh keys on the servers too - to save the password prompts while transferring files

    on the source server

    ssh-keygen -t dsa

    Accept the defaults

    Then

    scp /root/.ssh/id_dsa.pub root@123.123.123.123:/root/.ssh/authorized_keys (make the directory /root/.ssh on 123.123.123.123 if it doesn't exist, and chmod it 700)

    Then ssh into the box at 123.123.123.123 - no password.
    If it doesn't connect, type:
    /sbin/service sshd restart

    on both servers. I almost pulled my hair out over that one.

    I have a question, though.
    I'm installing to a new server, from Fedora Core 2 to CentOS 4.1. I ran the script, and everything copied over, but the IP addresses did not come up. During boot, it said it was bringing them up, but they were inaccessible. Did I miss something?
    Last edited by Biotron2000; 08-17-2005 at 02:32 PM.

  15. #15
    Member
    Join Date
    Sep 2001
    Posts
    315

    Default

    Is this script transfering also the reseller account settings?

    Or is any other thing missing?

    Michael

+ Reply to Thread
Page 1 of 4 1 2 3 ... LastLast
Similar Threads & Tags
Similar threads

  1. Filed with Developers Clone Server Configuration [Case 42206,52043]
    By cPanelDavidG in forum Feature Requests for cPanel/WHM
    Replies: 74
    Last Post: 01-28-2012, 03:17 AM
  2. Clone WHM/cPanel Config Settings to New Server(s)
    By Sir William in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 01-21-2011, 01:53 AM
  3. FormMail Clone using 'From:' webmaster@hostname.server.com
    By scorpio1 in forum E-mail Discussions
    Replies: 1
    Last Post: 08-03-2008, 06:01 AM
  4. Clone a cPanel server
    By SeanLee in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 11-06-2004, 01:43 PM
  5. Change master name server from server 1 to server 4
    By Curt in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 10-16-2002, 02:45 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube