The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Upgrading / Migrating to a New cPanel Server

Discussion in 'General Discussion' started by ruzbehraja, Sep 5, 2012.

  1. ruzbehraja

    ruzbehraja Well-Known Member

    Joined:
    May 19, 2011
    Messages:
    383
    Likes Received:
    7
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Scenario:
    Server hardware is old. We want to shift to a new server keeping the IP's the same.
    Both machines have WHM / Cpanel latest version. Both have identical configurations and config files updated for both.

    Issue:
    After the Accounts are all pulled to the new server through WHM, the Datacenter has to be informed about the IP Switch from old to new server.

    This may take from 15 minutes upto a few hours for them to respond to the support ticket and actually do the switch. Or we could also schedule this for a fixed date / time in future.

    The Question:
    I wanted to know if there is an effective way of keeping the servers "synced" uptil the last few minutes before the switch.

    Mainly to ensure that MySQL, Email and Website data is updated and latest on the new server.

    - - - Updated - - -

    I read an interesting article at http://bobcares.com/blog/?p=97 which has exactly what I want.

    However, I was wondering whether rsyncing had any drawbacks.

    I was especially concerned about whether rsyncing, and repairing the databases was foolproof.

    I ask this, since I have seen a lot of threads with cpanel techs being apprehensive about using rsync.

     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    My advice is to avoid using rsync to synchronize data unless absolutely necessary. Instead, you should consider using the following option when transferring the accounts to the destination server:

    Express Transfer

    This will route traffic over to the destination server as soon as the account is transferred, provided the DNS for the domain names is handled on the source server.

    Thank you.
     
  3. ruzbehraja

    ruzbehraja Well-Known Member

    Joined:
    May 19, 2011
    Messages:
    383
    Likes Received:
    7
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Thanks for the info regarding rsync.

    I don't think the Express Transfer is for my scenario (or maybe I didnt understand it properly).

    But I wouldnt want any changes in the DNS, because I will be switching the IP and retaining the old IP anyway.

    So what Express Transfer would do is give all the domains a new IP and then after the old IP is switched to the new server, I would need to change all the A records back to the Old IP.

    Any other solution to keep the data synced would be appreciated.

    Thanks.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    This is the recommended solution because you can easily convert the accounts back to the original IP address when necessary via:

    "WHM >> IP Functions >> IP Migration Wizard"

    The IP Migration Wizard is documented at:

    IP Migration Wizard

    However, feel free to use another method if you find one that better suites your specific requirments.

    Thank you.
     
  5. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    You should only be worried about using rsync if you are rsycing without doing initial cPanel account transfers or doing it and copying over some files and folders that should never be copied (such as /var/cpanel/sysinfo.config file).

    Using rsync is detailed here but it's in the scenario where the old machine isn't able to do a regular cPanel transfer:

    http://forums.cpanel.net/f5/rsync-backups-160054.html#post671150

    So my suggestion is just to do WHM > Transfer area to copy all the accounts over first, then to rsync the data using the above as a guide.

    Since the new server won't be live yet, you should be able to confirm if everything is working properly before you push it live. You'll still have the old one able to be used if the new one fails, so I'm never certain why people claim rsync is a bad idea for someone who does know what they are doing in Linux. Anything you do can be a terrible idea in command line if you don't know Linux.

    Of note, if you use rsync and the new server ends up having issues, we won't support the issues created by rsyncing it. Please keep that in mind.
     
  6. ruzbehraja

    ruzbehraja Well-Known Member

    Joined:
    May 19, 2011
    Messages:
    383
    Likes Received:
    7
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator

    In my case, the DNS for the domains is not handled by the CPanel Server, it is handled at the domain registrar end.

    Thanks for your suggestions Tristan.

    Still looking out for some other solution.

    - - - Updated - - -

    Thanks. Yes, Even I had the same hunch. Doing the WHM Transfer and then rsyncing should work.

    I guess I will try this out and post accordingly.

    Ill change the local machine hosts files to test it out.

    Worst-case: the new server can be cleanly reinstalled.
     
  7. cPanelJared

    cPanelJared Technical Analyst
    Staff Member

    Joined:
    Feb 25, 2010
    Messages:
    1,842
    Likes Received:
    18
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Using the tools we provide for copying accounts is the only method we can support. As Tristan said, you can often use rsync, but it is best to use it only after using our tools, to make sure "last-minute" changes to data get copied over. However, we cannot provide direct support for any changes made using manual rsync commands.
     
  8. ruzbehraja

    ruzbehraja Well-Known Member

    Joined:
    May 19, 2011
    Messages:
    383
    Likes Received:
    7
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Completed the migration and IP Switch to retain the old IP.

    Besides some expected minor glitches everything was perfect. There was no data loss or data inconsistency.

    Let me summarize the steps.
    I would like to reiterate for any new readers that the rsync part is solely at your risk. You need to know linux commands to perform some of the functions.
    cPanel will NOT provide support for any damage caused by this method.

    If you are not comfortable, then DONT try these steps.

    Before you start, create backups.

    Step 1:
    Configured the New server with the same Cpanel / WHM settings as the old one. Some things need to be done manually while some files can be copied over.

    Step 2:
    Used the WHM Copy Multiple Accounts tool to copy all the accounts over to the new server.

    Step 3:
    Once the accounts are dumped, you need to keep them synced till the IP is changed.

    All the commands are to be performed on the NEW server.

    What I synced is:
    • Databases
    • Users home folders
    • mailman folders
    • some basic cpanel user files which change often

    Although I tried out replication, it worked successfully for a short while and then errors kept cropping up, causing the sync to stop.

    I found that copying the WHOLE /var/lib/mysql folder was the most reliable method of transferring sql.
    Do note that copying anything less than the WHOLE folder may cause databases to get corrupt.

    BEFORE Syncing the databases, you need to ensure that the databases are locked and read only.

    This can be achieved by going to the mysql console and typing:

    Databases were synced with the command:
    Note that in the above command I have not used the -u switch, since I felt that it was not updating the files properly, causing some databases to get corrupt.

    To remove the lock and resume normal database operations you can use:
    Users home folders were synced with:
    Note that in the above command I have used the --delete switch, to delete any files at the destination, which are not present on the source. If you do not put this switch, you will notice that if users on the live(old) server are deleting files, those files will still remain on the new server.

    Also note that in my case the old server had 2 disks - home and home2 while the new server only has home.
    Hence, both the commands need to be performed in that order only.

    This time the -u / --update flag was used to update changed files.

    Then i synced the following:
    Keep doing these often, till the IP is switched.

    Feedback welcome.
     
  9. ruzbehraja

    ruzbehraja Well-Known Member

    Joined:
    May 19, 2011
    Messages:
    383
    Likes Received:
    7
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Just bumping this thread because I realized that the rsync commands here have a mistake.

    These are the right commands:

    rsync -avuz -e ssh root@oldserverip:/etc/vdomainaliases /etc/vdomainaliases
    rsync -avuz -e ssh root@oldserverip:/etc/vfilters /etc/vfilters
    rsync -avuz -e ssh root@oldserverip:/etc/valiases /etc/valiases

    I also like to add the --stats tag to see how many files were really updated.

    Eg:

    rsync -avuz --stats -e ssh root@oldserverip:/etc/vdomainaliases /etc/vdomainaliases
     
    ElviCities likes this.
  10. gryzli

    gryzli Active Member

    Joined:
    Jul 23, 2012
    Messages:
    44
    Likes Received:
    5
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    Twitter:
    Why not shut down both mysql's instead of locking the databases ? ( This is what we do in such migrations )
     
Loading...

Share This Page