How-to: cPanel to DA migration

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
13,853
Location
GMT +7.00
What makes you think so? What issues do you have?

Actually all subdomains can be added into parent's zone file.
 

bdacus01

Verified User
Joined
Jul 22, 2017
Messages
528
Location
Murfreesboro
Well when I restored the backup. There was a zone created for the parent domain and every subdomain. I have read everything I can find.. still not working.

Here is what does work going to main domain. Good

going to domain.com\subdomain Good

subdomain.domain.com. Won’t go there just shows the main domains home page. On the address bar it shows subdomain.domain.com in the address bar.
 

smtalk

Administrator
Staff member
Joined
Aug 22, 2006
Messages
8,331
Location
LT, EU
@bdacus01 may you create a ticket with access details where we could find the backup which you converted from and the converted backup? Thank you!
 

smtalk

Administrator
Staff member
Joined
Aug 22, 2006
Messages
8,331
Location
LT, EU
Version 0.0.7 released, changes:
Code:
* Sets the user skin to Evolution instead of Enhanced when converting
* mdbox is automatically converted to Maildir (waiting for feedback on this, worked fine in tests), note it requires backup to be converted in not in /root (like in official guides, as dovecot-sync requires +x perms on parent directory)
Security reminder - please trust only the backups you create at the moment. Script is not ready yet for cpmove-user.tar.gz files from unknown origin :)
 

smtalk

Administrator
Staff member
Joined
Aug 22, 2006
Messages
8,331
Location
LT, EU
Converting film (/home/user_backups/cpmove-film.tar.gz)...
Found previous /home/admin/converted_user_backup/film. Removing...
tar (child): /home/user_backups/cpmove-film.tar.gz: Cannot open: Not a directory
tar (child): Error is not recoverable: exiting now

gzip: stdin: unexpected end of file
tar: Child returned status 2
tar: Error is not recoverable: exiting now
Failed to extract /home/user_backups/cpmove-film.tar.gz to /home/admin/converted_user_backup/film_cpanel_to_convert


Please help :(
A ticket on this would be great! It seems like a corrupt cpmove-film.tar.gz file, but we'd give it a check :)
 

DanielP

Verified User
Joined
Jun 28, 2019
Messages
82
A bit off topic and a suggestion about a live transfer tool - such tool if it is released by next month it will really allow a lot of accounts to by transferred to Direct Admin with ease

(also may give the plugin developers a good idea)


I'm not a developer but i watched it how it work and process is similar to:

CP2 server connects to CP1 server with root list accounts you point and click which want to transfer and hit transfer

cpanel server 1 will run /scripts/pkgacct --skiphomedir (which make a backup without the home dir files which is a lot of smaller ) that backup is transferred and restored to the CP2 then restoration process uses rsync to move files in correct places which is alot lighter process that to move full backups one by one and restore them one by one

Optionally can be selected to overwrite the dns recored on CP1 with the new correct IP of CP2

Hope that will helpful and will give a good idea to a future function
 

bdacus01

Verified User
Joined
Jul 22, 2017
Messages
528
Location
Murfreesboro
Solved

I seem to remember this from before but I have a issue with subdomains. The cPanel file all came over good and converted. All the data is there. The ssl certs even created fine. When try to go to the subdomain like files.domain.com it goes to domain.com but shows files.domain.com in address bar.

I checked A records I have them. if I go to the full path domain.com/files I get forbidden htaccess issue.. thoughts?
Solved. Ok the issue was cPanel somehow makes a subdomain and an alias (called Pointers in da). Smtalk was able to figure it out and give guidance. All I needed to do was deleted the Pointers Located at

User Account > Account Manager > Domain pointers Then select them all and delete them. Then BAM all worked..

On to the next Server...;)
 

pkwebhost

Verified User
Joined
Jul 2, 2019
Messages
36
For Complete beginers just copy and past bellow commands


Note: replace username with your cpanel username
Replace directadminserverip with your directadmin server IP
[/B]


1
Code:
/scripts/pkgacct username /home/user_backups;
2
Code:
rsync -avt /home/cpmove-username.tar.gz root@directadminserverip:/home/user_backups/
3
only needs to be done once

Code:
mkdir -p /root/cpanel_to_da
cd /root/cpanel_to_da
wget -O cpanel_to_da.sh [url]http://www.custombuild.eu/cpanel/cpanel_to_da.sh[/url]
chmod +x cpanel_to_da.sh
wget -O cpanel_da_roundcube.php [url]http://www.custombuild.eu/cpanel/cpanel_da_roundcube.php.txt[/url]
wget -O php_sql_parser.tar.gz [url]http://www.custombuild.eu/cpanel/php_sql_parser.tar.gz[/url]
tar xzf php_sql_parser.tar.gz
rm -f php_sql_parser.tar.gz
4
If you already done above , use this command
Code:
cd /root/cpanel_to_da
5
Only need to be done once
Code:
mkdir -p /home/admin/converted_user_backup
cd /root/cpanel_to_da
6
If you already done above command , use this command

