1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| <?php
/*
* Edit the settings here
*/
// Your backup job title
$title = 'DEMO NK';
// Your desired backup archive. ONLY the file name and extension (without the path).
// The archive should be in the destination directory of the backup job
$fileName = 'mille245_demonk-original.sql.zip';
// true - restore files
// false - DON'T restore files
$files = true;
// true - restore database
// false - DON'T restore database
$database = true;
// Path to SmartBackup. Do not modify if restore.php is in SmartBackup's folder
// dirname(__FILE__) means 'the path to this file'
// For example if this file is located in /home/test/restore.php and SmartBackup is in /home/test/public_html/SmartBackup
// this needs to be set to dirname(__FILE__).'/public_html/SmartBackup'
$smartbackup_dir = dirname(__FILE__).'/public_html/1001web.ca/SmartBackup/';
/*
* The code which calls SmartBackup's functions to restore an archive is below.
* Do not modify it unless you know what you are doing.
*/
//error_reporting(0);
set_error_handler(create_function('$a, $b, $c, $d', 'throw new ErrorException($b, 0, $a, $c, $d);'), E_ERROR | E_RECOVERABLE_ERROR | E_USER_ERROR | E_USER_WARNING | E_WARNING);
require_once rtrim($smartbackup_dir, '/\\') . '/api/external.php';
$backup_model = StormModel::getInstance('backup_model');
$log_model = StormModel::getInstance('log_model');
$title = $backup_model->parseTitle($title);
$data = $backup_model->getByTitle($backup_model->getData(), $title);
/*if (!$data || !$backup_model->verifyArchive($data, $fileName))
{
die('Something is wrong. I can\'t find the backup job or the archive'. PHP_EOL);
}*/
echo "Restoring backup " . $title . " from " . $fileName . PHP_EOL;
try
{
@set_time_limit(0);
@ini_set('memory_limit', '256M');
}
catch (Exception $e) { }
try
{
$backup_model->restore($data, $fileName, $database, $files);
}
catch (Exception $e)
{
$log_model->Log(Storm::ToAbsolute('../logs/'. $title .'.txt'), "AUTO RESTORE - Error restoring archive: " . $e->__toString());
return new Status(500);
}
$log_model->Log(Storm::ToAbsolute('../logs/'. $title .'.txt'), "AUTO RESTORE - Restored " . $title . " from " . $fileName);
echo "The archive was restored". PHP_EOL; |
Partager