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.

Restore cPanel account through API

Discussion in 'cPanel Developers' started by saulyx, Apr 24, 2012.

  1. saulyx

    saulyx Member

    Joined:
    Apr 7, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Hi there,


    I've developed a tool that backups cPane/cPanel account through reseller logins to an offsite server. I was wondering would there be a way through API to specify where the backup is stored and make cpanel restore by using either cPanel details or WHM details and user nameof cPanel?



    Thanks!
     
  2. NetMantis

    NetMantis BANNED

    Joined:
    Apr 22, 2012
    Messages:
    117
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Utah
    cPanel Access Level:
    DataCenter Provider
    There are API functions but depending on how you wrote your program, it might be easier just to call the shell scripts.

    /scripts/pkgacct -- script used to create a backup archive of an account
    /scripts/restorepkg -- script used to restore site backups

    By default, Cpanel looks for the backup archives in a number of different fixed locations (see Cpanel documentation) but most common place to put these files is in /home which is one of the locations on the built in search path to find the backup archives.

    Incidentally, the backup system in WHM / Cpanel uses the same search locations as the shell scripts for finding the backups.
     
  3. saulyx

    saulyx Member

    Joined:
    Apr 7, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    I won't be able to run shell scripts, I need to do this over the API, I looked at the API docs and it seems only like I can do this from cpanel's own backups daily, weekly or monthly? can I do this by uploading or telling it what file to extract? All my backups are generated through the APIas well
     
  4. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    The XML/JSON API to restore an account will load the backup file from the backup destination set in WHM's 'Configure Backup' menu. You'll need to have the file present at the daily/weekly/monthly location within that backup destination for it to be used with the restore.
     
  5. saulyx

    saulyx Member

    Joined:
    Apr 7, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    So what would be the process? Move the file (gzip) from myremote server to the cpanel's backup directory(or home?) and then run the api query? Is there anysamples of code floating about? As I can't find anything :s


    Thanks!
     
  6. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    That's correct. You could use 'scp' to send the file to the remote server and then run the API command. I'm not aware of any code samples to do this specifically but you can use this PHP function: ssh2-scp-send.php
     
  7. saulyx

    saulyx Member

    Joined:
    Apr 7, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    My real question would be about moving the file really, as backup server I can access via FTP only and the server I want to put the backup on I can only access via WHM Logins. Thats the issue, been looking for a way for few hours now. Is there a way?
     
  8. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    Using FTP to get the files shouldn't be an issue: PHP:FTP. However, I'm not aware of any way to upload files via WHM. If you're a reseller, this isn't going to happen as the backup locations are going to be in a location you can't access.
     
Loading...

Share This Page