Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Restore package return code

Discussion in 'cPanel Developers' started by fernandomm, Feb 11, 2011.

  1. fernandomm

    fernandomm Active Member

    Nov 25, 2009
    Likes Received:
    Trophy Points:

    I have a script that automatically copy accounts to other servers and use restorepkg to restore them.

    The issue is that sometimes restorepkg fails and my script doesn't notice it, going on with the other actions.

    I tried to check return code of restorepkg but it's always 0.

    What is the correct way of checking is restorepkg successfully restored package?
  2. cPanelDavidN

    cPanelDavidN Integration Developer

    Dec 17, 2009
    Likes Received:
    Trophy Points:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi fernandomm,

    I'm not sure that it's possible to check the output of restorepkg programmatically for errors. I'm pretty certain it wasn't designed with that intention (unfortunately). You may wish to look at the XML-API function restoreaccount. Using this API call, you should be able to check for errors in the response. There's two things to consider about this XML-API call. 1) it's only available in cPanel/WHM version 11.28 and higher. 2) you will probably need to place the packaged account within the backup directory (/backup/cpbackup/weekly, etc.). I'm not 100% about that, nor am I 100% that a cpmove file will be considered a valid source for this operation. It's worth looking into and experimenting. The XML-API output will be worlds better to work with that the text based output of restorepkg.

    Best Regards,
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice