How-to: cPanel to Directadmin migration

To increase it in DA to 16, for example, you can simply run:
Code:

/usr/local/directadmin/directadmin set max_username_length 16 restart

* To make sure your MySQL username/database name is fine, I’d suggest upgrading your MySQL/MariaDB on the server (https://www.directadmin.com/features.php?id=2294), MySQL 5.7+ or MariaDB 10.x is recommended.
* I’d suggest trying it with 1 account first, most preferably – the one with the longest database name/username (guide for this in 2nd post) to make sure you have the nameservers you need and that you don’t hit any limitations 

* If you have user.tar.gz instead of cpmove-user.tar.gz, it will not work! pkacct forms cpmove-users.tar.gz. If you have a list of user.tar.gz files, and want to rename them all in current directory:
Code:

for i in `ls *.tar.gz | grep '^[A-Za-z0-9]*.tar.gz'`; do { mv -vf ${i} cpmove-${i}; }; done

* If you have backup-…._user.tar.gz instead of cpmove-user.tar.gz, it will not work! pkacct forms cpmove-users.tar.gz. If you have a list of backup-…._user.tar.gz files, and want to rename them all in current directory:
Code:

for i in `ls backup-[0-9]*.*.tar.gz`; do { USERNAME=`echo $i | cut -d_ -f3 | cut -d'.' -f1`; mv -v $i cpmove-${USERNAME}.tar.gz; }; done

* If you don’t see the user in “Move users between resellers” list, please apply: https://help.directadmin.com/item.php?id=251
* If you did not restore resellers first, all users were assigned to “admin”. If you want to re-assign them to correct resellers after restore:
Code:

cd /home/admin/all_backups
for i in `ls user*.tar.gz`; do { RESELLER=`echo $i | cut -d. -f2`; USER=`echo $i | cut -d'.' -f3`; /usr/local/directadmin/scripts/move_user_to_reseller.sh $USER admin $RESELLER; }; done
echo "action=cache&value=showallusers" >> /usr/local/directadmin/data/task.queue
/usr/local/directadmin/dataskq d

To increase it in DA to 16, for example, you can simply run:
Code:

/usr/local/directadmin/directadmin set max_username_length 16 restart

MIGRATION STEPS:
Steps to transfer ALL the accounts from cPanel server to DirectAdmin:
cPanel server:
1) Create a backup of all cPanel accounts on cPanel server and place them to /home/all_backups (make sure you have enough of space for them, if not, please read the suggestions at the end of the article):
Code:

mkdir -p /home/all_backups
for user in `ls /var/cpanel/users/`; do { /scripts/pkgacct ${user} /home/all_backups; }; done

2) Transfer /home/all_backups to DirectAdmin server:
Code:

rsync -avt --delete /home/all_backups/ root@your_directadmin_server.com:/home/admin/all_backups/

We’re done with cPanel server now. Let’s connect to DirectAdmin server now.

DirectAdmin server:
1) Make sure your DirectAdmin version is at least 1.57.4 (as of time of writing, pre-release: https://help.directadmin.com/item.php?id=408), make sure backups at /home/admin/all_backups are owned by “admin” and that you have latest version of convertor script
Code:

cd /usr/local/directadmin/custombuild
./build update
./build cpanel_to_da
chown -R admin. /home/admin/all_backups

2) We finally have DirectAdmin backups in /home/admin/all_backups 

 Now we can simply go to DirectAdmin “Admin Backup/Transfer” section, check “Backup/Restore Settings” (defaults should be fine) in Admin level and restore all backups from “/home/admin/all_backups” directory. 

That’s it! 

—–
If you have enough of space, I’d suggest leaving /home/admin/all_backups still there on DA server for a couple of weeks/months, if there is something missing in DA – you’d always have it in that backup.

If your cPanel server doesn’t have enough of space – it’s easy transfer accounts one-by one directly to the home folder on a new server. The most convenient way to do this is to generate SSH keys on cPanel server using:
Code:

ssh-keygen

Then you’ll have your public key placed in /root/.ssh/id_rsa.pub. Just copy the content of it to your DirectAdmin server, file /root/.ssh/authorized_keys (if /root/.ssh directory does not exist – create it). This will make it possible to connect to DA server without any password (from your cPanel server). Now instead of steps 1) and 2) on cPanel server, just do this:
Code:

for user in `ls /var/cpanel/users/`; do { /scripts/pkgacct ${user} /home/all_backups; rsync -avt /home/all_backups/cpmove-${user}.tar.gz root@your_directadmin_server.com:/home/admin/all_backups/cpmove-${user}.tar.gz; rm -f /home/all_backups/cpmove-${user}.tar.gz ; }; done

 2,548 total views,  3 views today

Comments

So empty here ... leave a comment!

Leave a Reply

Your email address will not be published. Required fields are marked *

Sidebar