UpdraftPlus WordPress Backup Plugin - Version 1.5.5

Version Description

  • 2013/03/26 =
  • Now translatable - .pot file included (translators welcome!)
  • When restoring, you can now select only some components to restore
  • History of previous backups can re-scan to find backups manually imported (e.g. via FTP) (trunk version has drag-and-drop import)
  • Multisite add-on (http://updraftplus.com/shop/) now stores/restores blogs and mu-plugins separately
  • Display UpdraftPlus's disk space usage
  • Internationalisation hooks in main body of plugin
  • Correctly remove old 'other' directories from a restoration when requested
  • Various layout + niceness fixes upon restoration
  • Prevent deletion of local archives upon failed restoration when there was no cloud storage
  • Various usability tweaks for the admin UI, including showing multisite warning only on UD's pages
  • Fix incorrect restoration (since 1.4.0) of directory-less paths from 'others' zip
  • Fix prevention of Dropbox re-authentication when Dropbox returns 5xx first time (library error)
  • Clear Dropbox credentials if the user explicitly re-authenticates
  • Clean up temporary files left behind by zipArchive::addFile
  • Tweak Dropbox library to work from behind very weird proxies that double-surround the HTTP header
  • Improved help for people with broken schedulers
Download this release

Release Info

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

Code changes from version 1.5.9 to 1.5.5

Files changed (2) hide show
  1. readme.txt +4 -3
  2. updraftplus.php +10 -50
readme.txt CHANGED
@@ -1,5 +1,5 @@
1
  === UpdraftPlus Backup ===
2
- Contributors: David Anderson
3
  Tags: backup, restore, database, cloud, amazon, s3, dropbox, google drive, ftp, webdav, back up, multisite
4
  Requires at least: 3.2
5
  Tested up to: 3.5.1
@@ -8,8 +8,7 @@ Author URI: http://updraftplus.com
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
10
 
11
- == Upgrade Notice ==
12
- New features: selective restoration, importing remote backups; plus many tweaks, optimisations + small bug-fixes: recommended upgrade for all
13
 
14
  == Description ==
15
 
@@ -394,3 +393,5 @@ We recognise and thank the following for code and/or libraries used and/or modif
394
  along with this program; if not, write to the Free Software
395
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
396
 
 
 
1
  === UpdraftPlus Backup ===
2
+ Contributors: DavidAnderson
3
  Tags: backup, restore, database, cloud, amazon, s3, dropbox, google drive, ftp, webdav, back up, multisite
4
  Requires at least: 3.2
5
  Tested up to: 3.5.1
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
10
 
11
+ Easy and complete backups and restoration. Manual or automated backups (Amazon S3, Dropbox, Google Drive, Rackspace, FTP, SFTP, WebDAV, email).
 
12
 
13
  == Description ==
14
 
393
  along with this program; if not, write to the Free Software
394
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
395
 
396
+ == Upgrade Notice ==
397
+ New features: selective restoration, importing remote backups; plus many tweaks, optimisations + small bug-fixes: recommended upgrade for all
updraftplus.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: UpdraftPlus - Backup/Restore
4
  Plugin URI: http://updraftplus.com
5
  Description: Backup and restore: your site can be backed up locally or to Amazon S3, Dropbox, Google Drive, (S)FTP, WebDAV & email, on automatic schedules.
6
  Author: UpdraftPlus.Com, DavidAnderson
7
- Version: 1.5.9
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
10
  Text Domain: updraftplus
@@ -144,7 +144,6 @@ class UpdraftPlus {
144
  var $zipfiles_existingfiles;
145
  var $zipfiles_dirbatched;
146
  var $zipfiles_batched;
147
- var $zipfiles_lastwritetime;
148
 
149
  var $zip_preferpcl = false;
150
 
@@ -351,20 +350,12 @@ class UpdraftPlus {
351
  // This is scheduled for 5 minutes after a backup job starts
352
 
353
  // Restore state
354
- $resumption_extralog = '';
355
  if ($resumption_no > 0) {
356
  $this->nonce = $bnonce;
357
  $this->backup_time = $this->jobdata_get('backup_time');
358
  $this->logfile_open($bnonce);
359
-
360
- $time_passed = $this->jobdata_get('run_times');
361
- if (!is_array($time_passed)) $time_passed = array();
362
-
363
- $prev_resumption = $resumption_no - 1;
364
- if (isset($time_passed[$prev_resumption])) $resumption_extralog = ", previous check-in=".round($time_passed[$prev_resumption], 1)."s";
365
  }
366
 
367
-
368
  $btime = $this->backup_time;
369
 
370
  $job_type = $this->jobdata_get('job_type');
@@ -374,23 +365,7 @@ class UpdraftPlus {
374
  $time_ago = time()-$btime;
375
 
376
  $this->current_resumption = $resumption_no;
377
- $this->log("Backup run: resumption=$resumption_no, nonce=$bnonce, begun at=$btime (${time_ago}s ago), job type: $job_type".$resumption_extralog);
378
-
379
- if ($resumption_no == 8) {
380
- $timings_string = "";
381
- $run_times_known=0;
382
- for ($i=0; $i<=7; $i++) {
383
- $timings_string .= "$i:";
384
- if (isset($time_passed[$i])) {
385
- $timings_string .= round($time_passed[$i], 1).' ';
386
- $run_times_known++;
387
- } else {
388
- $timings_string .= '? ';
389
- }
390
- }
391
- $this->log("Time passed on previous resumptions: $passed");
392
- // TODO: If there's sufficient data and an upper limit clearly lower than our present resume_interval, then decrease the resume_interval
393
- }
394
 
395
  // Schedule again, to run in 5 minutes again, in case we again fail
396
  // The actual interval can be increased (for future resumptions) by other code, if it detects apparent overlapping
@@ -405,7 +380,7 @@ class UpdraftPlus {
405
  wp_schedule_single_event($schedule_for, 'updraft_backup_resume', array($next_resumption, $bnonce));
406
  $this->newresumption_scheduled = $schedule_for;
407
  } else {
408
- $this->log(sprintf('The current run is attempt number %d - will not schedule a further attempt until we see something useful happening', 10));
409
  }
410
 
411
  // Sanity check
@@ -3054,7 +3029,6 @@ class UpdraftPlus {
3054
  $this->zipfiles_added = 0;
3055
  $this->zipfiles_dirbatched = array();
3056
  $this->zipfiles_batched = array();
3057
- $this->zipfiles_lastwritetime = time();
3058
 
3059
  // Magic value, used later to detect no error occurring
3060
  $last_error = 2349864;
@@ -3112,7 +3086,7 @@ class UpdraftPlus {
3112
  if (file_exists($zipfile)) {
3113
  $opencode = $zip->open($zipfile);
3114
  $original_size = filesize($zipfile);
3115
- clearstatcache();
3116
  } else {
3117
  $opencode = $zip->open($zipfile, ZIPARCHIVE::CREATE);
3118
  $original_size = 0;
@@ -3127,21 +3101,17 @@ class UpdraftPlus {
3127
  $fsize = filesize($file);
3128
  if (!isset($this->existing_files[$add_as]) || $this->existing_files[$add_as] != $fsize) {
3129
 
3130
- @touch($zipfile);
3131
  $zip->addFile($file, $add_as);
3132
 
3133
  $data_added_since_reopen += $fsize;
3134
  # 25Mb - force a write-out and re-open
3135
- if ($data_added_since_reopen > 26214400 || (time() - $this->zipfiles_lastwritetime) > 2) {
3136
 
3137
  $before_size = filesize($zipfile);
3138
- clearstatcache();
3139
 
3140
- if ($data_added_since_reopen > 26214400) {
3141
- $this->log("Adding batch to zip file: over 25Mb added on this batch (".round($data_added_since_reopen/1048576,1)." Mb); re-opening (prior size: ".round($before_size/1024,1).' Kb)');
3142
- } else {
3143
- $this->log("Adding batch to zip file: over 2 seconds have passed since the last write (".round($data_added_since_reopen/1048576,1)." Mb); re-opening (prior size: ".round($before_size/1024,1).' Kb)');
3144
- }
3145
  if (!$zip->close()) {
3146
  $this->log("zip::Close returned an error");
3147
  }
@@ -3150,33 +3120,23 @@ class UpdraftPlus {
3150
  $opencode = $zip->open($zipfile);
3151
  if ($opencode !== true) return array($opencode, 0);
3152
  $data_added_since_reopen = 0;
3153
- $this->zipfiles_lastwritetime = time();
3154
  // Call here, in case we've got so many big files that we don't complete the whole routine
3155
  if (filesize($zipfile) > $before_size) $this->something_useful_happened();
3156
- clearstatcache();
3157
  }
3158
  }
3159
  $this->zipfiles_added++;
3160
- // Don't call something_useful_happened() here - nothing necessarily happens until close() is called
3161
  if ($this->zipfiles_added % 100 == 0) $this->log("Zip: ".basename($zipfile).": ".$this->zipfiles_added." files added (on-disk size: ".round(filesize($zipfile)/1024,1)." Kb)");
3162
  }
3163
  // Reset the array
3164
  $this->zipfiles_batched = array();
3165
  $ret = $zip->close();
3166
- $this->zipfiles_lastwritetime = time();
3167
  if (filesize($zipfile) > $original_size) $this->something_useful_happened();
3168
- clearstatcache();
3169
  return $ret;
3170
  }
3171
 
3172
  function something_useful_happened() {
3173
-
3174
- // First, update the record of maximum detected runtime on each run
3175
- $time_passed = $this->jobdata_get('run_times');
3176
- if (!is_array($time_passed)) $time_passed = array();
3177
- $time_passed[$this->current_resumption] = microtime(true)-$this->opened_log_time;
3178
- $this->jobdata_set('run_times', $time_passed);
3179
-
3180
  if ($this->current_resumption >= 9 && $this->newresumption_scheduled == false) {
3181
  $resume_interval = $this->jobdata_get('resume_interval');
3182
  if (!is_numeric($resume_interval) || $resume_interval<$this->minimum_resume_interval()) { $resume_interval = $this->minimum_resume_interval(); }
4
  Plugin URI: http://updraftplus.com
5
  Description: Backup and restore: your site can be backed up locally or to Amazon S3, Dropbox, Google Drive, (S)FTP, WebDAV & email, on automatic schedules.
6
  Author: UpdraftPlus.Com, DavidAnderson
7
+ Version: 1.5.5
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
10
  Text Domain: updraftplus
144
  var $zipfiles_existingfiles;
145
  var $zipfiles_dirbatched;
146
  var $zipfiles_batched;
 
147
 
148
  var $zip_preferpcl = false;
149
 
350
  // This is scheduled for 5 minutes after a backup job starts
351
 
352
  // Restore state
 
353
  if ($resumption_no > 0) {
354
  $this->nonce = $bnonce;
355
  $this->backup_time = $this->jobdata_get('backup_time');
356
  $this->logfile_open($bnonce);
 
 
 
 
 
 
357
  }
358
 
 
359
  $btime = $this->backup_time;
360
 
361
  $job_type = $this->jobdata_get('job_type');
365
  $time_ago = time()-$btime;
366
 
367
  $this->current_resumption = $resumption_no;
368
+ $this->log("Backup run: resumption=$resumption_no, nonce=$bnonce, begun at=$btime (${time_ago}s ago), job type: $job_type");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
369
 
370
  // Schedule again, to run in 5 minutes again, in case we again fail
371
  // The actual interval can be increased (for future resumptions) by other code, if it detects apparent overlapping
380
  wp_schedule_single_event($schedule_for, 'updraft_backup_resume', array($next_resumption, $bnonce));
381
  $this->newresumption_scheduled = $schedule_for;
382
  } else {
383
+ $this->log(sprintf('The current run is attempt number %d - will not schedule a further attempt until we see something useful happening'), 10);
384
  }
385
 
386
  // Sanity check
3029
  $this->zipfiles_added = 0;
3030
  $this->zipfiles_dirbatched = array();
3031
  $this->zipfiles_batched = array();
 
3032
 
3033
  // Magic value, used later to detect no error occurring
3034
  $last_error = 2349864;
3086
  if (file_exists($zipfile)) {
3087
  $opencode = $zip->open($zipfile);
3088
  $original_size = filesize($zipfile);
3089
+ clearstatcache($zipfile);
3090
  } else {
3091
  $opencode = $zip->open($zipfile, ZIPARCHIVE::CREATE);
3092
  $original_size = 0;
3101
  $fsize = filesize($file);
3102
  if (!isset($this->existing_files[$add_as]) || $this->existing_files[$add_as] != $fsize) {
3103
 
3104
+ touch($file);
3105
  $zip->addFile($file, $add_as);
3106
 
3107
  $data_added_since_reopen += $fsize;
3108
  # 25Mb - force a write-out and re-open
3109
+ if ($data_added_since_reopen > 26214400) {
3110
 
3111
  $before_size = filesize($zipfile);
3112
+ clearstatcache($zipfile);
3113
 
3114
+ $this->log("Adding batch to zip file: over 25Mb added on this batch (".round($data_added_since_reopen/1048576,1)." Mb); re-opening (prior size: ".round($before_size/1024,1).' Kb)');
 
 
 
 
3115
  if (!$zip->close()) {
3116
  $this->log("zip::Close returned an error");
3117
  }
3120
  $opencode = $zip->open($zipfile);
3121
  if ($opencode !== true) return array($opencode, 0);
3122
  $data_added_since_reopen = 0;
 
3123
  // Call here, in case we've got so many big files that we don't complete the whole routine
3124
  if (filesize($zipfile) > $before_size) $this->something_useful_happened();
3125
+ clearstatcache($zipfile);
3126
  }
3127
  }
3128
  $this->zipfiles_added++;
 
3129
  if ($this->zipfiles_added % 100 == 0) $this->log("Zip: ".basename($zipfile).": ".$this->zipfiles_added." files added (on-disk size: ".round(filesize($zipfile)/1024,1)." Kb)");
3130
  }
3131
  // Reset the array
3132
  $this->zipfiles_batched = array();
3133
  $ret = $zip->close();
 
3134
  if (filesize($zipfile) > $original_size) $this->something_useful_happened();
3135
+ clearstatcache(zipfile);
3136
  return $ret;
3137
  }
3138
 
3139
  function something_useful_happened() {
 
 
 
 
 
 
 
3140
  if ($this->current_resumption >= 9 && $this->newresumption_scheduled == false) {
3141
  $resume_interval = $this->jobdata_get('resume_interval');
3142
  if (!is_numeric($resume_interval) || $resume_interval<$this->minimum_resume_interval()) { $resume_interval = $this->minimum_resume_interval(); }