The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

API for migrating a domain

Discussion in 'cPanel Developers' started by vivekvsist, Feb 13, 2009.

  1. vivekvsist

    vivekvsist Active Member

    Joined:
    May 29, 2007
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    1
    Hi

    Is there any API for moving a cpanel user from another server ?
     
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    If you are looking to automate this rather than using the Transfers section of WHM, I recommend you refer to the Backups and Transfers presentation from the 2007 cPanel Conference for technical details of how that system works:

    http://www.cpanel.net/docs/seminar07/Backups_and_Transfers.pdf

    This functionality is not implemented into our APIs at this time.
     
  3. vivekvsist

    vivekvsist Active Member

    Joined:
    May 29, 2007
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    1
    I read it, But it is not what I need.
    I have a php script. I can connect to my server using root accesshash
    I want to move a cpanel account from another server where I have only the cpanel shared account permission.

    How can I do this via my php interface ?



    Also
    Main >> Transfers >> Copy an account from another server with account password

    is not working for me after you guys placed the XML API for this.
    Its always showing error
     
  4. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    There is no XML API function matching Transfers -> Copy an account from another server with account password. However, I will say, that is traditionally the most unreliable method of transferring an account.

    If this is only a single account, have you considered making a full site backup, transferring it to your server then restoring it? That method doesn't require any APIs and is more likely to work.
     
  5. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Vivek,
    As David said, there really isn't a method for doing this implemented into cpanel. The way to do this will be tricky.

    To start:
    our transfer system work by generating the same backups that cpanel can create, these can be created through an API1 call called Fileman::fullbackup. Once this backup has been generated, it can be downloaded and moved to the new server.

    so, in order to generate the backup initially you'll need to run an XML call like, both of these can be called through:

    Code:
    <cpanelaction>
     <apiversion>1</apiversion>
     <module>Fileman</module>
     <func>fullbackup</func>
    </cpanelaction>
    once that is done you will need to poll the Fileman::listfullbackups function for the existance of the backup:

    Code:
    <cpanelaction>
     <apiversion>1</apiversion>
     <module>Fileman</module>
     <func>listfullbackups</func>
    </cpanelaction>
    which will return something like:

    Code:
    <cpanelresult>
      <module>Fileman</module>
      <func>listfullbackups</func>
      <type>event</type>
      <source>internal</source>
      <apiversion>1</apiversion>
      <data>
       <result>
         <div class="okmsg">
         <b>
         <a href="/download?file=backup-2.13.2009_10-31-56_cptest.tar.gz">backup-2.13.2009_10-31-56_cptest.tar.gz</a>
         </b>
         (Fri Feb 13 10:31:56 2009)
         <br/>
         </div>
         </result>
      </data>
    </cpanelresult>
    
    This will allow you to find the location and file name of the backup, in order to grab this url (the download url) it will have to be called by logging into the server via port :2083 using the user's username and either the user password or the root password.

    Now, once you have this downloaded, it will need to be put into the destination server's /home partition, you can choose your method to do this, I can't really help you there as I'm not a PHP programmer - but I'm sure it can be done easily enough.

    Once that has been done, you simply call a url in WHM:

    scripts5/quickrestore?user=USERNAME


    and the account should be restored.

    We have a perl script in /scripts that does just this ( /scripts/getremovecpmove ) and should work for your purposes. Also, it should tell you how different things need to be called so you can get this working.
     
  6. That1Swede

    That1Swede Member

    Joined:
    Jul 23, 2009
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Houston, Texas
    I apologize for the thread necromancy, but I figure since there's already a thread mentioning and giving examples of how to get a list of the backups via 'listfullbackups' I may as well use it.

    The actual XML returned by the listfullbackups API call has me scratching my head, though. :eek:

    I'm trying to parse the XML returned by the call, however since there are HTML tags in the cpanelresult->data->result element they get parsed as XML nodes instead of as the actual plain-text that I assume they're supposed to be.

    Any chance of having the 'result' node's text returned in a CDATA section instead so that the 'plain text/HTML' portion is left intact by XML parsers? So instead of:

    Code:
    <cpanelresult>
      <module>Fileman</module>
      <func>listfullbackups</func>
      <type>event</type>
      <source>internal</source>
      <apiversion>1</apiversion>
      <data>
       <result>
         <div class="okmsg">
         <b>
         <a href="/download?file=backup-2.13.2009_10-31-56_cptest.tar.gz">backup-2.13.2009_10-31-56_cptest.tar.gz</a>
         </b>
         (Fri Feb 13 10:31:56 2009)
         <br/>
         </div>
         </result>
      </data>
    </cpanelresult>
    we get:

    Code:
    <cpanelresult>
      <module>Fileman</module>
      <func>listfullbackups</func>
      <type>event</type>
      <source>internal</source>
      <apiversion>1</apiversion>
      <data>
       <result>
         <![CDATA[<div class="okmsg">
         <b>
         <a href="/download?file=backup-2.13.2009_10-31-56_cptest.tar.gz">backup-2.13.2009_10-31-56_cptest.tar.gz</a>
         </b>
         (Fri Feb 13 10:31:56 2009)
         <br/>
         </div>]]>
         </result>
      </data>
    </cpanelresult>
    which could then be used without making baby Jesus cry. :)
     
  7. That1Swede

    That1Swede Member

    Joined:
    Jul 23, 2009
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Houston, Texas
    Maybe I should have started a new thread.
     
  8. That1Swede

    That1Swede Member

    Joined:
    Jul 23, 2009
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Houston, Texas
    .. Or alternatively.. make it return an actual XML representation of the information, something like:

    Code:
    <cpanelresult>
      <module>Fileman</module>
      <func>listfullbackups</func>
      <type>event</type>
      <source>internal</source>
      <apiversion>1</apiversion>
      <data>
        <result>
          <backup>
            <status>ok</status>
            <filename>backup-2.13.2009_10-31-56_cptest.tar.gz<filename>
            <link>/download?file=backup-2.13.2009_10-31-56_cptest.tar.gz</link>
            <date>Fri Feb 13 10:31:56 2009</date>
          </backup>
        </result>
      </data>
    </cpanelresult>
     
  9. That1Swede

    That1Swede Member

    Joined:
    Jul 23, 2009
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Houston, Texas
    Bump.. in the hopes of seeing some kind of reply or acknowledgment.
     
  10. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    You've brought up a valid point and we've been discussing this internally for a few days now. We do intend to resolve this issue, but we're still exploring various possible options. I have no ETA on when this issue will be resolved, but we are very mindful of the issue you have brought to our attention.
     
Loading...

Share This Page