Page 2 of 2 FirstFirst 12
Results 21 to 24 of 24

Thread: Feture request, cpanel backup to directadmin backup.

  1. #21
    Join Date
    Jul 2017
    Location
    Murfreesboro
    Posts
    16
    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
    Thanks,

    Brent Dacus

  2. #22
    Join Date
    May 2008
    Posts
    32
    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

  3. #23
    Join Date
    Apr 2013
    Posts
    25
    i have error in mysql like this
    Code:
     set_collation: DB farapajo_farapajo_dnppoaO0HreTp7IL does not have any collation information in the backup. Skipping

  4. #24
    Join Date
    Apr 2013
    Posts
    25
    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

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •