UpdraftPlus WordPress Backup Plugin - Version 1.0.16

Version Description

  • 12/24/2012 =
  • Improve race detection and clean up already-created files when detected
Download this release

Release Info

Developer DavidAnderson
Plugin Icon 128x128 UpdraftPlus WordPress Backup Plugin
Version 1.0.16
Comparing to
See all releases

Code changes from version 1.0.15 to 1.0.16

Files changed (2) hide show
  1. readme.txt +4 -1
  2. updraftplus.php +27 -9
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: David Anderson
3
  Tags: backup, restore, database, cloud, amazon, s3, Amazon S3, google drive, google, gdrive, ftp, cloud, updraft, back up
4
  Requires at least: 3.2
5
  Tested up to: 3.5
6
- Stable tag: 1.0.8
7
  Donate link: http://david.dw-perspective.org.uk/donate
8
  License: GPLv3 or later
9
 
@@ -87,6 +87,9 @@ No, there's no warranty or guarantee, etc. It's completely up to you to verify t
87
 
88
  == Changelog ==
89
 
 
 
 
90
  = 1.0.15 - 12/22/2012 =
91
  * Fixed bug that set 1Tb (instead of 1Mb) chunk sizes for Google Drive uploads
92
  * Added link to some screenshots to help with Google Drive setup
3
  Tags: backup, restore, database, cloud, amazon, s3, Amazon S3, google drive, google, gdrive, ftp, cloud, updraft, back up
4
  Requires at least: 3.2
5
  Tested up to: 3.5
6
+ Stable tag: 1.0.15
7
  Donate link: http://david.dw-perspective.org.uk/donate
8
  License: GPLv3 or later
9
 
87
 
88
  == Changelog ==
89
 
90
+ = 1.0.16 - 12/24/2012 =
91
+ * Improve race detection and clean up already-created files when detected
92
+
93
  = 1.0.15 - 12/22/2012 =
94
  * Fixed bug that set 1Tb (instead of 1Mb) chunk sizes for Google Drive uploads
95
  * Added link to some screenshots to help with Google Drive setup
updraftplus.php CHANGED
@@ -4,14 +4,14 @@ Plugin Name: UpdraftPlus - Backup/Restore
4
  Plugin URI: http://wordpress.org/extend/plugins/updraftplus
5
  Description: Uploads, themes, plugins, and your DB can be automatically backed up to Amazon S3, Google Drive, FTP, or emailed, on separate schedules.
6
  Author: David Anderson.
7
- Version: 1.0.15
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
10
  Author URI: http://wordshell.net
11
  */
12
 
13
  /*
14
- TODO (some of these items mine, some from original Updraft awaiting review):
15
  //Add DropBox and Microsoft Skydrive support
16
  //improve error reporting / pretty up return messages in admin area
17
  //?? On 'backup now', open up a Lightbox, count down 5 seconds, then start examining the log file (if it can be found)
@@ -54,7 +54,7 @@ define('UPDRAFT_DEFAULT_OTHERS_EXCLUDE','upgrade,cache,updraft,index.php');
54
 
55
  class UpdraftPlus {
56
 
57
- var $version = '1.0.15';
58
 
59
  var $dbhandle;
60
  var $errors = array();
@@ -312,10 +312,22 @@ class UpdraftPlus {
312
  $this->logfile_handle = fopen($this->logfile_name, 'a');
313
  }
314
 
315
- function check_backup_race() {
316
- $cur_trans = get_transient('updraftplus_backup_job_nonce');
317
- if ( $cur_trans != $this->nonce) {
 
 
 
318
  $this->log("Another backup job ($cur_trans) appears to now be running - terminating our run");
 
 
 
 
 
 
 
 
 
319
  exit;
320
  }
321
  }
@@ -367,7 +379,7 @@ class UpdraftPlus {
367
  $backup_contains = "Files only (no database)";
368
  }
369
 
370
- $this->check_backup_race();
371
 
372
  //backup DB and return string of file path
373
  if ($backup_database) {
@@ -378,7 +390,7 @@ class UpdraftPlus {
378
  $backup_contains = ($backup_files) ? "Files and database" : "Database only (no files)";
379
  }
380
 
381
- $this->check_backup_race();
382
  set_transient("updraftplus_backupcontains", $backup_contains, 3600*3);
383
 
384
  //save this to our history so we can track backups for the retain feature
@@ -922,7 +934,9 @@ class UpdraftPlus {
922
  } else {
923
  $this->log("No backup of plugins: excluded by user's options");
924
  }
925
-
 
 
926
  # Themes
927
  @set_time_limit(900);
928
  if (get_option('updraft_include_themes', true)) {
@@ -940,6 +954,8 @@ class UpdraftPlus {
940
  $this->log("No backup of themes: excluded by user's options");
941
  }
942
 
 
 
943
  # Uploads
944
  @set_time_limit(900);
945
  if (get_option('updraft_include_uploads', true)) {
@@ -957,6 +973,8 @@ class UpdraftPlus {
957
  $this->log("No backup of uploads: excluded by user's options");
958
  }
959
 
 
 
960
  # Others
961
  @set_time_limit(900);
962
  if (get_option('updraft_include_others', true)) {
4
  Plugin URI: http://wordpress.org/extend/plugins/updraftplus
5
  Description: Uploads, themes, plugins, and your DB can be automatically backed up to Amazon S3, Google Drive, FTP, or emailed, on separate schedules.
6
  Author: David Anderson.
7
+ Version: 1.0.16
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
10
  Author URI: http://wordshell.net
11
  */
