Feture request, cpanel backup to directadmin backup.

bdacus01

Verified User
Joined
Jul 22, 2017
Messages
1,071
Location
Murfreesboro
Oh I am sure you all have something like this. here is a loop to make cpmoves on the entire CPANEL box.
Code:
grep root /etc/trueuserowners | cut -d : -f 1 | while read a; \
do /usr/local/cpanel/scripts/pkgacct $a; \
done
 

dmtinc

Verified User
Joined
May 10, 2008
Messages
45
Location
Chile
After some problems I got this script working, some comments to be aware if you have problems with the generated file:

The NS1 and NS2 needs to be globally defined, are used in the DNS functions but to generate the user.conf file too:

You can add this to the top of the file or after "#Generate user.conf"
Code:
NS1="`/usr/local/directadmin/directadmin c | grep -m1 '^ns1=' | cut -d= -f2`"
NS2="`/usr/local/directadmin/directadmin c | grep -m1 '^ns2=' | cut -d= -f2`"
Another problem was this error

Code:
Named::writeDB: error writing zone for domain.tld: email='' or ns1='' is empty. Ensure the zone is not corrupted.
If you the dns file generator section you will see

Code:
        #Create DNS zone
        CONVERTED_DOMAIN_DNS="${DIRECTADMIN_BACKUPS}/${USERNAME}/backup/${CONVERTED_DOMAIN}/${CONVERTED_DOMAIN}.db"
        CPANEL_DNS_DATA=${DIRECTADMIN_BACKUPS}/${USERNAME}_cpanel_to_convert/dnszones/${CONVERTED_DOMAIN}.db
        if [ -s ${CPANEL_DNS_DATA} ]; then
        cp -f ${CPANEL_DNS_DATA} ${CONVERTED_DOMAIN_DNS}
        else
And with this the DNS zone is done, but the cpanel dns file isn't compatible with the directadmin backup script a needs to be fixed, my suggestion:

add below
Code:
cp -f ${CPANEL_DNS_DATA} ${CONVERTED_DOMAIN_DNS}
This

Code:
                sed -i '/domainkey/d' ${CONVERTED_DOMAIN_DNS}
                sed -i '/NS/d' ${CONVERTED_DOMAIN_DNS}
                sed -i '/SOA/d' ${CONVERTED_DOMAIN_DNS}
                sed -i "/\$TTL/a@       IN      SOA     ${NS1}.      hostmaster.${CONVERTED_DOMAIN}. (" ${CONVERTED_DOMAIN_DNS}
                echo "${CONVERTED_DOMAIN}.     14400   IN      NS      ${NS1}." >> ${CONVERTED_DOMAIN_DNS}
                echo "${CONVERTED_DOMAIN}.     14400   IN      NS      ${NS2}." >> ${CONVERTED_DOMAIN_DNS}
With comments:

The cpanel domainkey isnt compatible with directadmin, not need here:
sed -i '/domainkey/d' ${CONVERTED_DOMAIN_DNS}
We need to update the NS servers of the zone to our local, for this, the NS records of cpanel needs to be removed.
sed -i '/NS/d' ${CONVERTED_DOMAIN_DNS}
The cpanel SOA starts with the domain name, in directadmin needs to be @ or the import fail, for this we remove the line:
sed -i '/SOA/d' ${CONVERTED_DOMAIN_DNS}
Add the new SOA line to the zone:
sed -i "/\$TTL/a@ IN SOA ${NS1}. hostmaster.${CONVERTED_DOMAIN}. (" ${CONVERTED_DOMAIN_DNS}
Add the new NS records to the zone:
echo "${CONVERTED_DOMAIN}. 14400 IN NS ${NS1}." >> ${CONVERTED_DOMAIN_DNS}
echo "${CONVERTED_DOMAIN}. 14400 IN NS ${NS2}." >> ${CONVERTED_DOMAIN_DNS}

I think more things can be done with this, but now the zone is compatible with directadmin :)

For alias/pointers domains you need to fix it too:

After this

Code:
cp -f ${CPANEL_POINTER_DNS_DATA} ${CONVERTED_POINTER_DNS}
Add

Code:
                sed -i '/domainkey/d' ${CONVERTED_POINTER_DNS}
                sed -i '/NS/d' ${CONVERTED_POINTER_DNS}
                sed -i '/SOA/d' ${CONVERTED_POINTER_DNS}
                sed -i "/\$TTL/a@       IN      SOA     ${NS1}.      hostmaster.${i}. (" ${CONVERTED_POINTER_DNS}
                echo "${i}.     14400   IN      NS      ${NS1}." >> ${CONVERTED_POINTER_DNS}
                echo "${i}.     14400   IN      NS      ${NS2}." >> ${CONVERTED_POINTER_DNS}
Another detail, the NS2 variable in the DNS Zone section is using the NS1 data:

Code:
NS2="`/usr/local/directadmin/directadmin c | grep -m1 '^ns1=' | cut -d= -f2`"
Fix to

Code:
NS2="`/usr/local/directadmin/directadmin c | grep -m1 '^ns2=' | cut -d= -f2`"


---------------

A question, when a cpanel backup dont have a DNS zone?

if [ -s ${CPANEL_DNS_DATA} ]

I think, the "else" section never will be executed because the cpmove file always have the main domain dns zone.

For the pointers is the same situation "if [ -s ${CPANEL_POINTER_DNS_DATA} ];" , if a pointer exist, you will have a DNS file from the cpmove, and based on this the "else" section never will be executed.

