How-to: cPanel to DA migration

Hello Martynas,

Good work:)

Could you add also resellers' name servers for migration please?

Thanks,
Melih
 
Hello,

Ok. I have updated the ticket: 18341

I have also some requests about cpanel migration:) Sorry for this but it is very important to migrate all accounts without minumum issue. We will migrate 20000 accounts.

Tickets:
18397
18433

Thanks a lot,
Melih
 
Hello Martynas,

Good work:)

Could you add also resellers' name servers for migration please?

Thanks,
Melih

Done in 0.0.26:
Code:
* Fix DB renames in .sql files for long DB usernames (the ones renamed), some backup files had "CREATE DATABASE" and "USE [B]dbname[/B]" statements.
* Reseller NS1/NS2 get migrated.
* DB names with dots (cPanel allows them) get renamed to ones without dots.
 
hi, ay luck recevin this error during restore. Unable to restore database d3host_wp.sql to d3host_wp : ERROR 1273 (HY000) at line 33 in file: '/home/d3host/backups/backup/d3host_wp.sql': Unknown collation: 'utf8mb4_unicode_520_ci'

As we're getting more and more questions on how to use https://forum.directadmin.com/showthread.php?t=52792&p=280613#post280613, I've decided to write this article to make it clear :)

See the 2nd post if you'd just like to try it for a single or couple accounts.

FAQ for new customers:
http://forum.directadmin.com/showthread.php?t=58062&p=296460#post296460

