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.

Backup API Questions

Discussion in 'cPanel Developers' started by aarondwyer, Mar 23, 2010.

  1. aarondwyer

    aarondwyer Well-Known Member

    Joined:
    Mar 26, 2005
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Brisbane
    cPanel Access Level:
    Root Administrator
    Hi

    I have a 3rd party AIR application to extract backups from the cPanel backup page. Currently it does this via straight HTTP.

    I'm looking to enhance further by using the cPanel API, however I don't think it's possible at this stage looking at the API reference doco.

    My software logs into each cPanel account over HTTP as an end user would, navigates to the backup page, and downloads the home DIR and databases as required on a schedule defined by the user.

    With the current API structure, would something like this be possible.?

    Thanks
    Aaron
     
  2. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Backup API

    Aaron,

    Currently there's only one function in API1, Backup::listfullbackups, that falls into your question. And really, while convenient, I doubt it's what you're looking for.

    I imagine that you're probably handling the situation optimally right now. I actually downloaded a trial version of your AIR application the other day to give it a spin...it worked as expect and was intuitive: good work!

    If you have specific thoughts about what would be ideal/most useful, I'd like to hear them; it could be a feature request!

    Best Regards,
    -Dave
     
  3. aarondwyer

    aarondwyer Well-Known Member

    Joined:
    Mar 26, 2005
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Brisbane
    cPanel Access Level:
    Root Administrator
    Thanks for your kind words about it, David.

    I just saw a need for my own multitude of accounts across multiple servers and those of my clients, and it just so happens that others needed it as well.

    As for API adjustments there wouldn't be many (probably I'm the only one) that would need the home directory and database backup exposed.

    Forgetting my software for a moment. This is a general backup issue I've faced.

    I've noticed with the home directory and database backup on the backup page of cPanel that it's done on the fly. This is fine however, once the user clicks on the links to download a home directory backup, cPanel looks like it's bundling up the ZIP and streaming it down over HTTP at the same time.

    Trouble with this is that there is no file size length reported to the browser, so there is no way of knowing how big the file size being downloaded is.

    This causes issues with some users unable to download a large home directory backup (usually greater than 1GB) in one go. Their internet may bounce, or something interrupts the transfer of the backup over HTTP.

    They then don't know it's incomplete (until they examine the .gz file) since there was no end size. Also you can't resume the backup, so you have to start again.

    I don't know enough about the inner workings of the home directory or database backup routines to draw any conclusions on this, just my observations being exposed to many different users doing downloads of cPanel home directory and database backups from the Backup page.

    I think this failure to serve up home directory backups larger than 1GB could also be server dependant (available space / resources), but I just don't know.

    Aaron
     
  4. 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
    Aaron,
    Luckily you can generate the backup then download it. This is done via Fileman::fullbackup (this is from the unpublished API1 docs...):

    So, you could start the backup process using this command via the XMLAPI f.ex:

    PHP:
    :2083/xml-api/cpanel?cpanel_xmlapi_apiversion=1&cpanel_xmlapi_module=Fileman&cpanel_xmlapi_func=fullbackup
    Then poll using Backups::listfullbackups to see if it is complete, f.ex:

    PHP:
    :2082/xml-api/cpanel?cpanel_xmlapi_module=Backups&cpanel_xmlapi_func=listfullbackups&cpanel_xmlapi_apiversion=1
    Now, it should be noted that these are API11 calls, so they do not necessarily return well-formed XML. However it will be much much easier to parse than the pages inside of x3 (and they are not theme specific).

    If you want to download a backup, you will see that listfullbackups will return a download URL for the backup file itself.

    Please let us know if you need any clarification/help.
     
  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
    Very good question indeed! This will affect the user's disk usage considerably, I *strongly* advise removing these files after they have been downloaded as each backup can potentially double a user's disk usage.
     
  6. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Good catch Matt!

    One question:
    How might this affect the user's diskusage?

    I can just imagine, if proper cleanup is not done, the case where the user's disk space is full of tarballs/zips.


    -Dave
     
  7. aarondwyer

    aarondwyer Well-Known Member

    Joined:
    Mar 26, 2005
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Brisbane
    cPanel Access Level:
    Root Administrator
    Thanks Matt and Dave

    Fullbackup is ok ocassionally but since most users just want to quickly grab their databases daily and files monthly, this restricts me to not using full backup and sticking with the home Dir and database backup options.

    The other reason is not adding burden to the users account with backup files. So Home Dir and Databases straight from the cPanel backup page is fine.

    Different themes are not a bother, and catered for.

    However some hosts customise their backup page URL location which is a problem and I just add in an option for that host specifically on an as needed basis. So far only 1 custom host has needed to be catered for.

    This is where the API would be handy.

    Most just use cPanel default setup straight out of the box.

    Aaron
     
  8. WaQas

    WaQas Registered

    Joined:
    Dec 16, 2004
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1

    Sir, its very help full.
    but sir in url we tried to set ftp command or use only email then what will the command?
    i tried..
    Code:
    2082/xml-api/cpanel?cpanel_xmlapi_apiversion=1&cpanel_xmlapi_module=Fileman&cpanel_xmlapi_func=fullbackup&email=email@domain.com
    but fail to get email..
    please give me any example
     
Loading...

Share This Page