Software Development Kit

cPanel & WHM's API [+] cPanel & WHM's API [-]


Modules and Plugins [+] Modules and Plugins [-]


cPanel & WHM Hooks [+] cPanel & WHM Hooks [-]


cPAddons (Site Software) [+] cPAddons (Site Software) [-]


System Administration [+] System Administration [-]


Developer Software [+] Developer Software [-]


Back to All Documentation

Restore a Backup — restoreaccount

For WHM version 11.28

This function allows you to restore a user's account from a backup file. You may restore a monthly, weekly, or daily backup.

note Note: This function uses the Whostmgr::Transfers module. The module is dynamically loaded. You may not see proper XML output if you have altered this module so that it does not conform to WHM's new mechanism for capturing output using the Cpanel::Demultiplexer module.

Calling Functions

Using the XML API

To use the XML API to perform the restoreaccount function from within your custom script:

  • Append the /xml-api/restoreaccount function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/xml-api/restoreaccount

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Using the JSON API

To use the JSON API to perform the restoreaccount function from within your custom script:

  • Append the /json-api/restoreaccount function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/json-api/restoreaccount

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Variables

Input

The restoreaccount function takes the following variables as input.

The following variables are required:

  • api.version — This variable is used for internal purposes. It must be set to 1.
  • user (string) — The name of the user for whom you wish to restore a backup.
  • type (string) — The type of backup you wish to restore. You may choose:
    • monthly — Using this value in the type parameter causes the function to restore the user's most recent monthly backup.
    • weekly — Using this value in the type parameter causes the function to restore the user's most recent weekly backup.
    • daily — Using this value in the type parameter causes the function to restore the user's most recent daily backup.
  • all (boolean) — Setting this value to 1 will create and restore the account. Setting this parameter to 1 will cause the function to fail if the account already exists. Setting this value to 0 will restore the account without attempting to create the account.
  • ip (boolean) — Setting this value to 1 allows you to restore the account's access to a dedicated IP address. This variable is only used if all is set to 1.
  • mail (boolean) — Setting this value to 1 allows you to restore the acount-level vfilters (filters) and valiases (forwarders).
  • mysql (boolean) — Setting this value to 1 allows you to restore the account's SQL databases.
  • subs (boolean) — Setting this value to 1 allows you to restore the account's subdomain entries.

note Note: To use this function, you must specify at least one of the following parameters: mail, subs, all, mysql.

Output

  • result — The XML results container.
  • metadata — The XML metadata container.
    • result — A boolean value indicating success or failure.
      • 0 — Indicates that the function failed.
      • 1 — Indicates that the function completed successfully.
    • reason — A string value that contains a message of success or a reason for failure.
    • version — The version of the XML API used.
    • command — The XML API function that has returned the data.
  • output — The XML output container.
  • raw — The raw output generated by the function.

Examples

XML API

Calling the URL https://example.com:2087/xml-api/restoreaccount?api.version=1=&user=user&type=1 in WebHost Manager will produce output similar to:

<result>
   <metadata>
      <result>1</result>
      <reason>OK</reason>
      <version>1</version>
      <command>restoreaccount</command>
   <output>
      <raw>
         Extracting tarball...................
         Done<br />
         Extracting Domain....Done<br />
         Done<br />
         <br /><br />Restoring cpanel user config fileDone<br />
         <br />Restoring reseller privs (if any)<br />Restoring Locale Setting<br />Restoring SSL keys and CertificatesDone<br />
         <br />Restoring frontpage (if installed)Done<br />
         <br />Restoring access logs.... Done<br />
         <br /><br />Restoring domain keys.... Done<br />
         <br /><br />Restoring DB MAP File.... Done<br />
         <br /><br /><span class="b2">Restoring PostgreSQL databases....</span>
         Restoring PostgreSQL privs<!-- --> Done<br />
         <br />Restoring Mailman listsDone<br />
         <br />Restoring Mailman ArchivesDone<br />
         <br />Restoring shell<blockquote><pre>Current shell /bin/bash is up to date.
         </pre></blockquote>Done<br />
         <br />Restoring password<blockquote><pre></pre></blockquote>Done<br />
         <br />Restoring proftpd fileDone<br />
         <br />Resyncing FTP Passwords<blockquote><pre>Updating ftp passwords for userFtp password files updated.Ftp vhost passwords synced</pre></blockquote>Done<br />
         <br />Linking old home directories<br />Parsing Domain Databases...ParkedDomains......AddonDomains...<br />Restoring Domains<br />
         <br />Restoring Bandwidth DataDone
         <br />Restoring Counter Data<pre></pre><br />Restoring Homedir....<blockquote><pre></pre></blockquote>Done<br />
         <br />Doing fileprotect conversion<br />Restoring nobody owned filesDone<br />
         <br />Restoring Mail filesDone<br />
         <br />Restoring userdata.... Done<br />
         <br /><br />Restoring custom virtualhost templates.... Converting email to cPanel 5+ (if needed)<blockquote><pre></pre></blockquote>Done<br />
         <br />Cleaning up filters (if needed)<blockquote><pre>vfilter converter v3.0Updating vfilter files to latest format.Running for user only (force=0) (has_spam_acl=1)Processing user......Done</pre></blockquote>Done<br />
         <br />Fixing mail permissions<blockquote><pre></pre></blockquote>Done<br />
         <br />Restoring crontabDone<br />
         Converting to maildir if needed<blockquote><pre></pre></blockquote>Done<br />
         Restoring Dns Zones<blockquote><pre>Restoring zone: user.com.db
         </pre></blockquote><br />Adding missing subdomain DNS entries (if needed)<pre></pre><br />Update Proxy subomains<blockquote><pre>Adding proxy subdomains for domain example.com.Records Installed</pre></blockquote>Done<br />
         <br />Updating SPF Records<blockquote><pre></pre></blockquote>Done<br />
         <br />Restoring quota<blockquote><pre></pre></blockquote>Done<br />
         <br /><br />Update mail routing<blockquote><pre>LOCAL MAIL EXCHANGER: This server will serve as a primary mail exchanger for example.com's mail.: This configuration has been manually selected.
         </pre></blockquote>Done<br />
         <br />Rebuilding Apache Conf<br />Restore CompleteAccount Restore Complete
         Unlocking password for user user.passwd: Success.<br />
      </raw>
   </output>
   </metadata>
