Version Description
- Updates: Wordpress 4.0 support
- Feature: Add support for large database restore.
- Feature: Add database checkpoint recovery for database restore failures
- Feature: Add restore logging on all restores
- Fix: Correct bug on restore when table prefix doesn't match.
Download this release
Release Info
Developer | cssimmon |
Plugin | Backup and Restore WordPress – WPBackItUp Backup Plugin |
Version | 1.8 |
Comparing to | |
See all releases |
Code changes from version 1.7.5.1 to 1.8
- lib/includes/backup.php +13 -2
- lib/includes/class-logger.php +4 -1
- lib/includes/class-sql.php +101 -2
- lib/includes/class-wpbackitup-admin.php +8 -4
- lib/includes/restore.php +71 -20
- readme.txt +9 -3
- views/restore.php +1 -0
- wp-backitup.php +2 -2
lib/includes/backup.php
CHANGED
@@ -260,8 +260,19 @@ function create_SiteInfoFile($path){
|
|
260 |
function create_siteinfo($path, $table_prefix) {
|
261 |
$siteinfo = $path ."backupsiteinfo.txt";
|
262 |
$handle = fopen($siteinfo, 'w+');
|
263 |
-
|
264 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
fclose($handle);
|
266 |
return true;
|
267 |
}
|
260 |
function create_siteinfo($path, $table_prefix) {
|
261 |
$siteinfo = $path ."backupsiteinfo.txt";
|
262 |
$handle = fopen($siteinfo, 'w+');
|
263 |
+
|
264 |
+
//Write Site URL
|
265 |
+
$entry = site_url( '/' ) ."\n";
|
266 |
+
fwrite($handle, $entry);
|
267 |
+
|
268 |
+
//Write Table Prefix
|
269 |
+
$entry = $table_prefix ."\n" ;
|
270 |
+
fwrite($handle, $entry);
|
271 |
+
|
272 |
+
//write WP version
|
273 |
+
$entry =get_bloginfo( 'version')."\n" ;
|
274 |
+
fwrite($handle, $entry);
|
275 |
+
|
276 |
fclose($handle);
|
277 |
return true;
|
278 |
}
|
lib/includes/class-logger.php
CHANGED
@@ -17,11 +17,14 @@ class WPBackItUp_Logger {
|
|
17 |
public $logFileName;
|
18 |
public $logFilePath;
|
19 |
|
20 |
-
public function __construct($delete_log, $path=null, $file_name=null) {
|
21 |
global $WPBackitup;
|
22 |
|
23 |
$this->logging = $WPBackitup->logging();
|
24 |
|
|
|
|
|
|
|
25 |
//check for optional parms
|
26 |
if (!is_string($path)){
|
27 |
$path = WPBACKITUP__PLUGIN_PATH .'/logs';
|
17 |
public $logFileName;
|
18 |
public $logFilePath;
|
19 |
|
20 |
+
public function __construct($delete_log, $path=null, $file_name=null, $debugOverride=false) {
|
21 |
global $WPBackitup;
|
22 |
|
23 |
$this->logging = $WPBackitup->logging();
|
24 |
|
25 |
+
//If override debug flag then turn logging on.
|
26 |
+
if (true===$debugOverride) $this->logging=true;
|
27 |
+
|
28 |
//check for optional parms
|
29 |
if (!is_string($path)){
|
30 |
$path = WPBACKITUP__PLUGIN_PATH .'/logs';
|
lib/includes/class-sql.php
CHANGED
@@ -255,7 +255,7 @@ class WPBackItUp_SQL {
|
|
255 |
return true;
|
256 |
}
|
257 |
|
258 |
-
public function
|
259 |
$this->logger->log('(SQL.run_sql_manual)SQL Execute:' .$sql_file);
|
260 |
|
261 |
//Is the backup sql file empty
|
@@ -276,15 +276,21 @@ class WPBackItUp_SQL {
|
|
276 |
return false;
|
277 |
}
|
278 |
|
|
|
|
|
279 |
if($mysqli->multi_query($query))
|
280 |
{
|
281 |
do {
|
|
|
|
|
282 |
/* store first result set */
|
283 |
if($resultSet = $mysqli->store_result())
|
284 |
{
|
|
|
|
|
285 |
while($row = $resultSet->fetch_row())
|
286 |
{
|
287 |
-
|
288 |
}
|
289 |
$resultSet->free();
|
290 |
}
|
@@ -293,6 +299,7 @@ class WPBackItUp_SQL {
|
|
293 |
|
294 |
} while ($mysqli->next_result());
|
295 |
|
|
|
296 |
$mysqli->close();
|
297 |
}
|
298 |
|
@@ -306,6 +313,98 @@ class WPBackItUp_SQL {
|
|
306 |
return true;
|
307 |
}
|
308 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
private function get_sqlconnection() {
|
310 |
$this->logger->log('(SQL.get_sqlconnection)Get SQL connection to database.');
|
311 |
$db_name = DB_NAME;
|
255 |
return true;
|
256 |
}
|
257 |
|
258 |
+
public function run_sql_manual_OLD($sql_file) {
|
259 |
$this->logger->log('(SQL.run_sql_manual)SQL Execute:' .$sql_file);
|
260 |
|
261 |
//Is the backup sql file empty
|
276 |
return false;
|
277 |
}
|
278 |
|
279 |
+
$ctr=1;
|
280 |
+
$this->logger->log('(SQL.run_sql_manual) 0: here ');
|
281 |
if($mysqli->multi_query($query))
|
282 |
{
|
283 |
do {
|
284 |
+
|
285 |
+
$this->logger->log('(SQL.run_sql_manual) 1: ' .$ctr++);
|
286 |
/* store first result set */
|
287 |
if($resultSet = $mysqli->store_result())
|
288 |
{
|
289 |
+
$this->logger->log('(SQL.run_sql_manual) 2: ');
|
290 |
+
|
291 |
while($row = $resultSet->fetch_row())
|
292 |
{
|
293 |
+
$this->logger->log('(SQL.run_sql_manual) 3: ');
|
294 |
}
|
295 |
$resultSet->free();
|
296 |
}
|
299 |
|
300 |
} while ($mysqli->next_result());
|
301 |
|
302 |
+
$this->logger->log('(SQL.run_sql_manual) 4: ');
|
303 |
$mysqli->close();
|
304 |
}
|
305 |
|
313 |
return true;
|
314 |
}
|
315 |
|
316 |
+
function run_sql_manual($sql_file_path, $delimiter = ';')
|
317 |
+
{
|
318 |
+
$this->logger->log('(SQL.run_sql_manual)SQL Execute:' .$sql_file_path);
|
319 |
+
set_time_limit(0);
|
320 |
+
|
321 |
+
//Is the backup sql file empty
|
322 |
+
if (!file_exists($sql_file_path) || filesize($sql_file_path)<=0) {
|
323 |
+
$this->logger->log('(SQL.run_sql_manual) Failure: SQL File was empty:' .$sql_file_path);
|
324 |
+
return false;
|
325 |
+
}
|
326 |
+
|
327 |
+
try {
|
328 |
+
if (is_file($sql_file_path) === true)
|
329 |
+
{
|
330 |
+
$sql_handle = fopen($sql_file_path, 'r');
|
331 |
+
|
332 |
+
if (is_resource($sql_handle) === true)
|
333 |
+
{
|
334 |
+
$query = array();
|
335 |
+
|
336 |
+
$mysqli = $this->get_sqlconnection();
|
337 |
+
$mysqli->set_charset('utf8');
|
338 |
+
// $mysqli->autocommit(FALSE);
|
339 |
+
// $mysqli->begin_transaction();
|
340 |
+
|
341 |
+
if (false===$mysqli) {
|
342 |
+
return false;
|
343 |
+
}
|
344 |
+
|
345 |
+
$error_count=0;
|
346 |
+
$total_query=0;
|
347 |
+
while (feof($sql_handle) === false)
|
348 |
+
{
|
349 |
+
$query[] = fgets($sql_handle);
|
350 |
+
|
351 |
+
if (preg_match('~' . preg_quote($delimiter, '~') . '\s*$~iS', end($query)) === 1)
|
352 |
+
{
|
353 |
+
$query = trim(implode('', $query));
|
354 |
+
|
355 |
+
//Execute SQL statement
|
356 |
+
$total_query++;
|
357 |
+
if ($mysqli->query($query) === false) {
|
358 |
+
$error_count++;
|
359 |
+
|
360 |
+
$this->logger->log('(SQL.run_sql_manual)Total Queries Executed:' .$total_query);
|
361 |
+
$this->logger->log('(SQL.run_sql_manual)Query Errors:' .$error_count);
|
362 |
+
|
363 |
+
$this->logger->log('(SQL.run_sql_manual) SQL ERROR: ' . $query);
|
364 |
+
|
365 |
+
//$mysqli->rollback();
|
366 |
+
$mysqli->close();
|
367 |
+
|
368 |
+
fclose($sql_handle);
|
369 |
+
return false;
|
370 |
+
}
|
371 |
+
// else {
|
372 |
+
// $this->logger->log('(SQL.run_sql_manual) SUCCESS: ' . $query);
|
373 |
+
// }
|
374 |
+
|
375 |
+
while (ob_get_level() > 0)
|
376 |
+
{
|
377 |
+
ob_end_flush();
|
378 |
+
}
|
379 |
+
|
380 |
+
flush();
|
381 |
+
}
|
382 |
+
|
383 |
+
if (is_string($query) === true)
|
384 |
+
{
|
385 |
+
$query = array();
|
386 |
+
}
|
387 |
+
}
|
388 |
+
|
389 |
+
//$mysqli->commit();
|
390 |
+
$mysqli->close();
|
391 |
+
|
392 |
+
$this->logger->log('(SQL.run_sql_manual)SQL Executed successfully:' .$sql_file_path);
|
393 |
+
$this->logger->log('(SQL.run_sql_manual)Total Queries Executed:' .$total_query);
|
394 |
+
$this->logger->log('(SQL.run_sql_manual)Query Errors:' .$error_count);
|
395 |
+
return fclose($sql_handle);
|
396 |
+
}
|
397 |
+
}
|
398 |
+
|
399 |
+
}catch(Exception $e) {
|
400 |
+
$this->logger->log('(SQL.run_sql_manual) Exception: ' .$e);
|
401 |
+
return false;
|
402 |
+
}
|
403 |
+
|
404 |
+
$this->logger->log('(SQL.run_sql_manual)SQL File could not be opened:' .$sql_file_path);
|
405 |
+
return false;
|
406 |
+
}
|
407 |
+
|
408 |
private function get_sqlconnection() {
|
409 |
$this->logger->log('(SQL.get_sqlconnection)Get SQL connection to database.');
|
410 |
$db_name = DB_NAME;
|
lib/includes/class-wpbackitup-admin.php
CHANGED
@@ -459,11 +459,16 @@ class WPBackitup_Admin {
|
|
459 |
$this->set_option('lite_registration_email', $email);
|
460 |
|
461 |
//register with mail chimp
|
462 |
-
|
463 |
$mailchimp_form_id = '8e8e45c83b'; //PRD
|
464 |
|
|
|
|
|
|
|
465 |
|
466 |
$form_data = array(
|
|
|
|
|
467 |
'yks-mailchimp-list-ct'=>'0',
|
468 |
'yks-mailchimp-list-id'=>$mailchimp_form_id,
|
469 |
$mailchimp_form_id .'EMAIL' => $email,
|
@@ -474,8 +479,7 @@ class WPBackitup_Admin {
|
|
474 |
|
475 |
//URL Encode the Form Data
|
476 |
$form_data=http_build_query($form_data);
|
477 |
-
|
478 |
-
$post_url=WPBACKITUP__SECURESITE_URL . '/wp-admin/admin-ajax.php';
|
479 |
|
480 |
$logger->log('Lite User Registration Post URL: ' .$post_url);
|
481 |
$logger->log('Lite User Registration Post Form Data: ' .$form_data);
|
@@ -488,7 +492,7 @@ class WPBackitup_Admin {
|
|
488 |
'blocking' => true,
|
489 |
'headers' => array(),
|
490 |
'body' => array(
|
491 |
-
|
492 |
, 'form_action' => 'frontend_submit_form'
|
493 |
, 'form_data' => $form_data
|
494 |
),
|
459 |
$this->set_option('lite_registration_email', $email);
|
460 |
|
461 |
//register with mail chimp
|
462 |
+
//$mailchimp_form_id = '5e70c18c53'; //DEV
|
463 |
$mailchimp_form_id = '8e8e45c83b'; //PRD
|
464 |
|
465 |
+
$url = WPBACKITUP__SECURESITE_URL; //PRD
|
466 |
+
//$url="http://localhost/dev.wpbackitup.com"; //DEV
|
467 |
+
|
468 |
|
469 |
$form_data = array(
|
470 |
+
// '_wpnonce'=>'d0c887e966',
|
471 |
+
// '_wp_http_referer'=>'/' .$url .'/test-newsletter-signup',
|
472 |
'yks-mailchimp-list-ct'=>'0',
|
473 |
'yks-mailchimp-list-id'=>$mailchimp_form_id,
|
474 |
$mailchimp_form_id .'EMAIL' => $email,
|
479 |
|
480 |
//URL Encode the Form Data
|
481 |
$form_data=http_build_query($form_data);
|
482 |
+
$post_url=$url . '/wp-admin/admin-ajax.php';
|
|
|
483 |
|
484 |
$logger->log('Lite User Registration Post URL: ' .$post_url);
|
485 |
$logger->log('Lite User Registration Post Form Data: ' .$form_data);
|
492 |
'blocking' => true,
|
493 |
'headers' => array(),
|
494 |
'body' => array(
|
495 |
+
'action' => 'yks_mailchimp_form'
|
496 |
, 'form_action' => 'frontend_submit_form'
|
497 |
, 'form_data' => $form_data
|
498 |
),
|
lib/includes/restore.php
CHANGED
@@ -32,6 +32,7 @@ global $table_prefix; //this is from wp-config
|
|
32 |
|
33 |
global $backup_file_name; //name of the backup file
|
34 |
global $backup_file_path; //full path to zip file on server
|
|
|
35 |
|
36 |
global $status_array,$inactive,$active,$complete,$failure,$warning,$success;
|
37 |
$inactive=0;
|
@@ -53,8 +54,12 @@ $status_array = array(
|
|
53 |
'cleanup'=>$inactive
|
54 |
);
|
55 |
|
|
|
|
|
|
|
|
|
56 |
global $logger;
|
57 |
-
$logger = new WPBackItUp_Logger(
|
58 |
|
59 |
global $wp_restore; //Eventually everything will be migrated to this class
|
60 |
$wp_restore = new WPBackItUp_Restore($logger);
|
@@ -96,39 +101,49 @@ set_status('preparing',$active,true);
|
|
96 |
//set path to backup file
|
97 |
$backup_file_path = $wp_restore->backup_folder_path .$backup_file_name ;
|
98 |
|
99 |
-
$logger->log('DELETE RESTORE FOLDER');
|
100 |
delete_restore_folder();
|
|
|
101 |
|
102 |
-
$logger->log('CREATE RESTORE FOLDER');
|
103 |
create_restore_folder($wp_restore->restore_folder_path);
|
104 |
set_status('preparing',$complete,false);
|
|
|
105 |
|
106 |
-
$logger->log('UNZIP BACKUP');
|
107 |
set_status('unzipping',$active,true);
|
108 |
unzip_backup($backup_file_path,$wp_restore->restore_folder_path);
|
109 |
set_status('unzipping',$complete,false);
|
|
|
|
|
110 |
|
111 |
-
$logger->log('VALIDATE BACKUP');
|
112 |
set_status('validation',$active,true);
|
113 |
$restoration_dir_path=validate_restore_folder($wp_restore->restore_folder_path);
|
|
|
114 |
|
115 |
-
$backupSQLFile = $restoration_dir_path . WPBACKITUP__SQL_DBBACKUP_FILENAME;
|
116 |
|
117 |
-
$logger->log('VALIDATE SQL');
|
|
|
118 |
validate_SQL_exists($backupSQLFile);
|
|
|
|
|
119 |
|
|
|
120 |
$siteurl = get_siteurl();
|
121 |
$homeurl = get_homeurl();
|
122 |
$user_login = get_user_login($user_id);
|
123 |
$user_pass = get_user_pass($user_id);
|
124 |
$user_email = get_user_email($user_id);
|
|
|
125 |
|
126 |
//Collect previous backup site url start
|
127 |
-
$logger->log('
|
128 |
$import_siteinfo_lines = file($restoration_dir_path .'backupsiteinfo.txt');
|
129 |
-
$import_siteurl = trim($import_siteinfo_lines[0]);
|
130 |
$current_siteurl = trim($siteurl ,'/');
|
131 |
-
$import_table_prefix =
|
|
|
132 |
$logger->log($import_siteinfo_lines);
|
133 |
|
134 |
//Check table prefix values FATAL
|
@@ -137,50 +152,74 @@ if($table_prefix !=$import_table_prefix) {
|
|
137 |
write_warning_status('error221');
|
138 |
}
|
139 |
|
|
|
140 |
|
|
|
141 |
//Create restore point for DB
|
142 |
set_status('validation',$complete,false);
|
143 |
set_status('restore_point',$active,true);
|
144 |
$RestorePoint_SQL = backup_database($wp_restore->backup_folder_path); //Save in backup folder
|
145 |
-
|
146 |
set_status('restore_point',$complete,false);
|
|
|
147 |
|
|
|
|
|
148 |
//Import the backed up database
|
149 |
set_status('database',$active,true);
|
150 |
-
import_backedup_database($backupSQLFile);
|
|
|
|
|
151 |
|
|
|
152 |
//FAILURES AFTER THIS POINT SHOULD REQUIRE ROLLBACK OF DB
|
153 |
update_user_credentials($import_table_prefix, $user_login, $user_pass, $user_email, $user_id);
|
154 |
-
|
155 |
update_siteurl($import_table_prefix, $current_siteurl);
|
156 |
-
|
157 |
update_homeurl($import_table_prefix, $homeurl);
|
|
|
158 |
|
159 |
//Done with DB restore
|
160 |
set_status('database',$complete,false);
|
161 |
|
|
|
|
|
162 |
//***DEAL WITH WPCONTENT NOW ***
|
163 |
set_status('wpcontent',$active,true);
|
|
|
164 |
delete_plugins_content();
|
|
|
|
|
|
|
165 |
delete_themes_content();
|
|
|
166 |
|
|
|
167 |
//delete whatever is left
|
168 |
$wpcontent_folder=WPBACKITUP__CONTENT_PATH;
|
169 |
delete_wpcontent_content($wpcontent_folder);
|
|
|
170 |
|
|
|
171 |
restore_wpcontent($restoration_dir_path);
|
172 |
set_status('wpcontent',$complete,false);
|
|
|
|
|
|
|
173 |
validate_wpcontent($restoration_dir_path,$wpcontent_folder);
|
|
|
174 |
|
|
|
175 |
update_permalinks();
|
|
|
|
|
176 |
|
|
|
177 |
set_status('cleanup',$active,true);
|
178 |
cleanup_restore_folder($restoration_dir_path);
|
179 |
set_status('cleanup',$complete,false);
|
180 |
-
|
181 |
|
|
|
182 |
$logger->log('Restore completed successfully');
|
183 |
-
|
184 |
$logger->log('***END RESTORE***');
|
185 |
die();
|
186 |
|
@@ -361,7 +400,7 @@ function validate_SQL_exists($backupSQLFile){
|
|
361 |
function restore_database(){
|
362 |
global $logger;
|
363 |
global $RestorePoint_SQL;
|
364 |
-
$logger->log('Restore the DB to previous state
|
365 |
|
366 |
$dbc = new WPBackItUp_SQL($logger);
|
367 |
if(!$dbc->run_sql_exec($RestorePoint_SQL)) {
|
@@ -378,8 +417,9 @@ function restore_database(){
|
|
378 |
}
|
379 |
|
380 |
//Run DB restore
|
381 |
-
function import_backedup_database($backupSQLFile){
|
382 |
global $logger;
|
|
|
383 |
$logger->log('Import the backed up database.');
|
384 |
//Try SQL Import first
|
385 |
|
@@ -388,8 +428,19 @@ function import_backedup_database($backupSQLFile){
|
|
388 |
//Do it manually if the import doesnt work
|
389 |
if(!$dbc->run_sql_manual($backupSQLFile)) {
|
390 |
$logger->log('Error: Database import error.');
|
391 |
-
|
392 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
393 |
die();
|
394 |
}
|
395 |
}
|
32 |
|
33 |
global $backup_file_name; //name of the backup file
|
34 |
global $backup_file_path; //full path to zip file on server
|
35 |
+
global $RestorePoint_SQL; //path to restore point
|
36 |
|
37 |
global $status_array,$inactive,$active,$complete,$failure,$warning,$success;
|
38 |
$inactive=0;
|
54 |
'cleanup'=>$inactive
|
55 |
);
|
56 |
|
57 |
+
$fileUTCDateTime=current_time( 'timestamp' );
|
58 |
+
$localDateTime = date_i18n('Y-m-d-His',$fileUTCDateTime);
|
59 |
+
$log_filename = 'restorelog_'.'_' .$localDateTime;
|
60 |
+
|
61 |
global $logger;
|
62 |
+
$logger = new WPBackItUp_Logger(false,null,$log_filename,true);
|
63 |
|
64 |
global $wp_restore; //Eventually everything will be migrated to this class
|
65 |
$wp_restore = new WPBackItUp_Restore($logger);
|
101 |
//set path to backup file
|
102 |
$backup_file_path = $wp_restore->backup_folder_path .$backup_file_name ;
|
103 |
|
104 |
+
$logger->log('**DELETE RESTORE FOLDER**');
|
105 |
delete_restore_folder();
|
106 |
+
$logger->log('** END DELETE RESTORE FOLDER**');
|
107 |
|
108 |
+
$logger->log('**CREATE RESTORE FOLDER**');
|
109 |
create_restore_folder($wp_restore->restore_folder_path);
|
110 |
set_status('preparing',$complete,false);
|
111 |
+
$logger->log('**END CREATE RESTORE FOLDER**');
|
112 |
|
113 |
+
$logger->log('**UNZIP BACKUP**');
|
114 |
set_status('unzipping',$active,true);
|
115 |
unzip_backup($backup_file_path,$wp_restore->restore_folder_path);
|
116 |
set_status('unzipping',$complete,false);
|
117 |
+
$logger->log('**END UNZIP BACKUP**');
|
118 |
+
|
119 |
|
120 |
+
$logger->log('**VALIDATE BACKUP**');
|
121 |
set_status('validation',$active,true);
|
122 |
$restoration_dir_path=validate_restore_folder($wp_restore->restore_folder_path);
|
123 |
+
$logger->log('**END VALIDATE BACKUP**');
|
124 |
|
|
|
125 |
|
126 |
+
$logger->log('**VALIDATE SQL FILE EXISTS**');
|
127 |
+
$backupSQLFile = $restoration_dir_path . WPBACKITUP__SQL_DBBACKUP_FILENAME;
|
128 |
validate_SQL_exists($backupSQLFile);
|
129 |
+
$logger->log('**END VALIDATE SQL FILE EXISTS**');
|
130 |
+
|
131 |
|
132 |
+
$logger->log('**GET SITE VALUES FROM DB**');
|
133 |
$siteurl = get_siteurl();
|
134 |
$homeurl = get_homeurl();
|
135 |
$user_login = get_user_login($user_id);
|
136 |
$user_pass = get_user_pass($user_id);
|
137 |
$user_email = get_user_email($user_id);
|
138 |
+
$logger->log('**END GET SITE VALUES FROM DB**');
|
139 |
|
140 |
//Collect previous backup site url start
|
141 |
+
$logger->log('**GET backupsiteinfo.txt VALUES**');
|
142 |
$import_siteinfo_lines = file($restoration_dir_path .'backupsiteinfo.txt');
|
143 |
+
$import_siteurl = str_replace("\n", '',trim($import_siteinfo_lines[0]));
|
144 |
$current_siteurl = trim($siteurl ,'/');
|
145 |
+
$import_table_prefix = str_replace("\n", '',$import_siteinfo_lines[1]);
|
146 |
+
$import_wp_version = str_replace("\n", '',$import_siteinfo_lines[2]);
|
147 |
$logger->log($import_siteinfo_lines);
|
148 |
|
149 |
//Check table prefix values FATAL
|
152 |
write_warning_status('error221');
|
153 |
}
|
154 |
|
155 |
+
$logger->log('**END GET backupsiteinfo.txt VALUES**');
|
156 |
|
157 |
+
$logger->log('**CREATE RESTORE POINT**');
|
158 |
//Create restore point for DB
|
159 |
set_status('validation',$complete,false);
|
160 |
set_status('restore_point',$active,true);
|
161 |
$RestorePoint_SQL = backup_database($wp_restore->backup_folder_path); //Save in backup folder
|
|
|
162 |
set_status('restore_point',$complete,false);
|
163 |
+
$logger->log('**END CREATE RESTORE POINT**');
|
164 |
|
165 |
+
|
166 |
+
$logger->log('**RESTORE DATABASE**');
|
167 |
//Import the backed up database
|
168 |
set_status('database',$active,true);
|
169 |
+
import_backedup_database($backupSQLFile,$RestorePoint_SQL);
|
170 |
+
$logger->log('**END RESTORE DATABASE**');
|
171 |
+
|
172 |
|
173 |
+
$logger->log('**UPDATE DATABASE VALUES**');
|
174 |
//FAILURES AFTER THIS POINT SHOULD REQUIRE ROLLBACK OF DB
|
175 |
update_user_credentials($import_table_prefix, $user_login, $user_pass, $user_email, $user_id);
|
|
|
176 |
update_siteurl($import_table_prefix, $current_siteurl);
|
|
|
177 |
update_homeurl($import_table_prefix, $homeurl);
|
178 |
+
$logger->log('**END UPDATE DATABASE VALUES**');
|
179 |
|
180 |
//Done with DB restore
|
181 |
set_status('database',$complete,false);
|
182 |
|
183 |
+
|
184 |
+
|
185 |
//***DEAL WITH WPCONTENT NOW ***
|
186 |
set_status('wpcontent',$active,true);
|
187 |
+
$logger->log('**DELETE PLUGINS**');
|
188 |
delete_plugins_content();
|
189 |
+
$logger->log('**END DELETE PLUGINS**');
|
190 |
+
|
191 |
+
$logger->log('**DELETE THEMES**');
|
192 |
delete_themes_content();
|
193 |
+
$logger->log('**END DELETE THEMES**');
|
194 |
|
195 |
+
$logger->log('**DELETE WPCONTENT**');
|
196 |
//delete whatever is left
|
197 |
$wpcontent_folder=WPBACKITUP__CONTENT_PATH;
|
198 |
delete_wpcontent_content($wpcontent_folder);
|
199 |
+
$logger->log('**END DELETE WPCONTENT**');
|
200 |
|
201 |
+
$logger->log('**RESTORE WPCONTENT**');
|
202 |
restore_wpcontent($restoration_dir_path);
|
203 |
set_status('wpcontent',$complete,false);
|
204 |
+
$logger->log('**END DELETE WPCONTENT**');
|
205 |
+
|
206 |
+
$logger->log('**VALIDATE WPCONTENT**');
|
207 |
validate_wpcontent($restoration_dir_path,$wpcontent_folder);
|
208 |
+
$logger->log('**END VALIDATE WPCONTENT**');
|
209 |
|
210 |
+
$logger->log('**UPDATE PERMALINKS**');
|
211 |
update_permalinks();
|
212 |
+
$logger->log('**END UPDATE PERMALINKS**');
|
213 |
+
|
214 |
|
215 |
+
$logger->log('**CLEANUP**');
|
216 |
set_status('cleanup',$active,true);
|
217 |
cleanup_restore_folder($restoration_dir_path);
|
218 |
set_status('cleanup',$complete,false);
|
219 |
+
$logger->log('**END CLEANUP**');
|
220 |
|
221 |
+
set_status_success();
|
222 |
$logger->log('Restore completed successfully');
|
|
|
223 |
$logger->log('***END RESTORE***');
|
224 |
die();
|
225 |
|
400 |
function restore_database(){
|
401 |
global $logger;
|
402 |
global $RestorePoint_SQL;
|
403 |
+
$logger->log('Restore the DB to previous state:' . $RestorePoint_SQL);
|
404 |
|
405 |
$dbc = new WPBackItUp_SQL($logger);
|
406 |
if(!$dbc->run_sql_exec($RestorePoint_SQL)) {
|
417 |
}
|
418 |
|
419 |
//Run DB restore
|
420 |
+
function import_backedup_database($backupSQLFile,$restorePoint_SQL){
|
421 |
global $logger;
|
422 |
+
|
423 |
$logger->log('Import the backed up database.');
|
424 |
//Try SQL Import first
|
425 |
|
428 |
//Do it manually if the import doesnt work
|
429 |
if(!$dbc->run_sql_manual($backupSQLFile)) {
|
430 |
$logger->log('Error: Database import error.');
|
431 |
+
|
432 |
+
//Restore to checkpoint
|
433 |
+
if ($dbc->run_sql_manual($restorePoint_SQL)){
|
434 |
+
$logger->log('Database successfully restored to checkpoint.');
|
435 |
+
write_fatal_error_status('error230');
|
436 |
+
|
437 |
+
}
|
438 |
+
else {
|
439 |
+
$logger->log('Database NOT restored to checkpoint.');
|
440 |
+
write_fatal_error_status('error212');
|
441 |
+
}
|
442 |
+
|
443 |
+
delete_restore_folder();
|
444 |
die();
|
445 |
}
|
446 |
}
|
readme.txt
CHANGED
@@ -1,10 +1,9 @@
|
|
1 |
=== WP Backitup ===
|
2 |
Contributors: cssimmon,jcpeden
|
3 |
Donate link: http://www.wpbackitup.com
|
4 |
-
Tags: backup, back up, backups, backup wordpress, backup database, backup plugin, backup and restore, database, database backup, database restore, db, db backup, db restore, download database, full backup, mysql backup, restore, restore database,restore wordpress, restore wordpress backup,restoring wordpress, website backup, wordpress backup, wordpress restore, plugin,
|
5 |
-
backup buddy,
|
6 |
Requires at least: 3.8.0
|
7 |
-
Tested up to:
|
8 |
Stable tag: 1.7.5.1
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -147,6 +146,13 @@ Our online documentation and full list of FAQs can be found at [www.wpbackitup.c
|
|
147 |
3. When the backup has been created, click the download link to access a zipped backup of your site.
|
148 |
|
149 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
= 1.7.5.1 =
|
151 |
* This is a minor release with some small UI fixes.
|
152 |
* Feature: Add lite registration
|
1 |
=== WP Backitup ===
|
2 |
Contributors: cssimmon,jcpeden
|
3 |
Donate link: http://www.wpbackitup.com
|
4 |
+
Tags: backup, back up, backups, backup wordpress, backup database, backup plugin, backup and restore, database, database backup, database restore, db, db backup, db restore, download database, full backup, mysql backup, restore, restore database,restore wordpress, restore wordpress backup,restoring wordpress, website backup, wordpress backup, wordpress restore, plugin, backup buddy
|
|
|
5 |
Requires at least: 3.8.0
|
6 |
+
Tested up to: 4.0
|
7 |
Stable tag: 1.7.5.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
146 |
3. When the backup has been created, click the download link to access a zipped backup of your site.
|
147 |
|
148 |
== Changelog ==
|
149 |
+
= 1.8 =
|
150 |
+
* Updates: Wordpress 4.0 support
|
151 |
+
* Feature: Add support for large database restore.
|
152 |
+
* Feature: Add database checkpoint recovery for database restore failures
|
153 |
+
* Feature: Add restore logging on all restores
|
154 |
+
* Fix: Correct bug on restore when table prefix doesn't match.
|
155 |
+
|
156 |
= 1.7.5.1 =
|
157 |
* This is a minor release with some small UI fixes.
|
158 |
* Feature: Add lite registration
|
views/restore.php
CHANGED
@@ -196,6 +196,7 @@ if (!$restore_folder_exists) {
|
|
196 |
<span class='error223'><div class='isa_error'><?php _e('Error 223: An error occurred during the restore. We attempted to restore the database to its previous state but were unsuccessful. Please contact WP BackItUp customer support and do not attempt to perform any further restores', $namespace); ?>.</div></span>
|
197 |
<span class='error224'><div class='isa_error'><?php _e('Error 224: An error occurred during the restore, however, we have successfully restored your database to the previous state', $namespace); ?>.</div></span>
|
198 |
<span class='error225'><div class='isa_error'><?php _e('Error 225: Restore option is only available to licensed WP BackItUp users', $namespace); ?>.</div></span>
|
|
|
199 |
</div>
|
200 |
|
201 |
<!--restore success messages-->
|
196 |
<span class='error223'><div class='isa_error'><?php _e('Error 223: An error occurred during the restore. We attempted to restore the database to its previous state but were unsuccessful. Please contact WP BackItUp customer support and do not attempt to perform any further restores', $namespace); ?>.</div></span>
|
197 |
<span class='error224'><div class='isa_error'><?php _e('Error 224: An error occurred during the restore, however, we have successfully restored your database to the previous state', $namespace); ?>.</div></span>
|
198 |
<span class='error225'><div class='isa_error'><?php _e('Error 225: Restore option is only available to licensed WP BackItUp users', $namespace); ?>.</div></span>
|
199 |
+
<span class="error230"><div class='isa_error'><?php _e('Error 230: WP BackItUp ran into unexpected errors during the database restore. However, we were able to successfully revert the database back to its original state . This error may require importing the database manually', $namespace); ?>.</div></span>
|
200 |
</div>
|
201 |
|
202 |
<!--restore success messages-->
|
wp-backitup.php
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
Plugin Name: WP Backitup
|
13 |
Plugin URI: http://www.wpbackitup.com
|
14 |
Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
|
15 |
-
Version: 1.
|
16 |
Author: Chris Simmons
|
17 |
Author URI: http://www.wpbackitup.com
|
18 |
License: GPL3
|
@@ -34,7 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
34 |
*/
|
35 |
|
36 |
define( 'WPBACKITUP__NAMESPACE', 'wp-backitup' );
|
37 |
-
define( 'WPBACKITUP__VERSION', '1.
|
38 |
define( 'WPBACKITUP__DEBUG', false );
|
39 |
define( 'WPBACKITUP__MINIMUM_WP_VERSION', '3.0' );
|
40 |
define( 'WPBACKITUP__ITEM_NAME', 'WP Backitup' );
|
12 |
Plugin Name: WP Backitup
|
13 |
Plugin URI: http://www.wpbackitup.com
|
14 |
Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
|
15 |
+
Version: 1.8
|
16 |
Author: Chris Simmons
|
17 |
Author URI: http://www.wpbackitup.com
|
18 |
License: GPL3
|
34 |
*/
|
35 |
|
36 |
define( 'WPBACKITUP__NAMESPACE', 'wp-backitup' );
|
37 |
+
define( 'WPBACKITUP__VERSION', '1.8');
|
38 |
define( 'WPBACKITUP__DEBUG', false );
|
39 |
define( 'WPBACKITUP__MINIMUM_WP_VERSION', '3.0' );
|
40 |
define( 'WPBACKITUP__ITEM_NAME', 'WP Backitup' );
|