Backup and Restore WordPress – WPBackItUp Backup Plugin - Version 1.10.8

Version Description

  • UPDATE: Add database size logging
  • UPDATE: Add WordPress and WP BackItUp version info to support email
  • UPDATE: Add logging to verify work files exist
  • FIX: Add fix to handle special characters in file names
  • FIX: Add fix to handle datediff for php versions <=5.3
  • FIX: Add fix to version compare utility method
  • FIX: Add fix to recursive directory iterator for php versions < 5.3
  • FIX: Ignore backwpup folders during backup
  • FIX: Fix missing database port issue
  • FIX: Add logging and clearstatcache to backup files
  • FIX: Remove use of GLOB_BRACE
Download this release

Release Info

Developer cssimmon
Plugin Icon 128x128 Backup and Restore WordPress – WPBackItUp Backup Plugin
Version 1.10.8
Comparing to
See all releases

Code changes from version 1.10.7 to 1.10.8

lib/includes/class-backup.php CHANGED
@@ -206,7 +206,7 @@ class WPBackItUp_Backup {
206
  $this->logger->log_info(__METHOD__, 'Begin - Cleanup Backup Folder:' . $path);
207
 
208
  $fileSystem = new WPBackItUp_FileSystem($this->logger);
209
- $work_files = array_filter(glob($this->backup_project_path. '*.{txt,sql}',GLOB_BRACE), 'is_file');
210
 
211
  if(!$fileSystem ->delete_files($work_files)) {
212
  $this->logger->log_error(__METHOD__,'Work files could not be deleted');
@@ -217,23 +217,6 @@ class WPBackItUp_Backup {
217
  return true;
218
  }
219
 
220
- public function delete_site_data_files(){
221
- $path = $this->backup_project_path;
222
- $this->logger->log_info(__METHOD__, 'Begin - Cleanup Backup Folder:' . $path);
223
-
224
- $fileSystem = new WPBackItUp_FileSystem($this->logger);
225
- $work_files = array_filter(glob($this->backup_project_path. '*.{txt,sql}',GLOB_BRACE), 'is_file');
226
-
227
- if(!$fileSystem ->delete_files($work_files)) {
228
- $this->logger->log_error(__METHOD__,'Work files could not be deleted');
229
- return false;
230
- }
231
-
232
- $this->logger->log_info(__METHOD__,'End - Work Files Deleted');
233
- return true;
234
- }
235
-
236
-
237
  public function purge_old_files(){
238
  $this->logger->log_info(__METHOD__,'Begin');
239
  $fileSystem = new WPBackItUp_FileSystem( $this->logger);
@@ -332,6 +315,10 @@ class WPBackItUp_Backup {
332
  $sqlUtil = new WPBackItUp_SQL($this->logger);
333
  $this->logger->log_info(__METHOD__,'Begin - Export Database: ' .$sql_file_name);
334
 
 
 
 
 
335
  //Try SQLDump First
336
  $this->logger->log_info(__METHOD__,'Export DB with MYSQLDUMP');
337
  if(!$sqlUtil->mysqldump_export($sql_file_name) ) {
@@ -432,7 +419,7 @@ class WPBackItUp_Backup {
432
  try {
433
  $batch_counter = 0;
434
  $total_counter=0;
435
- $directory_iterator=new RecursiveDirectoryIterator($root_path,FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS | RecursiveIteratorIterator::CATCH_GET_CHILD);
436
  $item_iterator = new RecursiveIteratorIterator($directory_iterator,RecursiveIteratorIterator::SELF_FIRST);
437
 
438
  $datetime1 = new DateTime('now');
@@ -469,9 +456,17 @@ class WPBackItUp_Backup {
469
  }
470
 
471
  $datetime2 = new DateTime('now');
472
- $interval = $datetime1->diff($datetime2);
473
- $this->logger->log_info( __METHOD__, 'File Count/Time: ' .$total_counter . '-' . $interval->format('%s seconds'));
474
- return true;
 
 
 
 
 
 
 
 
475
 
476
  } catch(Exception $e) {
477
  $this->logger->log_error( __METHOD__, 'Exception: ' .$e);
@@ -534,14 +529,15 @@ class WPBackItUp_Backup {
534
  $this->logger->log_info( __METHOD__, 'Begin:' .$group_id);
535
 
536
  //create a separate log file for inventory
537
- $logger_inventory = new WPBackItUp_Logger(true,null,'debug_inventory_'.$group_id);
 
538
  $logger_inventory->log_info( __METHOD__, 'Root Path: ' .$root_path);
539
  $logger_inventory->log_info( __METHOD__, 'Exclude: ' .var_export($exclude,true));
540
  $logger_inventory->log_info( __METHOD__, '***');
541
  try {
542
  $batch_counter = 0;
543
  $total_counter=0;
544
- $directory_iterator=new RecursiveDirectoryIterator($root_path,FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS | RecursiveIteratorIterator::CATCH_GET_CHILD);
545
  $item_iterator = new RecursiveIteratorIterator($directory_iterator,RecursiveIteratorIterator::SELF_FIRST);
546
 
547
  $datetime1 = new DateTime('now');
@@ -551,15 +547,23 @@ class WPBackItUp_Backup {
551
  while ($item_iterator->valid()) {
552
  //Skip the item if its in the exclude array
553
  //This is a string compare starting in position 1
554
- $file_path = $item_iterator->getSubPathname();
 
 
 
 
 
 
555
  if ($this->strposa0($file_path, $exclude)===true) {
556
  $logger_inventory->log_info( __METHOD__, 'Skip: ' .$file_path);
557
  } else {
558
  if ( $item_iterator->isFile()) {
559
  if ($batch_counter>=$batch_insert_size){
 
560
  if (! $db->insert_job_items($sql,$logger_inventory)) {
561
  return false;
562
  }
 
563
  $sql="";
564
  $batch_counter=0;
565
  }
@@ -574,14 +578,27 @@ class WPBackItUp_Backup {
574
  }
575
 
576
  if ($batch_counter>0) {
 
577
  if (! $db->insert_job_items($sql,$logger_inventory)) {
578
  return false;
579
  }
 
580
  }
581
 
582
  $datetime2 = new DateTime('now');
583
- $interval = $datetime1->diff($datetime2);
584
- $this->logger->log_info( __METHOD__, 'File Count/Time: ' .$total_counter . '-' . $interval->format('%s seconds'));
 
 
 
 
 
 
 
 
 
 
 
585
  return true;
586
 
587
  } catch(Exception $e) {
@@ -654,9 +671,17 @@ class WPBackItUp_Backup {
654
  }
655
 
656
  $datetime2 = new DateTime('now');
657
- $interval = $datetime1->diff($datetime2);
658
- $this->logger->log_info( __METHOD__, 'File Count/Time: ' .$total_counter . '-' . $interval->format('%s seconds'));
659
- return true;
 
 
 
 
 
 
 
 
660
 
661
  } catch(Exception $e) {
662
  $this->logger->log_error( __METHOD__, 'Exception: ' .$e);
@@ -825,14 +850,34 @@ class WPBackItUp_Backup {
825
  return false;
826
  }
827
 
 
 
 
 
 
 
 
828
  //if there are no more files to add then rename the zip
829
  //Check to see if the file exists, it is possible that it does not if only empty folders were contained
830
  if(file_exists($zip_file_path) ) {
 
831
  if ( ! $this->add_zip_suffix( $batch_id,$zip_file_path ) ) {
 
832
  return false;
833
- }
 
 
 
 
 
 
 
 
 
834
  }
835
 
 
 
836
  //update the batch as done.
837
  $db->update_batch_complete($job_id,$batch_id);
838
 
@@ -888,16 +933,29 @@ class WPBackItUp_Backup {
888
  $current_zip_file=null;
889
  $zip=null;
890
  $file_counter=0;
 
 
 
 
891
  foreach($file_list as $file) {
892
  $batch_id = $file->batch_id;
893
  $item = $target_root .'/' .utf8_decode( $file->item );
894
 
895
  //get zip path
896
  $zip_file_path = sprintf('%s-%s-%s.zip',$this->backup_project_path . $this->backup_name, $content_type,$batch_id);
897
- if ($current_zip_file!=$zip_file_path){
 
 
 
 
898
  //$this->logger->log_info( __METHOD__, 'Zip File:' . $zip_file_path );
899
  if (! file_exists($zip_file_path)){
900
  $this->logger->log_error( __METHOD__, 'Zip File not found:' . $zip_file_path );
 
 
 
 
 
901
  return false;
902
  }
903
  $current_zip_file = $zip_file_path;
@@ -1188,4 +1246,4 @@ class WPBackItUp_Backup {
1188
  $this->logger->log_info(__METHOD__,'End');
1189
  }
1190
 
1191
- }
206
  $this->logger->log_info(__METHOD__, 'Begin - Cleanup Backup Folder:' . $path);
207
 
208
  $fileSystem = new WPBackItUp_FileSystem($this->logger);
209
+ $work_files = $fileSystem->get_fileonly_list($path, 'txt|sql');
210
 
211
  if(!$fileSystem ->delete_files($work_files)) {
212
  $this->logger->log_error(__METHOD__,'Work files could not be deleted');
217
  return true;
218
  }
219
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
  public function purge_old_files(){
221
  $this->logger->log_info(__METHOD__,'Begin');
222
  $fileSystem = new WPBackItUp_FileSystem( $this->logger);
315
  $sqlUtil = new WPBackItUp_SQL($this->logger);
316
  $this->logger->log_info(__METHOD__,'Begin - Export Database: ' .$sql_file_name);
317
 
318
+ //log database size
319
+ $db_size = $sqlUtil->get_table_rows();
320
+ $this->logger->log_info(__METHOD__,$db_size,"Table Size");
321
+
322
  //Try SQLDump First
323
  $this->logger->log_info(__METHOD__,'Export DB with MYSQLDUMP');
324
  if(!$sqlUtil->mysqldump_export($sql_file_name) ) {
419
  try {
420
  $batch_counter = 0;
421
  $total_counter=0;
422
+ $directory_iterator=new RecursiveDirectoryIterator($root_path, 4096 | 8192 | RecursiveIteratorIterator::CATCH_GET_CHILD);
423
  $item_iterator = new RecursiveIteratorIterator($directory_iterator,RecursiveIteratorIterator::SELF_FIRST);
424
 
425
  $datetime1 = new DateTime('now');
456
  }
457
 
458
  $datetime2 = new DateTime('now');
459
+
460
+ if(method_exists($datetime2, 'diff')) {
461
+ $interval = $datetime1->diff($datetime2);
462
+ $this->logger->log_info( __METHOD__, 'File Count/Time: ' .$total_counter . '-' . $interval->format('%s seconds'));
463
+ } else {
464
+ $util = new WPBackItUp_Utility($this->logger);
465
+ $interval = $util->date_diff_array($datetime1, $datetime2);
466
+ $this->logger->log_info(__METHOD__, 'File Count/Time: ' . $total_counter . '-' . $interval['second'] . ' seconds');
467
+ }
468
+
469
+ return true;
470
 
471
  } catch(Exception $e) {
472
  $this->logger->log_error( __METHOD__, 'Exception: ' .$e);
529
  $this->logger->log_info( __METHOD__, 'Begin:' .$group_id);
530
 
531
  //create a separate log file for inventory
532
+ $logger_inventory = new WPBackItUp_Logger(false,null,sprintf('debug_inventory_%s_%s',$group_id,$job_id));
533
+ $logger_inventory->log_info( __METHOD__, '**BEGIN**');
534
  $logger_inventory->log_info( __METHOD__, 'Root Path: ' .$root_path);
535
  $logger_inventory->log_info( __METHOD__, 'Exclude: ' .var_export($exclude,true));
536
  $logger_inventory->log_info( __METHOD__, '***');
537
  try {
538
  $batch_counter = 0;
539
  $total_counter=0;
540
+ $directory_iterator=new RecursiveDirectoryIterator($root_path, 4096 | 8192 | RecursiveIteratorIterator::CATCH_GET_CHILD);
541
  $item_iterator = new RecursiveIteratorIterator($directory_iterator,RecursiveIteratorIterator::SELF_FIRST);
542
 
543
  $datetime1 = new DateTime('now');
547
  while ($item_iterator->valid()) {
548
  //Skip the item if its in the exclude array
549
  //This is a string compare starting in position 1
550
+
551
+ //Fix the path to use backslash
552
+ $file_path = str_replace('\\', "/",$item_iterator->getSubPathname());
553
+
554
+ //Remove special characters
555
+ $file_path = esc_sql($file_path);
556
+
557
  if ($this->strposa0($file_path, $exclude)===true) {
558
  $logger_inventory->log_info( __METHOD__, 'Skip: ' .$file_path);
559
  } else {
560
  if ( $item_iterator->isFile()) {
561
  if ($batch_counter>=$batch_insert_size){
562
+ $logger_inventory->log_info( __METHOD__, '*Try Write Batch*');
563
  if (! $db->insert_job_items($sql,$logger_inventory)) {
564
  return false;
565
  }
566
+ $logger_inventory->log_info( __METHOD__, '*Write Batch SUCCESS*');
567
  $sql="";
568
  $batch_counter=0;
569
  }
578
  }
579
 
580
  if ($batch_counter>0) {
581
+ $logger_inventory->log_info( __METHOD__, '*Try Write Batch*');
582
  if (! $db->insert_job_items($sql,$logger_inventory)) {
583
  return false;
584
  }
585
+ $logger_inventory->log_info( __METHOD__, '*Write Batch SUCCESS*');
586
  }
587
 
588
  $datetime2 = new DateTime('now');
589
+
590
+ $logger_inventory->log_info( __METHOD__, '**END**');
591
+
592
+ if(method_exists($datetime2, 'diff')) {
593
+ $interval = $datetime1->diff($datetime2);
594
+ $this->logger->log_info( __METHOD__, 'File Count/Time: ' .$total_counter . '-' . $interval->format('%s seconds'));
595
+ } else {
596
+ $util = new WPBackItUp_Utility($this->logger);
597
+ $interval = $util->date_diff_array($datetime1, $datetime2);
598
+ $this->logger->log_info( __METHOD__, 'File Count/Time: ' .$total_counter . '-' . $interval['second'] . ' seconds');
599
+ }
600
+
601
+
602
  return true;
603
 
604
  } catch(Exception $e) {
671
  }
672
 
673
  $datetime2 = new DateTime('now');
674
+
675
+ if(method_exists($datetime2, 'diff')) {
676
+ $interval = $datetime1->diff($datetime2);
677
+ $this->logger->log_info( __METHOD__, 'File Count/Time: ' .$total_counter . '-' . $interval->format('%s seconds'));
678
+ } else {
679
+ $util = new WPBackItUp_Utility($this->logger);
680
+ $interval = $util->date_diff_array($datetime1, $datetime2);
681
+ $this->logger->log_info( __METHOD__, 'File Count/Time: ' .$total_counter . '-' . $interval['second'] . ' seconds');
682
+ }
683
+
684
+ return true;
685
 
686
  } catch(Exception $e) {
687
  $this->logger->log_error( __METHOD__, 'Exception: ' .$e);
850
  return false;
851
  }
852
 
853
+ // checking zip file path.
854
+ $this->logger->log_info(__METHOD__,'Begin:: Checking Zip file Existance');
855
+ $this->logger->log_info(__METHOD__,'Tmp file path: '. $zip_file_path);
856
+
857
+ // Clears file status cache
858
+ clearstatcache();
859
+
860
  //if there are no more files to add then rename the zip
861
  //Check to see if the file exists, it is possible that it does not if only empty folders were contained
862
  if(file_exists($zip_file_path) ) {
863
+ $this->logger->log_info(__METHOD__,'Tmp File exist');
864
  if ( ! $this->add_zip_suffix( $batch_id,$zip_file_path ) ) {
865
+ $this->logger->log_info(__METHOD__,'Adding Zip Suffix Failed');
866
  return false;
867
+ }else{
868
+ $this->logger->log_info(__METHOD__,'Adding Zip Suffix Successful');
869
+ }
870
+ }else{
871
+ $this->logger->log_info(__METHOD__,'Tmp File Not exist - file_exists() not working.');
872
+ // Scanning Temp Directory.
873
+ $files_on_temp_directory = scandir($this->backup_project_path);
874
+ $this->logger->log_info(__METHOD__,'Begin::Files on TMP Directory');
875
+ $this->logger->log_info(__METHOD__,$files_on_temp_directory);
876
+ $this->logger->log_info(__METHOD__,'End::Files on TMP Directory');
877
  }
878
 
879
+ $this->logger->log_info(__METHOD__,'End:: Checking Zip file Existance');
880
+
881
  //update the batch as done.
882
  $db->update_batch_complete($job_id,$batch_id);
883
 
933
  $current_zip_file=null;
934
  $zip=null;
935
  $file_counter=0;
936
+
937
+ // Checking zip file existance
938
+ $this->logger->log_info(__METHOD__,'All Zip files Path');
939
+
940
  foreach($file_list as $file) {
941
  $batch_id = $file->batch_id;
942
  $item = $target_root .'/' .utf8_decode( $file->item );
943
 
944
  //get zip path
945
  $zip_file_path = sprintf('%s-%s-%s.zip',$this->backup_project_path . $this->backup_name, $content_type,$batch_id);
946
+
947
+ // loging zip file path.
948
+ $this->logger->log_info(__METHOD__,'zip file path: '. $zip_file_path);
949
+
950
+ if ($current_zip_file!=$zip_file_path){
951
  //$this->logger->log_info( __METHOD__, 'Zip File:' . $zip_file_path );
952
  if (! file_exists($zip_file_path)){
953
  $this->logger->log_error( __METHOD__, 'Zip File not found:' . $zip_file_path );
954
+ // Scanning Temp Directory.
955
+ $files_on_temp_directory = scandir($this->backup_project_path);
956
+ $this->logger->log_info(__METHOD__,'Begin::Files on TMP Directory');
957
+ $this->logger->log_info(__METHOD__,$files_on_temp_directory);
958
+ $this->logger->log_info(__METHOD__,'End::Files on TMP Directory');
959
  return false;
960
  }
961
  $current_zip_file = $zip_file_path;
1246
  $this->logger->log_info(__METHOD__,'End');
1247
  }
1248
 
1249
+ }
lib/includes/class-database.php CHANGED
@@ -53,10 +53,6 @@ class WPBackItUp_DataAccess {
53
  $this->logger->log_info(__METHOD__,'Begin');
54
  global $wpdb;
55
 
56
- //Remove slashes
57
- $sql_values= str_replace('\\', "/", $sql_values );
58
- //$sql_values= utf8_encode($sql_values);
59
-
60
  $sql_insert = "INSERT INTO $wpdb->wpbackitup_job
61
  (job_id, group_id, item, size_kb, create_date)
62
  VALUES " ;
53
  $this->logger->log_info(__METHOD__,'Begin');
54
  global $wpdb;
55
 
 
 
 
 
56
  $sql_insert = "INSERT INTO $wpdb->wpbackitup_job
57
  (job_id, group_id, item, size_kb, create_date)
58
  VALUES " ;
lib/includes/class-filesystem.php CHANGED
@@ -563,5 +563,40 @@ class WPBackItUp_FileSystem {
563
  }
564
 
565
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
566
  }
567
 
563
  }
564
 
565
 
566
+ /**
567
+ * Fetch an array of files from the path provided.
568
+ * An optional list of pipe delimited extensions may be provided to filter
569
+ * results by extension. If none is provided all files in path will be returned.
570
+ *
571
+ * @param $path Path to folder where files reside.
572
+ * @param null $extensions Pipe delimited list of extensions ex. txt|sql
573
+ *
574
+ * @return array Array of files
575
+ */
576
+ function get_fileonly_list($path,$extensions=null){
577
+ $this->logger->log_info(__METHOD__,"Begin:" .$path);
578
+ $this->logger->log_info(__METHOD__,"Pattern:" .$extensions);//txt|sql'
579
+
580
+ //Remove trailing slashes
581
+ $path = rtrim($path,"\\");
582
+ $path = rtrim($path,"/");
583
+ $this->logger->log_info(__METHOD__,"Path:" .$path);
584
+
585
+ $all_files = glob($path .'/*.*');
586
+ $this->logger->log_info(__METHOD__,"All Files:" .var_export($all_files,true));
587
+
588
+ //If a file pattern is passed then filter
589
+ if(isset($extensions)){
590
+ $regex = sprintf('~\.(%s)$~',$extensions);
591
+ $filtered_files = preg_grep($regex, $all_files);
592
+ }else{
593
+ $filtered_files =array_filter($all_files, 'is_file');
594
+ }
595
+
596
+ $this->logger->log_info(__METHOD__,"Filtered Files:" .var_export($filtered_files,true));
597
+ return $filtered_files;
598
+ }
599
+
600
+
601
  }
602
 
lib/includes/class-logger.php CHANGED
@@ -78,7 +78,8 @@ class WPBackItUp_Logger {
78
  try{
79
  if (true===$this->logging){
80
  if (!is_null($this->dfh) && is_resource($this->dfh)){
81
- $date = date_i18n('Y-m-d H:i:s',current_time( 'timestamp' ));
 
82
  if( is_array( $message ) || is_object( $message ) ){
83
  fwrite($this->dfh, $date ." " .print_r( $message, true ) . PHP_EOL);
84
  } else {
@@ -151,6 +152,7 @@ class WPBackItUp_Logger {
151
  $this->log("\n--Wordpress Info--");
152
  $this->log("Wordpress Version:" . get_bloginfo( 'version'));
153
  $this->log('Language:' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ));
 
154
  $this->log('Table Prefix:' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ));
155
  $this->log('WP_DEBUG:' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ));
156
  $this->log('Memory Limit:' . WP_MEMORY_LIMIT );
78
  try{
79
  if (true===$this->logging){
80
  if (!is_null($this->dfh) && is_resource($this->dfh)){
81
+ //$date = date_i18n('Y-m-d H:i:s',current_time( 'timestamp' ));
82
+ $date = date_i18n('Y-m-d H:i:s', time());
83
  if( is_array( $message ) || is_object( $message ) ){
84
  fwrite($this->dfh, $date ." " .print_r( $message, true ) . PHP_EOL);
85
  } else {
152
  $this->log("\n--Wordpress Info--");
153
  $this->log("Wordpress Version:" . get_bloginfo( 'version'));
154
  $this->log('Language:' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ));
155
+ $this->log('DB_HOST:' . DB_HOST);
156
  $this->log('Table Prefix:' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ));
157
  $this->log('WP_DEBUG:' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ));
158
  $this->log('Memory Limit:' . WP_MEMORY_LIMIT );
lib/includes/class-sql.php CHANGED
@@ -20,8 +20,7 @@ class WPBackItUp_SQL {
20
  $this->connection = $this->get_sqlconnection();
21
 
22
  } catch(Exception $e) {
23
- //Dont do anything
24
- print $e;
25
  }
26
  }
27
 
@@ -120,6 +119,35 @@ class WPBackItUp_SQL {
120
  }
121
 
122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  public function manual_export($sql_file_path) {
124
  global $wpdb;
125
  $this->logger->log_info(__METHOD__,'Manually Create SQL Backup File:'.$sql_file_path);
@@ -517,7 +545,7 @@ class WPBackItUp_SQL {
517
  private function get_portonly($db_host) {
518
  //Check for port
519
  $host_array = explode(':',$db_host);
520
- if (is_array($host_array) && count($host_array)>1){
521
  return $host_array[1];
522
  }
523
 
20
  $this->connection = $this->get_sqlconnection();
21
 
22
  } catch(Exception $e) {
23
+ $this->logger->log_error(__METHOD__,$e);
 
24
  }
25
  }
26
 
119
  }
120
 
121
 
122
+ /**
123
+ *
124
+ * Fetch all tables and number of rows in database
125
+ *
126
+ * @return array|bool
127
+ */
128
+ public function get_table_rows() {
129
+ $this->logger->log_info(__METHOD__,'Begin');
130
+
131
+ $mysqli = $this->connection;
132
+ if (false === $mysqli) {
133
+ $this->logger->log_error(__METHOD__,'No SQL Connection');
134
+ return false;
135
+ }
136
+ $sql = "SELECT TABLE_NAME,TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES
137
+ WHERE TABLE_SCHEMA = '" . DB_NAME . "'
138
+ ORDER BY TABLE_ROWS DESC;";
139
+ $result = $mysqli->query($sql);
140
+
141
+ // Cycle through "$result" and put content into an array
142
+ $tables = array();
143
+ while ($row = $result->fetch_row()) {
144
+ $tables[] = array("table_name" => $row[0], 'table_rows' => $row[1]) ;
145
+ }
146
+
147
+ $this->logger->log_info(__METHOD__,'End');
148
+ return $tables;
149
+ }
150
+
151
  public function manual_export($sql_file_path) {
152
  global $wpdb;
153
  $this->logger->log_info(__METHOD__,'Manually Create SQL Backup File:'.$sql_file_path);
545
  private function get_portonly($db_host) {
546
  //Check for port
547
  $host_array = explode(':',$db_host);
548
+ if (is_array($host_array) && count($host_array)>1 && !empty($port)){
549
  return $host_array[1];
550
  }
551
 
lib/includes/class-utility.php CHANGED
@@ -118,6 +118,32 @@ class WPBackItUp_Utility {
118
  return $timestamp_diff_seconds;
119
  }
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  public static function encode_items(&$item, $key)
122
  {
123
  //If not string convert to one.
@@ -149,14 +175,14 @@ class WPBackItUp_Utility {
149
  $version1_array = explode('.', $version1);
150
  $version2_array = explode('.', $version2);
151
 
152
- if (! empty($version1_array[0]) && isset ($version1_array[0]) &&
153
- ! empty($version2_array[0]) && isset ($version2_array[0]) &&
154
- ! empty($version1_array[1]) && isset ($version1_array[1]) &&
155
- ! empty($version2_array[1]) && isset ($version2_array[1]) ){
156
 
157
  //If major or minor version is different
158
- if ($version1_array[0] == $version2_array[0] &&
159
- $version1_array[1] == $version2_array[1] ) {
160
  return true;
161
  }
162
 
118
  return $timestamp_diff_seconds;
119
  }
120
 
121
+ function date_diff_array(DateTime $oDate1, DateTime $oDate2) {
122
+ $aIntervals = array(
123
+ 'year' => 0,
124
+ 'month' => 0,
125
+ 'week' => 0,
126
+ 'day' => 0,
127
+ 'hour' => 0,
128
+ 'minute' => 0,
129
+ 'second' => 0,
130
+ );
131
+
132
+ foreach($aIntervals as $sInterval => &$iInterval) {
133
+ while($oDate1 <= $oDate2){
134
+ $oDate1->modify('+1 ' . $sInterval);
135
+ if ($oDate1 > $oDate2) {
136
+ $oDate1->modify('-1 ' . $sInterval);
137
+ break;
138
+ } else {
139
+ $iInterval++;
140
+ }
141
+ }
142
+ }
143
+
144
+ return $aIntervals;
145
+ }
146
+
147
  public static function encode_items(&$item, $key)
148
  {
149
  //If not string convert to one.
175
  $version1_array = explode('.', $version1);
176
  $version2_array = explode('.', $version2);
177
 
178
+ if ( isset ($version1_array[0]) && is_numeric($version1_array[0])
179
+ && isset ($version2_array[0]) && is_numeric($version2_array[0])
180
+ && isset ($version1_array[1]) && is_numeric($version1_array[1])
181
+ && isset ($version2_array[1]) && is_numeric($version2_array[1]) ){
182
 
183
  //If major or minor version is different
184
+ if ($version1_array[0] === $version2_array[0] &&
185
+ $version1_array[1] === $version2_array[1] ) {
186
  return true;
187
  }
188
 
lib/includes/class-wpbackitup-admin.php CHANGED
@@ -964,7 +964,10 @@ class WPBackitup_Admin {
964
  $support_subject = '[#' .trim($_POST['support_ticket_id']) .']';
965
 
966
  $site_info = 'WordPress Site: <a href="' . home_url() . '" target="_blank">' . home_url() .'</a><br/>';
967
- $site_info .="WP BackItUp License Type: " . $this->license_type_description() .' <br />';
 
 
 
968
 
969
  $support_body=$site_info . '<br/><br/><b>Customer Comments:</b><br/><br/>' . $_POST['support_body'];
970
 
964
  $support_subject = '[#' .trim($_POST['support_ticket_id']) .']';
965
 
966
  $site_info = 'WordPress Site: <a href="' . home_url() . '" target="_blank">' . home_url() .'</a><br/>';
967
+ $site_info .="WordPress Version: " . get_bloginfo( 'version') .' <br />';
968
+ $site_info .="WP BackItUp License Type: " . $this->license_type_description() .' <br />';
969
+ $site_info .="WP BackItUp Version: " . $this->version .' <br />';
970
+
971
 
972
  $support_body=$site_info . '<br/><br/><b>Customer Comments:</b><br/><br/>' . $_POST['support_body'];
973
 
lib/includes/job_backup.php CHANGED
@@ -297,6 +297,8 @@ if ('task_preparing'==$current_task) {
297
  end_backup(128,false);
298
  };
299
 
 
 
300
  $plugin_exclude = WPBACKITUP__BACKUP_GLOBAL_IGNORE_LIST;
301
  if (! $wp_backup->save_folder_inventory(WPBACKITUP__SQL_BULK_INSERT_SIZE,$backup_job->backup_id,'plugins',WPBACKITUP__PLUGINS_ROOT_PATH,$plugin_exclude)){
302
  $logger->log_error( __METHOD__, 'Plugins Inventory Error.');
@@ -315,7 +317,13 @@ if ('task_preparing'==$current_task) {
315
  end_backup(127,false);
316
  };
317
 
318
- $upload_exclude = WPBACKITUP__BACKUP_GLOBAL_IGNORE_LIST;
 
 
 
 
 
 
319
  $upload_array = wp_upload_dir();
320
  $uploads_root_path = $upload_array['basedir'];
321
  if (! $wp_backup->save_folder_inventory(WPBACKITUP__SQL_BULK_INSERT_SIZE,$backup_job->backup_id,'uploads',$uploads_root_path,$upload_exclude)){
@@ -326,7 +334,6 @@ if ('task_preparing'==$current_task) {
326
  end_backup(127,false);
327
  };
328
 
329
- $global_exclude = explode(',', WPBACKITUP__BACKUP_GLOBAL_IGNORE_LIST);
330
  $other_exclude = array_merge (
331
  $global_exclude,
332
  array(
@@ -403,7 +410,9 @@ if ('task_backup_siteinfo'==$current_task) {
403
  $source_site_data_root = $wp_backup->backup_project_path;
404
  $target_site_data_root = 'site-data';
405
 
406
- $site_data_files = get_fileonly_list($wp_backup->backup_project_path, '*.{txt,sql}');
 
 
407
  $site_data_complete = $wp_backup->backup_file_list( $source_site_data_root, $target_site_data_root, $suffix, $site_data_files, WPBACKITUP__OTHERS_BATCH_SIZE );
408
  if ( $site_data_complete == 'error' ) {
409
  $backup_job->set_task_error('105');
@@ -422,7 +431,7 @@ if ('task_backup_siteinfo'==$current_task) {
422
  }
423
 
424
  //get rid of the SQL and sitedata file - will check again at end in cleanup
425
- $wp_backup->delete_site_data_files();
426
 
427
  set_status( 'infofile', $complete, false );
428
  $backup_job->set_task_complete();
@@ -639,7 +648,8 @@ if ('task_finalize_backup'==$current_task) {
639
  }
640
 
641
  //Take an inventory of the zip files created
642
- $zip_files = get_fileonly_list($wp_backup->backup_project_path, '*.{zip}');
 
643
  $wp_backup->save_file_list_inventory(WPBACKITUP__SQL_BULK_INSERT_SIZE,$backup_job->backup_id,'backups',$wp_backup->backup_project_path,$zip_files);
644
 
645
  //Combine the zip files into one file
@@ -1038,22 +1048,3 @@ function get_error_message($error_code){
1038
 
1039
  return $error_message;
1040
  }
1041
-
1042
-
1043
- function get_fileonly_list($path,$pattern){
1044
- global $logger;
1045
- $logger->log_info(__METHOD__,"Begin:" .$path);
1046
- $logger->log_info(__METHOD__,"Pattern:" .$pattern);//'*.{txt,sql}'
1047
-
1048
- $all_files = glob($path. $pattern,GLOB_BRACE);
1049
- $logger->log_info(__METHOD__,"All Files:" .var_export($all_files,true));
1050
-
1051
- $filtered_array =array_filter($all_files, 'is_file'); //not sure i need this...
1052
- $logger->log_info(__METHOD__,"Filtered Files:" .var_export($filtered_array,true));
1053
-
1054
- return $filtered_array;
1055
-
1056
-
1057
- }
1058
-
1059
-
297
  end_backup(128,false);
298
  };
299
 
300
+ $global_exclude = explode(',', WPBACKITUP__BACKUP_GLOBAL_IGNORE_LIST);
301
+
302
  $plugin_exclude = WPBACKITUP__BACKUP_GLOBAL_IGNORE_LIST;
303
  if (! $wp_backup->save_folder_inventory(WPBACKITUP__SQL_BULK_INSERT_SIZE,$backup_job->backup_id,'plugins',WPBACKITUP__PLUGINS_ROOT_PATH,$plugin_exclude)){
304
  $logger->log_error( __METHOD__, 'Plugins Inventory Error.');
317
  end_backup(127,false);
318
  };
319
 
320
+ $upload_exclude = array_merge (
321
+ $global_exclude,
322
+ array(
323
+ "backup",
324
+ "backwpup",
325
+ ));
326
+
327
  $upload_array = wp_upload_dir();
328
  $uploads_root_path = $upload_array['basedir'];
329
  if (! $wp_backup->save_folder_inventory(WPBACKITUP__SQL_BULK_INSERT_SIZE,$backup_job->backup_id,'uploads',$uploads_root_path,$upload_exclude)){
334
  end_backup(127,false);
335
  };
336
 
 
337
  $other_exclude = array_merge (
338
  $global_exclude,
339
  array(
410
  $source_site_data_root = $wp_backup->backup_project_path;
411
  $target_site_data_root = 'site-data';
412
 
413
+
414
+ $file_system = new WPBackItUp_FileSystem($logger);
415
+ $site_data_files = $file_system->get_fileonly_list($wp_backup->backup_project_path, 'txt|sql');
416
  $site_data_complete = $wp_backup->backup_file_list( $source_site_data_root, $target_site_data_root, $suffix, $site_data_files, WPBACKITUP__OTHERS_BATCH_SIZE );
417
  if ( $site_data_complete == 'error' ) {
418
  $backup_job->set_task_error('105');
431
  }
432
 
433
  //get rid of the SQL and sitedata file - will check again at end in cleanup
434
+ $wp_backup->cleanup_current_backup();
435
 
436
  set_status( 'infofile', $complete, false );
437
  $backup_job->set_task_complete();
648
  }
649
 
650
  //Take an inventory of the zip files created
651
+ $file_system = new WPBackItUp_FileSystem($logger);
652
+ $zip_files = $file_system->get_fileonly_list($wp_backup->backup_project_path, 'zip');
653
  $wp_backup->save_file_list_inventory(WPBACKITUP__SQL_BULK_INSERT_SIZE,$backup_job->backup_id,'backups',$wp_backup->backup_project_path,$zip_files);
654
 
655
  //Combine the zip files into one file
1048
 
1049
  return $error_message;
1050
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === WP Backitup ===
2
- Contributors: cssimmon,jcpeden,wpbackitup
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.2.2
7
- Stable tag: 1.10.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -151,6 +151,19 @@ Our online documentation and full list of FAQs can be found at [www.wpbackitup.c
151
 
152
 
153
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  = 1.10.7 =
155
  * UPDATE: Add multi-site support for database backup
156
  * UPDATE: Add WordPress 4.2 support
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.2.2
7
+ Stable tag: 1.10.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
151
 
152
 
153
  == Changelog ==
154
+ = 1.10.8 =
155
+ * UPDATE: Add database size logging
156
+ * UPDATE: Add WordPress and WP BackItUp version info to support email
157
+ * UPDATE: Add logging to verify work files exist
158
+ * FIX: Add fix to handle special characters in file names
159
+ * FIX: Add fix to handle datediff for php versions <=5.3
160
+ * FIX: Add fix to version compare utility method
161
+ * FIX: Add fix to recursive directory iterator for php versions < 5.3
162
+ * FIX: Ignore backwpup folders during backup
163
+ * FIX: Fix missing database port issue
164
+ * FIX: Add logging and clearstatcache to backup files
165
+ * FIX: Remove use of GLOB_BRACE
166
+
167
  = 1.10.7 =
168
  * UPDATE: Add multi-site support for database backup
169
  * UPDATE: Add WordPress 4.2 support
views/backup.php CHANGED
@@ -8,6 +8,8 @@
8
  * @link http://www.wpbackitup.com
9
  *
10
  */
 
 
11
  //Check the license
12
  do_action( 'wpbackitup_check_license');
13
 
@@ -66,9 +68,10 @@
66
 
67
  //Cleanup old backups - this can be removed in a few months.
68
  //Get Zip File List
69
- $file_list = glob($backup_folder_root . "/*.{zip,log}",GLOB_BRACE);
70
- //If there are zip files then move them into their own folders
71
 
 
72
  $logger->log_info(__METHOD__,'Files in backup folder: ' .var_export($file_list,true));
73
  $logger->log_info(__METHOD__,'Last Error: ' .var_export(error_get_last(),true));
74
 
8
  * @link http://www.wpbackitup.com
9
  *
10
  */
11
+ require_once( WPBACKITUP__PLUGIN_PATH .'/lib/includes/class-filesystem.php' );
12
+
13
  //Check the license
14
  do_action( 'wpbackitup_check_license');
15
 
68
 
69
  //Cleanup old backups - this can be removed in a few months.
70
  //Get Zip File List
71
+ $file_system = new WPBackItUp_FileSystem($logger);
72
+ $file_list = $file_system->get_fileonly_list($backup_folder_root, 'zip|log');
73
 
74
+ //If there are zip files then move them into their own folders
75
  $logger->log_info(__METHOD__,'Files in backup folder: ' .var_export($file_list,true));
76
  $logger->log_info(__METHOD__,'Last Error: ' .var_export(error_get_last(),true));
77
 
wp-backitup.php CHANGED
@@ -13,7 +13,7 @@
13
  Plugin Name: WP Backitup
14
  Plugin URI: http://www.wpbackitup.com
15
  Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
16
- Version: 1.10.7
17
  Author: Chris Simmons
18
  Author URI: http://www.wpbackitup.com
19
  License: GPL3
@@ -37,7 +37,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
37
  define( 'WPBACKITUP__NAMESPACE', 'wp-backitup' );
38
  define( 'WPBACKITUP__MAJOR_VERSION', 1);
39
  define( 'WPBACKITUP__MINOR_VERSION', 10);
40
- define( 'WPBACKITUP__MAINTENANCE_VERSION', 7);
41
  define( 'WPBACKITUP__BUILD_VERSION', 0);
42
  define( 'WPBACKITUP__VERSION',sprintf("%d.%d.%d.%d", WPBACKITUP__MAJOR_VERSION, WPBACKITUP__MINOR_VERSION,WPBACKITUP__MAINTENANCE_VERSION,WPBACKITUP__BUILD_VERSION));
43
  define( 'WPBACKITUP__DEBUG', false );
13
  Plugin Name: WP Backitup
14
  Plugin URI: http://www.wpbackitup.com
15
  Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
16
+ Version: 1.10.8
17
  Author: Chris Simmons
18
  Author URI: http://www.wpbackitup.com
19
  License: GPL3
37
  define( 'WPBACKITUP__NAMESPACE', 'wp-backitup' );
38
  define( 'WPBACKITUP__MAJOR_VERSION', 1);
39
  define( 'WPBACKITUP__MINOR_VERSION', 10);
40
+ define( 'WPBACKITUP__MAINTENANCE_VERSION', 8);
41
  define( 'WPBACKITUP__BUILD_VERSION', 0);
42
  define( 'WPBACKITUP__VERSION',sprintf("%d.%d.%d.%d", WPBACKITUP__MAJOR_VERSION, WPBACKITUP__MINOR_VERSION,WPBACKITUP__MAINTENANCE_VERSION,WPBACKITUP__BUILD_VERSION));
43
  define( 'WPBACKITUP__DEBUG', false );