</result>

JSON API

Calling the URL https://example.com:2087/json-api/restoreaccount?api.version=1=&user=user&type=1 in WebHost Manager will produce output similar to:

{
   "metadata":{
      "result":1,
      "reason":"OK",
      "version":1,
      "command":"restoreaccount",
      "output":{
         "raw":"Extracting tarball...................\nDone<br />\nExtracting Domain....Done<br />\nDone<br />\n<br /><br />Restoring cpanel user config fileDone<br />\n<br />Restoring reseller privs (if any)<br />Restoring Locale Setting<br />Restoring SSL keys and CertificatesDone<br />\n<br />Restoring frontpage (if installed)Done<br />\n<br />Restoring access logs....\nDone<br />\n<br /><br />Restoring domain keys....\nDone<br />\n<br /><br />Restoring DB MAP File....\nDone<br />\n<br /><br /><span class=\"b2\">Restoring PostgreSQL databases....</span>\nRestoring PostgreSQL privs<!--\n-->\nDone<br />\n<br />Restoring Mailman listsDone<br />\n<br />Restoring Mailman ArchivesDone<br />\n<br />Restoring shell<blockquote><pre>Current shell /bin/bash is up to date.\n</pre></blockquote>Done<br />\n<br />Restoring password<blockquote><pre></pre></blockquote>Done<br />\n<br />Restoring proftpd fileDone<br />\n<br />Resyncing FTP Passwords<blockquote><pre>Updating ftp passwords for userFtp password files updated.Ftp vhost passwords synced</pre></blockquote>Done<br />\n<br />Linking old home directories<br />Parsing Domain Databases...ParkedDomains......AddonDomains...<br />Restoring Domains<br />\n<br />Restoring Bandwidth DataDone\n<br />Restoring Counter Data<pre></pre><br />Restoring Homedir....<blockquote><pre></pre></blockquote>Done<br />\n<br />Doing fileprotect conversion<br />Restoring nobody owned filesDone<br />\n<br />Restoring Mail filesDone<br />\n<br />Restoring userdata....\nDone<br />\n<br /><br />Restoring custom virtualhost templates....\nConverting email to cPanel 5+ (if needed)<blockquote><pre></pre></blockquote>Done<br />\n<br />Cleaning up filters (if needed)<blockquote><pre>vfilter converter v3.0Updating vfilter files to latest format.Running for user only (force=0) (has_spam_acl=1)Processing user......Done</pre></blockquote>Done<br />\n<br />Fixing mail permissions<blockquote><pre></pre></blockquote>Done<br />\n<br />Restoring crontabDone<br />\nConverting to maildir if needed<blockquote><pre></pre></blockquote>Done<br />\nRestoring Dns Zones<blockquote><pre>Restoring zone: user.com.db\n</pre></blockquote><br />Adding missing subdomain DNS entries (if needed)<pre></pre><br />Update Proxy subomains<blockquote><pre>Adding proxy subdomains for domain example.com.Records Installed</pre></blockquote>Done<br />\n<br />Updating SPF Records<blockquote><pre></pre></blockquote>Done<br />\n<br />Restoring quota<blockquote><pre></pre></blockquote>Done<br />\n<br /><br />Update mail routing<blockquote><pre>LOCAL MAIL EXCHANGER: This server will serve as a primary mail exchanger for example.com's mail.: This configuration has been manually selected.\n</pre></blockquote>Done<br />\n<br />Rebuilding Apache Conf<br />Restore CompleteAccount Restore Complete\nUnlocking password for user user.passwd: Success.<br />"
      }
   }
}

Topic revision: r13 - 22 Apr 2013 - 16:06:29 - Main.StacyWyatt
AllDocumentation/AutomationIntegration.RestoreAccount moved from Sandbox.RestoreAccount on 01 Jul 2010 - 16:35 by Main.JustinSchaefer