Code:
cd /root/cpanel_to_da
./cpanel_to_da.sh /home/user_backups/cpmove-username.tar.gz /home/admin/converted_user_backup/cpmove-username.tar.gz
chown -R admin. /home/admin/converted_user_backup
Restore it in "Admin Backup/Transfer" section on DA admin level (don't forget to set the path to /home/admin/converted_user_backup, otherwise you won't see the backup)
 

smtalk

Administrator
Staff member
Joined
Aug 22, 2006
Messages
8,331
Location
LT, EU
Version 0.0.8 released, changes:
Code:
* Old cPanel mail/ directory is renamed to .mail_unused_folder_from_cpanel/ instead of being removed. It's safe to remove it from /home/user from all the accounts, if nothing is missing. Just better to be save than sorry. No reports on missing email data in converted backup at all :)
* Fixed specific case where if a domain pointer had its own email account - its data was put to a wrong folder after conversion.
Waiting for the feedback :) Thank you!
 
Last edited:

bdacus01

Verified User
Joined
Jul 22, 2017
Messages
528
Location
Murfreesboro
Version 0.0.8 released, changes:
[code}* Fixed specific case where if a domain pointer had its own email account - its data was put to a wrong folder after conversion.[/code]

Waiting for the feedback :) Thank you!
I assume this one was mine. Did you want me to download your updated script and try the convert again? I can if you want.
 

smtalk

Administrator
Staff member
Joined
Aug 22, 2006
Messages
8,331
Location
LT, EU
I assume this one was mine. Did you want me to download your updated script and try the convert again? I can if you want.
Sure, just note that if it's a production site, it'd restore your emails + MySQL databases etc. etc., this could lead to data inconsistency. If that's just a testing file - totally fine, and this would be really appreciated.
 

bdacus01

Verified User
Joined
Jul 22, 2017
Messages
528
Location
Murfreesboro
No its fine its not open to the world really.. I will take a seperate da backup as well. So just redownload from the first post?
 

pkwebhost

Verified User
Joined
Jul 2, 2019
Messages
36
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:
* 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. 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
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 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 :)
---

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/all_backups/
We're done with cPanel server now. Let's connect to DirectAdmin server now.

DirectAdmin server:
1) Convert all backups to DirectAdmin format, place them to /home/admin/admin_backups and set appropriate permissions for them:
a) Install converter script
Code:
mkdir -p /root/cpanel_to_da
cd /root/cpanel_to_da
wget -O cpanel_to_da.sh http://www.custombuild.eu/cpanel/cpanel_to_da.sh
chmod +x cpanel_to_da.sh
wget -O cpanel_da_roundcube.php http://www.custombuild.eu/cpanel/cpanel_da_roundcube.php.txt
wget -O php_sql_parser.tar.gz http://www.custombuild.eu/cpanel/php_sql_parser.tar.gz
tar xzf php_sql_parser.tar.gz
rm -f php_sql_parser.tar.gz
b) convert all the backups and place them to /home/admin/converted_backups
Code:
mkdir -p /home/admin/converted_backups
for i in `ls /home/all_backups/`; do { ./cpanel_to_da.sh /home/all_backups/$i /home/admin/converted_backups; }; done
chown -R admin. /home/admin/converted_backups
2) We finally have DirectAdmin backups in /home/admin/converted_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/converted_backups" directory.

That's it!

-----
If you have enough of space, I'd suggest leaving /home/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/all_backups/cpmove-${user}.tar.gz; rm -f /home/all_backups/cpmove-${user}.tar.gz ; }; done
Hello

i jus try to convert backup of Cpanel weekly backup but getting this error

Max username length (10) is smaller than cPanel username (14)

backup is in this format username.tar.gz
 

lolfust1

Verified User
Joined
Oct 24, 2015
Messages
41
Hey the restore backup from DA from cpmove file, will catch the custom made DNS records or user? like landing pages, or sub domains, or gsuite or outlook?
 

smtalk

Administrator
Staff member
Joined
Aug 22, 2006
Messages
8,331
Location
LT, EU
Hello

i jus try to convert backup of Cpanel weekly backup but getting this error

Max username length (10) is smaller than cPanel username (14)

backup is in this format username.tar.gz
It means you need to increase the max username length from 10 to 14 on your DirectAdmin server:
Code:
/usr/local/directadmin/directadmin set max_username_length 14 restart
 

smtalk

Administrator
Staff member
Joined
Aug 22, 2006
Messages
8,331
Location
LT, EU
Hey the restore backup from DA from cpmove file, will catch the custom made DNS records or user? like landing pages, or sub domains, or gsuite or outlook?
Yes, it should copy the DNS zone over. If any issues noticed - just let us know :) Thank you!
 
Top