In place migration from FreeBSD to Linux

jerrybell

Well-Known Member
Nov 27, 2006
90
0
156
I am rebuilding a FreeBSD server to centos. What is the best way to transfer cpanel accounts from the old server to the new server? centos is being installed on new drives and I'll be able to mount the old drives to perform data transfer. It's not clear to me what the best way to perform a restore is, though. Should I run the "restore a full backup/cpmove file"?

Thanks,

Jerry
 

jerrybell

Well-Known Member
Nov 27, 2006
90
0
156
So, the migration is complete. I thought I'd follow up to my own question...

My dedicated server provider let me keep my the server old drives and added a new one to install centos on, so I could copy data over without having to restore from an offline backup. Since I was on FreeBSD and moving to Linux, I knew I was in for some fun mounting UFS (BSD) formatted drives in Linux. To make things easy for myself, I took a spare drive on the system and under freebsd, I formatted it as an ext2 filesystem. I mounted it and copied over my site backups (/var/backups/cpanel/...) to the new ext2 formatted drive. I set the backup directory in cpanel to that new hard drive and ran another backup for good measure. Cpanel complained about not being able to set certain access time parameters on the files due to limitations with ext2, but it did not impact anything.

My provider shut down the server, installed a new drive and installed centos. I was able to tell pretty easily which drive was my backup drive - fidsk -l showed me 3 drives, 2 formatted as UFS. I think that's a misinterpretation, since the second drive was actually formatted as ext2, but I think fdisk is just reading the partition table, which likely indicates it was FreeBSD that partitioned the drive. I am glad I did this since I was not able to mount the UFS formatted main FreeBSD drives. Allegedly it can be done using a kernel mod package for centos, but I wasn't motivated enough to try to figure it out.

I opened whm and went to restore backups. After some reading, I learned that I needed to go into the backup configuration and change the directory to point to my ext2 drive (makes sense). I went to restore and whm was not seeing any of my backups. The was pretty disconcerting. I did a bunch more reading and learned that I had to basically set the backup configuration to match almost exactly what it was under FreeBSD. In particular, I had to enable "incremental backups". Without that, Cpanel is looking for single files per account, rather than the directories per account I had.

Once I did that, all of the accounts appeared available to restore. I was able to restore using the "restore multiple accounts" tool without much problem. Pretty fast and painless.

I did have one big issue, though... One of the accounts has pretty large mysql databases. Upon checking to make sure that site was functional, I found that it, of course, was not. I did some poking and found that the account's database tables weren't restored. I went into the backup directory and found that the tables for that site were not being backed up for some reason. Actually, there was a file had the database name, but it was a pretty small size. A few hundred kb, when the database should have been about 3.5GB. After a big of swearing I was about to call my provider and as them to shut down the server and flip drives so I could copy tables, I poked around in the backup directory and found a copy of the tables from the /var/db/mysql directory tucked away in .../dirs/_var_db_mysql on my ext2 backup drive. I copied those tables by hand into /var/lib/mysql/... and changed ownership to mysql and viola! all was good. I didn't see any other database backup issues. So, that is something I am going to be looking at in the coming days. Possibly the sql dump function craps out on very large tables... Don't know yet.

One other important point to note: none of the general WHM settings are backed up/restored. I had to go through and reconfigure exim, apache, etc, etc. That's not terribly surprising, but in case anyone is curious, I wanted to make it explicitly clear because I couldn't find that answer when I was searching prior to my migration.
 

JaredR.

Well-Known Member
Feb 25, 2010
1,834
27
143
Houston, TX
cPanel Access Level
Root Administrator
I apologize that I did not notice this thread sooner. In your case, you had good cPanel backups, but to anyone who wants to transfer accounts and may not have backups, we always recommend using the transfer tools in the WebHost Manager. Trying to copy accounts from a hard drive without good cPanel backups can be very frustrating and we cannot directly help with this.

This is the advice we usually give to customers looking to migrate from one server to another:

You can copy /etc/wwwacct.conf and /var/cpanel/cpanel.config, as well as the EasyApache build profile, to the new server. This will copy most of your important server settings, and will make sure that cPanel and Apache are configured the way they are on the old server. Once this is done, use our cPanel transfer tools to transfer your accounts to the new server.

I want to mention that there are many how-to guides online in forums, blogs and other sources that recommend using rsync to copy all of your files from one server to another. Please do not do this. Using rsync sounds great in theory, but in reality, it almost always ends up copying bad configurations and even corrupt files. We see many problems caused by following tutorials that involve rsync. We do not recommend or endorse any solution involving rsync, and we cannot support any damage that may be done by using rsync to copy files indiscriminately between servers.*

Our installation documentation actually addresses this subject in some detail:

Advanced Options: Pre-Installation

You can copy /var/cpanel/cpanel.config on the old server to /root/cpanel_profile/cpanel.config before you even install cPanel on the new server. If cPanel is already installed on the new server, simply copy /var/cpanel/cpanel.config from the old server to /var/cpanel/cpanel.config on the new server. Use scp or any other method you are comfortable with to copy the file. Then, copy /etc/wwwacct.conf from the old server to the new server. These two files contain the majority of the settings in your WebHost Manager and cPanel configuration.

You can also copy your EasyApache build profile, so that Apache and PHP will be built on the new server just like on the old server. The following section of our documentation explains how to do this:

Configuring Apache Pre-Installation

You can copy the EasyApache build profile either before or after you install cPanel on the new server. If you do it after cPanel is installed on the new server, remember that you will need to run EasyApache separately so that Apache and PHP will be built with the profile you copied.

Once the cPanel settings have been copied and EasyApache has been run with your build profile, you can use our transfer tools to copy your accounts. On the new server, in the WebHost Manager, click Main
>> Transfers >> Copy multiple accounts/packages from another server. The new server will log into your old server, package your accounts, and copy them over. The transfer tool is documented here:

Copy Multiple Accounts/Packages from Another Server

* The lone exception to this is very large accounts, several gigabytes or more. In the case of very large accounts it can be better to use /scripts/pkgacct with the --skiphomedir argument to package everything related to the account except its home directory, copy the package to the new server, restore it on the new server, and then use rsync to copy the account's home directory. This should only be done with exceptionally large accounts, though, because our transfer tools are very robust and normally work well for average-size accounts.