Page tree
Skip to end of metadata
Go to start of metadata

 

Description

This function restores a file from a backup to the file's original location.

Examples


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsessXXXXXXXXXXXX/execute/Restore/restore_file?backupID=2017-07-03&fullpath=%2Fpublic_html%2Findex.php&overwrite=1

Note:

This example calls the UAPI function via a cPanel session. For more information, read our Guide to UAPI documentation. 

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.

// get a directory listing of all backups for user
$DAV = $cpanel->uapi(
    'Restore', 'restore_file',
    array(
        'backupID'  => '2017-07-03',
        'fullpath' => '/public_html/index.php',
        'overwrite' => 1,
    )
 );

Unable to render {include} The included page could not be found.

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.

# get a directory listing of all backups for user
my $disable_shared_global_addressbook = $cpliveapi->uapi(
    'Restore', 'restore_file',
    {
        'backupID'  => '2017-07-03',
        'fullpath' => '/public_html/index.php',
        'overwrite' => 1,
    }
 );

Note:

For more information, read our Guide to the LiveAPI System.

 cPanel Template Toolkit
<!--  get a directory listing of all backups for user -->
[% data = execute( 'Restore', 'restore_file'{ 'backupID' => '2017-07-03', 'fullpath' => '/public_html/index.php', 'overwrite' => 1 } ); %]
[% FOREACH q = data %]
     <p>
         success: [% q.success %]
     </p>
[% END %]

Note:

For more information, read our Guide to Template Toolkit documentation. 

 Command Line
uapi --user=example Restore restore_file backupID=2017-07-03 fullpath=/public_html/index.php overwrite=1

Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • We introduced this functionality in cPanel & WHM version 56.

 Output (JSON)
{  
   "result":{  
      "metadata":{  

      },
      "data":{  
         "success":1
      },
      "errors":null,
      "status":1,
      "messages":null
   },
}


Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample
backupIDstring

Required.

The backup's identification.

  • YYYY-MM-DD — Restore a daily backup from the specified backup date, in YYYY-MM-DD format.
  • monthly/YYYY-MM-DD — Restore a monthly backup from the specified backup date, in YYYY-MM-DD format.
  • weekly/YYYY-MM-DD — Restore a weekly backup from the specified backup date, in YYYY-MM-DD format.
  • incremental — Restore a daily incremental backup.
  • monthly/incremental — Restore a monthly incremental backup.
  • weekly/incremental — Restore a weekly incremental backup.

Note:

 The date format, where: blah blah blah

2017-07-03
fullpath string

Required.

The fullpath of the file, within a backup, that you wish to restore.

Note:

The value of this parameter must begin with a forward slash (/).

Warning:

You must parse filenames properly to prevent a cross-site scripting (XSS) attack. 

A valid absolute path.

/public_html/index.php
overwriteBoolean

Required.

Whether to overwrite a file.

  • 1 — Overwrite the file.
  • 0 — Do not overwrite the file.
 1

 

Returns

ReturnTypeDescriptionPossible valuesExample
datahashA hash that contains the status of the operation.

This hash contains the success value.

 

success

Boolean

Whether the overwrite flag successfully overwrote a file.

This function returns this value under the data hash.

  • 1 — Success.
  • 0 — Failure.

1