12
 
13
  /*
14
+ TODO
15
  //Add DropBox and Microsoft Skydrive support
16
  //improve error reporting / pretty up return messages in admin area
17
  //?? On 'backup now', open up a Lightbox, count down 5 seconds, then start examining the log file (if it can be found)
54
 
55
  class UpdraftPlus {
56
 
57
+ var $version = '1.0.16';
58
 
59
  var $dbhandle;
60
  var $errors = array();
312
  $this->logfile_handle = fopen($this->logfile_name, 'a');
313
  }
314
 
315
+ function check_backup_race( $to_delete = false ) {
316
+ // Avoid caching
317
+ global $wpdb;
318
+ $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", "_transient_updraftplus_backup_job_nonce" ) );
319
+ $cur_trans = ( is_object( $row ) ) ? $row->option_value : "";
320
+ if ($cur_trans != "" && $cur_trans != $this->nonce) {
321
  $this->log("Another backup job ($cur_trans) appears to now be running - terminating our run");
322
+ $bdir = $this->backups_dir_location();
323
+ if (is_array($to_delete)) {
324
+ foreach ($to_delete as $key => $file) {
325
+ if (is_file($bdir.'/'.$file)) {
326
+ $this->log("Deleteing the file we created: ".$file);
327
+ @unlink($bdir.'/'.$file);
328
+ }
329
+ }
330
+ }
331
  exit;
332
  }
333
  }
379
  $backup_contains = "Files only (no database)";
380
  }
381
 
382
+ $this->check_backup_race($backup_array);
383
 
384
  //backup DB and return string of file path
385
  if ($backup_database) {
390
  $backup_contains = ($backup_files) ? "Files and database" : "Database only (no files)";
391
  }
392
 
393
+ $this->check_backup_race($backup_array);
394
  set_transient("updraftplus_backupcontains", $backup_contains, 3600*3);
395
 
396
  //save this to our history so we can track backups for the retain feature
934
  } else {
935
  $this->log("No backup of plugins: excluded by user's options");
936
  }
937
+
938
+ $this->check_backup_race($backup_array);
939
+
940
  # Themes
941
  @set_time_limit(900);
942
  if (get_option('updraft_include_themes', true)) {
954
  $this->log("No backup of themes: excluded by user's options");
955
  }
956
 
957
+ $this->check_backup_race($backup_array);
958
+
959
  # Uploads
960
  @set_time_limit(900);
961
  if (get_option('updraft_include_uploads', true)) {
973
  $this->log("No backup of uploads: excluded by user's options");
974
  }
975
 
976
+ $this->check_backup_race($backup_array);
977
+
978
  # Others
979
  @set_time_limit(900);
980
  if (get_option('updraft_include_others', true)) {