---
Known issues:
* RoundCube data is converted from sqlite (like ./homedir/etc/domain.com/user.rcube.db) just since version 0.0.14, make sure you run the latest.
* cPanel mdbox is supported in ver. 0.0.7, but hasn't been tested very throughly.
* Mailman mailing lists do not get converted to majordomo mailing lists
* Please make sure it's you who created cpmove-user.tar.gz backup for security purposes, because at this moment we fully trust the content inside, thus available on admin level only. This might change later.
* DirectAdmin format for mysql usernames/databases is always username_database and username_user. cPanel has the same format, but due to max username/database length (https://forums.cpanel.net/threads/username-length-limits.630671/), is sometime shortens the username part in from of it. cPanel allows myusername_ to have a DB username with myuserna_. DA DB names/usernames always start with myusername_, changing this would create a mess, for example, you could have myuserna user owning myuserna_db1 and myusername user owning myserna_db2. The script converts username to be username in such cases, so, for some accounts you might need to change database username/name in wp-config.php or other files CMS uses. This should be rare though. Script output in such cases:
Code:
WARNING! us_wordpress cannot be owned by user, renaming database user to user_wordpress
* JetBackup format doesn't include cpmove-user directory inside, so, for now these need to be converted manually, like (would store converted backup in /home/admin/converted_user_backup):
Code:
jetbackup=yes /usr/local/directadmin/scripts/cpanel_to_da/cpanel_to_da.sh /home/admin/user_backups/cpmove-[B]USERNAME[/B].tar.gz /home/admin/converted_user_backup
chown -R admin. /home/admin/converted_user_backup

Other things to take into consideration:
* It's recommended to leave all the cpmove-user.tar.gz files on the system after restore. If there are bugs, or something goes wrong, it'd still be possible to recover that data.
* Like any software - there might be bugs there, if you notice any - please let us know, and we'll try fixing them as soon as possible.
* DirectAdmin supports a different feature set than cPanel. For example, DirectAdmin supports nginx/openlitespeed, MySQL8, rspamd etc., but it has no support for PostgreSQL or Ruby. So, if you have any sites using them - they'd need to be transferred manually.
* Max username length is 16 characters for MySQL users by default, and 10 for system user. Max username length can be increased in /usr/local/directadmin/conf/directadmin.conf. You can find max length of your username in cPanel easily:
Code:
ls /var/cpanel/users | awk '{print length, $0}' | sort -nr | head -n1

To increase it in DA to 16, for example, you can simply run:
Code:
/usr/local/directadmin/directadmin set max_username_length [B]16 [/B]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
---

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@[B]your_directadmin_server.com[/B]:/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
 
user tmp dirs not imported

Hey Martynas,

Thanks for all the work you've done on this script!

I've been testing against individual accounts before doing all of them for a full server migration. One thing that I found, is that the /home/$user/tmp dir is not being imported even though it's part of the dump. This dir contains all of the web stats files for awstats and webalizer among others. I don't expect them to be imported into their respected apps, but would expect the files to imported into the new tmp dir on the DA server. Was there a reason this is being excluded?

Thanks,
-Dan
 
hi, ay luck recevin this error during restore. Unable to restore database d3host_wp.sql to d3host_wp : ERROR 1273 (HY000) at line 33 in file: '/home/d3host/backups/backup/d3host_wp.sql': Unknown collation: 'utf8mb4_unicode_520_ci'

sounds like an older version of MySQL than on the host you are migrating from.
 
Hi,

Just tried my first cpanel backup restoration in da.

After restore, it created a file cpmove-username.tar.gz.error.log which had..
Code:
/usr/local/directadmin/scripts/cpanel_to_da/cpanel_to_da.sh: line 504: /home/admin/user_backups/username/backup/mydomain/domain.cacer
t: Is a directory

Any thing to worry?
 
Not sure how you've got into that case, however, if SSL functions normally on the domain - there is nothing to worry about :)
 
Hello smtalk,

can you pls convert Password Protected Directories setting from cpanel backup

cpmove-user.tar.gz
homedir--> .htpasswds keeping the Password Protected Directories setting

cpanel writing username and password in
home/username/.htpasswds/public_html/directorie_name/passwd

and in directorie_name has following .htaccess
AuthType Basic
AuthName "XXXXX"
AuthUserFile "/home/username/.htpasswds/public_html/directorie_name/passwd"
require valid-user


directadmin writing user and password in

/home/username/domains/domainname/.htpasswd/public_html/directorie_name/htpasswd
can you pls convert Password Protected Directories setting too

Thany you
 
Hello smtalk,

can you pls convert Password Protected Directories setting from cpanel backup

cpmove-user.tar.gz
homedir--> .htpasswds keeping the Password Protected Directories setting

cpanel writing username and password in


and in directorie_name has following .htaccess



directadmin writing user and password in


can you pls convert Password Protected Directories setting too

Thany you

May you provide a cpmove file for this? I'd give it a try :)
 
You may want to check the distribution of this script across mirrors.

files3.directadmin.com doesn't appear to be getting the correct cpanel_sqlite_da_roundcube-0.2.php file. I do not know if there are other files that aren't being distributed properly.

# wget -nv -O /dev/null http://files.directadmin.com/services/custombuild/all/cpanel-conversion/cpanel_sqlite_da_roundcube-0.2.php
2019-08-19 10:35:51 URL:http://files.directadmin.com/services/custombuild/all/cpanel-conversion/cpanel_sqlite_da_roundcube-0.2.php [6408/6408] -> "/dev/null" [1]


# wget -nv -O /dev/null http://files3.directadmin.com/services/custombuild/all/cpanel-conversion/cpanel_sqlite_da_roundcube-0.2.php
2019-08-19 10:36:00 URL:http://files3.directadmin.com/services/custombuild/all/cpanel-conversion/cpanel_sqlite_da_roundcube-0.2.php [224] -> "/dev/null" [1]
 
I had a domain with one addon domain after conversion in new directadmin the folders are all different and I receive Forbidden

You don't have permission to access this resource.
 
0.0.28 released:
* If there is invalid email set in cPanel backup, converter uses [email protected]
* Password protected directories are migrated
* Improve add-on domain transfers if subdomains have the same docroot set
 
You may want to check the distribution of this script across mirrors.

files3.directadmin.com doesn't appear to be getting the correct cpanel_sqlite_da_roundcube-0.2.php file. I do not know if there are other files that aren't being distributed properly.

# wget -nv -O /dev/null http://files.directadmin.com/servic...conversion/cpanel_sqlite_da_roundcube-0.2.php
2019-08-19 10:35:51 URL:http://files.directadmin.com/servic...conversion/cpanel_sqlite_da_roundcube-0.2.php [6408/6408] -> "/dev/null" [1]


# wget -nv -O /dev/null http://files3.directadmin.com/servi...conversion/cpanel_sqlite_da_roundcube-0.2.php
2019-08-19 10:36:00 URL:http://files3.directadmin.com/servi...conversion/cpanel_sqlite_da_roundcube-0.2.php [224] -> "/dev/null" [1]
Thanks for the report. files3 has been fixed.

Note, files3 is not in the servers.txt file, so I'm unclear how you ended up there, but no matter, it's working now ;)

John
 
Note, files3 is not in the servers.txt file, so I'm unclear how you ended up there, but no matter, it's working now ;)

Ahh! Sorry, I think I had problems with slow mirrors when I was initially installing, so I just updated the options.conf file to use a different mirror - I guess I just randomly chose files3.

But if files3 isn't suppose to be used, then that certainly explains things.
 
I had a domain with one addon domain after conversion in new directadmin the folders are all different and I receive Forbidden

You don't have permission to access this resource.

Your problem has been solved in 0.0.28 (multiple subdomains owning the same docroot as add-on domain). Please give it a try.

Thank you and sorry for the troubles!
 
Back
Top