After all now the script is working :) thanks smtalk for your script.

Regards
Roberto
 

parsibox

Verified User
Joined
Apr 18, 2013
Messages
47
i have error in mysql like this
Code:
 set_collation: DB farapajo_farapajo_dnppoaO0HreTp7IL does not have any collation information in the backup. Skipping
 

parsibox

Verified User
Joined
Apr 18, 2013
Messages
47
some other error in email
Code:
 Error writing db file for siminsepahan.com : The email or the ns1 value is blank.  Check to ensure the zone isn't corrupted
 

smtalk

Administrator
Staff member
Joined
Aug 22, 2006
Messages
9,093
Location
LT, EU
Thank you for the reports! Updated version to 0.0.4 with bugfixes for reported problems :)
 

dmtinc

Verified User
Joined
May 10, 2008
Messages
45
Location
Chile
Thank you for the reports! Updated version to 0.0.4 with bugfixes for reported problems :)
Hi smtalk,
Just still a small bug(or not?), the NS records on the DA converted zone still use the cpanel records, I think this records needs to be change for the DA default ones.

Thanks
Regards
 

smtalk

Administrator
Staff member
Joined
Aug 22, 2006
Messages
9,093
Location
LT, EU
There is a checkbox in DA admin backup/transfer for that: "Restore with Local NameServers. (unchecked: Use NS values from backup)". If it's checked, it should overwrite NS to the ones used on DA server.
 

arpahost

New member
Joined
Dec 8, 2017
Messages
4
How to use This Script?

cPanel backup conversion tool BETA is now ready :) I'm attaching it to the reply.

Differences between this tool and the one that is already on DA forums:
1. Script transfers resellers and their packages.
2. Script transfers subdomain/domain data from custom folders.
3. Email forwarders get transferred.
4. MX records in DNS zones get transferred.
5. RoundCube data gets transferred (optional, requires additional scripts)

There might be more differences between the scripts, but these are the most obvious ones :)

Known issues:
* cPanel mdbox format email transfer has not been tested
* Mailman mailing lists do not get converted to majordomo mailing lists

Please let us know if you notice anything with your transfers :)

Cpanel to DA backup conversion script URL http://www.custombuild.eu/cpanel/cpanel_to_da.sh

It will not convert RoundCube data by default, please do the following in the same directory if you want RoundCube data to be transferred:
Code:
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
How to use This Script? How to use this script?
Please explain step by step for beginners
thank you
 

shaggy

Verified User
Joined
Jul 12, 2005
Messages
29
Location
Paris, KY
I am trying to run the script and I keep getting this error:

Unable to extract username from tarball name

Can you provide any guidance or documentation to help solve this? Thanks.
 

smtalk

Administrator
Staff member
Joined
Aug 22, 2006
Messages
9,093
Location
LT, EU
I am trying to run the script and I keep getting this error:

Unable to extract username from tarball name

Can you provide any guidance or documentation to help solve this? Thanks.
What's the name of the backup file? It should be cpmove-username.tar.gz or username​.tar.gz.
 

arpahost

New member
Joined
Dec 8, 2017
Messages
4
Download http://www.custombuild.eu/cpanel/cpanel_to_da.sh, apply "chmod 700 cpanel_to_da.sh", then execute the file using "./cpanel_to_da.sh" and it will provide you instructions.
Thank you smtalk
The result of commands :

./cpanel_to_da.sh
Usage:
./cpanel_to_da.sh <full path to cpanel backup> [<full path to directadmin backup directory>]
you gave #0: ./cpanel_to_da.sh

Should we insert backup file path in sh file or somewhere?
backupfile name : backup-12.8.2017_18-33-07_my.tar.gz
 

arpahost

New member
Joined
Dec 8, 2017
Messages
4
import]# ./cpanel_to_da.sh
Usage:
./cpanel_to_da.sh <full path to cpanel backup> [<full path to directadmin backup directory>]
you gave #0: ./cpanel_to_da.sh
 

shaggy

Verified User
Joined
Jul 12, 2005
Messages
29
Location
Paris, KY
What's the name of the backup file? It should be cpmove-username.tar.gz or username​.tar.gz.
I finally got it working. I unzipped the file and gzipped it again and it worked... Not sure how or why, but it did. Everything seems to have worked but a mysql DB user had to be recreated manually. Thanks for this great script. Saved a lot of time!
 

psalm91

Verified User
Joined
Sep 20, 2015
Messages
71
I wish beside a thread in forum we could also have a page dedicated to this converting tool so we could see the result in there.
Is this script still valid ? last reply to this thread was last year .
 

smtalk

Administrator
Staff member
Joined
Aug 22, 2006
Messages
9,093
Location
LT, EU
Yes, it should still work without any problems :) If you experience any - please let us know.
 

alex2k

Verified User
Joined
Oct 28, 2004
Messages
88
Location
Behind You!
Usage:
./cpanel_to_da.sh <full path to cpanel backup> [<full path to directadmin backup directory>]
you gave #0: ./cpanel_to_da.sh
What is [<full path to directadmin backup directory>] ?
Anyone could explain better?

Thank you :)
 

alex2k

Verified User
Joined
Oct 28, 2004
Messages
88
Location
Behind You!
The backup directory of the user account (eg. /home/<user>/ etc)
Thank you :)

Another question:

I got this error:
Code:
Max username length (10) is smaller than cPanel username (17)
I already edit /usr/local/directadmin/conf/directadmin.conf with max_username_length=17 then restart directadmin
But still got that error :(

Any idea?
 
Top