UpdraftPlus WordPress Backup Plugin - Version 1.2.25

Version Description

  • 01/14/2013 =
  • Fixed bug with DropBox deletions
  • Fixed cases where DropBox failed to resume chunked uploading
Download this release

Release Info

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

Code changes from version 1.2.24 to 1.2.25

Files changed (4) hide show
  1. includes/Dropbox/API.php +6 -6
  2. methods/dropbox.php +36 -18
  3. readme.txt +3 -2
  4. updraftplus.php +9 -5
includes/Dropbox/API.php CHANGED
@@ -170,12 +170,12 @@ class Dropbox_API
170
  $uploadID = $response['body']->upload_id;
171
  }
172
 
173
- // Set the data offset
174
- $offset += mb_strlen($data, '8bit');
175
-
176
- if ($callback) {
177
- call_user_func($callback, $offset, $uploadID);
178
- }
179
 
180
  // Close the file handle for this chunk
181
  fclose($chunkHandle);
170
  $uploadID = $response['body']->upload_id;
171
  }
172
 
173
+ if (isset($response['body']->offset)) {
174
+ $offset = $response['body']->offset;
175
+ if ($callback) {
176
+ call_user_func($callback, $offset, $uploadID);
177
+ }
178
+ }
179
 
180
  // Close the file handle for this chunk
181
  fclose($chunkHandle);
methods/dropbox.php CHANGED
@@ -38,8 +38,8 @@ class UpdraftPlus_BackupModule_dropbox {
38
  $dropbox = $this->bootstrap(get_option('updraft_dropbox_appkey'), get_option('updraft_dropbox_secret'));
39
  $dropbox->setChunkSize(524288); // 512Kb
40
  } catch (Exception $e) {
41
- $updraftplus->log('DropBox error: '.print_r($e, true));
42
- $updraftplus->error('DropBox error: failed to access DropBox (see log file for more)');
43
  return false;
44
  }
45
 
@@ -69,14 +69,32 @@ class UpdraftPlus_BackupModule_dropbox {
69
  $upload_id = null;
70
  }
71
 
 
 
 
 
 
72
  try {
73
- //$put = $dropbox->putFile($updraft_dir.'/'.$file, $dropbox_folder.$file);
74
- // I did erroneously have $dropbox_folder as the third parameter - this causes a sub-directory to be created
75
- $dropbox->chunkedUpload($updraft_dir.'/'.$file, $file, '', true, $offset, $upload_id, array($this, 'chunked_callback'));
76
  } catch (Exception $e) {
77
- $updraftplus->log('DropBox error: '.print_r($e, true));
78
- $updraftplus->error("DropBox error: failed to upload file $file (see full log for more)");
79
- $file_success = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  }
81
  if ($file_success) {
82
  $updraftplus->uploaded_file($file);
@@ -108,7 +126,7 @@ class UpdraftPlus_BackupModule_dropbox {
108
  try {
109
  $dropbox = $this->bootstrap(get_option('updraft_dropbox_appkey'), get_option('updraft_dropbox_secret'));
110
  } catch (Exception $e) {
111
- $updraftplus->log('DropBox error: '.print_r($e, true));
112
  //$updraftplus->error('DropBox error: failed to access DropBox (see log file for more)');
113
  return false;
114
  }
@@ -120,9 +138,9 @@ class UpdraftPlus_BackupModule_dropbox {
120
  // Apparently $dropbox_folder is not needed
121
  $dropbox->delete($file);
122
  } catch (Exception $e) {
123
- $updraftplus->log('DropBox error: '.print_r($e, true));
124
  // TODO
125
- // Add this back July 2013 when removing the block below
126
  //$updraftplus->error("DropBox error: failed to delete file ($file): see log file for more info");
127
  $file_success = 0;
128
  }
@@ -130,11 +148,11 @@ class UpdraftPlus_BackupModule_dropbox {
130
  $updraftplus->log('DropBox: delete succeeded');
131
  } else {
132
  $file_success = 1;
133
- // We created the file in the wrong place for a while. This code is needed until July 2013, when it can be removed.
134
  try {
135
  $dropbox->delete($dropbox_folder.'/'.$file);
136
  } catch (Exception $e) {
137
- $updraftplus->log('DropBox error: '.print_r($e, true));
138
  $file_success = 1;
139
  }
140
  if ($file_success) $updraftplus->log('DropBox: delete succeeded (alternative path)');
@@ -154,7 +172,7 @@ class UpdraftPlus_BackupModule_dropbox {
154
  try {
155
  $dropbox = $this->bootstrap(get_option('updraft_dropbox_appkey'), get_option('updraft_dropbox_secret'));
156
  } catch (Exception $e) {
157
- $updraftplus->error('DropBox error: '.print_r($e, true));
158
  return false;
159
  }
160
 
@@ -165,12 +183,12 @@ class UpdraftPlus_BackupModule_dropbox {
165
  try {
166
  $get = $dropbox->getFile($file, $updraft_dir.'/'.$file);
167
  } catch (Exception $e) {
168
- // TODO: Remove this July 2013 (we stored in the wrong place for a while...)
169
  $try_the_other_one = true;
170
- $possible_error = print_r($e, true);
171
  }
172
 
173
- // TODO: Remove this July 2013 (we stored in the wrong place for a while...)
174
  if ($try_the_other_one) {
175
  $dropbox_folder = trailingslashit(get_option('updraft_dropbox_folder'));
176
  $updraftplus->error('DropBox error: '.$e);
@@ -178,7 +196,7 @@ class UpdraftPlus_BackupModule_dropbox {
178
  $get = $dropbox->getFile($file, $updraft_dir.'/'.$file);
179
  } catch (Exception $e) {
180
  $updraftplus->error($possible_error);
181
- $updraftplus->error(print_r($e, true));
182
  }
183
  }
184
 
38
  $dropbox = $this->bootstrap(get_option('updraft_dropbox_appkey'), get_option('updraft_dropbox_secret'));
39
  $dropbox->setChunkSize(524288); // 512Kb
40
  } catch (Exception $e) {
41
+ $updraftplus->log('DropBox error: '.$e->getMessage().' (line: '.$e->getLine().', file: '.$e->getFile().')');
42
+ $updraftplus->error('DropBox error: '.$e->getMessage().' (see log file for more)');
43
  return false;
44
  }
45
 
69
  $upload_id = null;
70
  }
71
 
72
+ // I did erroneously have $dropbox_folder as the third parameter in chunkedUpload... this causes a sub-directory to be created
73
+ // Old-style, single file put: $put = $dropbox->putFile($updraft_dir.'/'.$file, $dropbox_folder.$file);
74
+
75
+ $ourself = $this;
76
+
77
  try {
78
+ $dropbox->chunkedUpload($updraft_dir.'/'.$file, $file, '', true, $offset, $upload_id, array($ourself, 'chunked_callback'));
 
 
79
  } catch (Exception $e) {
80
+ $updraftplus->log("Exception: ".$e->getMessage());
81
+ if (preg_match("/Submitted input out of alignment: got \[(\d+)\] expected \[(\d+)\]/i", $e->getMessage(), $matches)) {
82
+ // Try the indicated offset
83
+ $we_tried = $matches[1];
84
+ $dropbox_wanted = $matches[2];
85
+ $updraftplus->log("DropBox alignment error: tried=$we_tried, wanted=$dropbox_wanted; will attempt recovery");
86
+ try {
87
+ $dropbox->chunkedUpload($updraft_dir.'/'.$file, $file, '', true, $dropbox_wanted, $upload_id, array($ourself, 'chunked_callback'));
88
+ } catch (Exception $e) {
89
+ $updraftplus->log('DropBox error: '.$e->getMessage().' (line: '.$e->getLine().', file: '.$e->getFile().')');
90
+ $updraftplus->error("DropBox error: failed to upload file $file (see full log for more)");
91
+ $file_success = 0;
92
+ }
93
+ } else {
94
+ $updraftplus->log('DropBox error: '.$e->getMessage());
95
+ $updraftplus->error("DropBox error: failed to upload file $file (see full log for more)");
96
+ $file_success = 0;
97
+ }
98
  }
99
  if ($file_success) {
100
  $updraftplus->uploaded_file($file);
126
  try {
127
  $dropbox = $this->bootstrap(get_option('updraft_dropbox_appkey'), get_option('updraft_dropbox_secret'));
128
  } catch (Exception $e) {
129
+ $updraftplus->log('DropBox error: '.$e->getMessage().' (line: '.$e->getLine().', file: '.$e->getFile().')');
130
  //$updraftplus->error('DropBox error: failed to access DropBox (see log file for more)');
131
  return false;
132
  }
138
  // Apparently $dropbox_folder is not needed
139
  $dropbox->delete($file);
140
  } catch (Exception $e) {
141
+ $updraftplus->log('DropBox error: '.$e->getMessage().' (line: '.$e->getLine().', file: '.$e->getFile().')');
142
  // TODO
143
+ // Add this back October 2013 when removing the block below
144
  //$updraftplus->error("DropBox error: failed to delete file ($file): see log file for more info");
145
  $file_success = 0;
146
  }
148
  $updraftplus->log('DropBox: delete succeeded');
149
  } else {
150
  $file_success = 1;
151
+ // We created the file in the wrong place for a while. This code is needed until October 2013, when it can be removed.
152
  try {
153
  $dropbox->delete($dropbox_folder.'/'.$file);
154
  } catch (Exception $e) {
155
+ $updraftplus->log('DropBox error: '.$e->getMessage().' (line: '.$e->getLine().', file: '.$e->getFile().')');
156
  $file_success = 1;
157
  }
158
  if ($file_success) $updraftplus->log('DropBox: delete succeeded (alternative path)');
172
  try {
173
  $dropbox = $this->bootstrap(get_option('updraft_dropbox_appkey'), get_option('updraft_dropbox_secret'));
174
  } catch (Exception $e) {
175
+ $updraftplus->log('DropBox error: '.$e->getMessage().' (line: '.$e->getLine().', file: '.$e->getFile().')');
176
  return false;
177
  }
178
 
183
  try {
184
  $get = $dropbox->getFile($file, $updraft_dir.'/'.$file);
185
  } catch (Exception $e) {
186
+ // TODO: Remove this October 2013 (we stored in the wrong place for a while...)
187
  $try_the_other_one = true;
188
+ $possible_error = $e->getMessage();
189
  }
190
 
191
+ // TODO: Remove this October 2013 (we stored in the wrong place for a while...)
192
  if ($try_the_other_one) {
193
  $dropbox_folder = trailingslashit(get_option('updraft_dropbox_folder'));
194
  $updraftplus->error('DropBox error: '.$e);
196
  $get = $dropbox->getFile($file, $updraft_dir.'/'.$file);
197
  } catch (Exception $e) {
198
  $updraftplus->error($possible_error);
199
+ $updraftplus->error($e->getMessage());
200
  }
201
  }
202
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: David Anderson
3
  Tags: backup, restore, database, cloud, amazon, s3, Amazon S3, DropBox, DropBox backup, 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.2.24
7
  Donate link: http://david.dw-perspective.org.uk/donate
8
  License: GPLv3 or later
9
 
@@ -112,8 +112,9 @@ Thanks for asking - yes, I have. Check out my profile page - http://profiles.wor
112
 
113
  == Changelog ==
114
 
115
- = 1.2.24 - 01/14/2013 =
116
  * Fixed bug with DropBox deletions
 
117
 
118
  = 1.2.20 - 01/12/2013 =
119
  * DropBox no longer limited to 150Mb uploads
3
  Tags: backup, restore, database, cloud, amazon, s3, Amazon S3, DropBox, DropBox backup, 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.2.25
7
  Donate link: http://david.dw-perspective.org.uk/donate
8
  License: GPLv3 or later
9
 
112
 
113
  == Changelog ==
114
 
115
+ = 1.2.25 - 01/14/2013 =
116
  * Fixed bug with DropBox deletions
117
+ * Fixed cases where DropBox failed to resume chunked uploading
118
 
119
  = 1.2.20 - 01/12/2013 =
120
  * DropBox no longer limited to 150Mb uploads
updraftplus.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: UpdraftPlus - Backup/Restore
4
  Plugin URI: http://wordpress.org/extend/plugins/updraftplus
5
  Description: Backup and restore: All your content and your DB can be automatically backed up to Amazon S3, DropBox, Google Drive, FTP, or emailed, on separate schedules.
6
  Author: David Anderson.
7
- Version: 1.2.22
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
10
  Author URI: http://wordshell.net
@@ -17,10 +17,13 @@ TODO
17
  //?? On 'backup now', open up a Lightbox, count down 5 seconds, then start examining the log file (if it can be found)
18
  //Should make clear in dashboard what is a non-fatal error (i.e. can be retried) - leads to unnecessary bug reports
19
  //Eventually, when everything can be resumed, we will no longer need the backup() routine; it can be replaced with the resume() routine
 
20
  // Should we resume if the only errors were upon deletion (i.e. the backup itself was fine?) Presently we do, but it displays errors for the user to confuse them.
21
  // Separate 'retain' settings for db + files (since they are on separate schedules)
22
  // Warn the user if their zip-file creation is slooowww...
23
  // Create a "Want Support?" button/console, that leads them through what is needed, and performs some basic tests...
 
 
24
 
25
  Encrypt filesystem, if memory allows (and have option for abort if not); split up into multiple zips when needed
26
  // Does not delete old custom directories upon a restore?
@@ -62,7 +65,7 @@ define('UPDRAFT_DEFAULT_OTHERS_EXCLUDE','upgrade,cache,updraft,index.php');
62
 
63
  class UpdraftPlus {
64
 
65
- var $version = '1.2.22';
66
 
67
  // Choices will be shown in the admin menu in the order used here
68
  var $backup_methods = array (
@@ -321,9 +324,10 @@ class UpdraftPlus {
321
  // Do not set the transient or schedule the resume event until now, when we know there is something to do - otherwise 'vacatated' runs (when the database is on the same schedule as the files, and they get combined, leading to an empty run) can over-write the resume event and prevent resumption (because it is 'successful' - there was nothing to do).
322
  // If we don't finish in 3 hours, then we won't finish
323
  // This transient indicates the identity of the current backup job (which can be used to find the files and logfile)
324
- set_transient("updraftplus_backup_job_nonce",$this->nonce,3600*3);
325
- set_transient("updraftplus_backup_job_time",$this->backup_time,3600*3);
326
- // Schedule the even to run later, which checks on success and can resume the backup
 
327
  // We save the time to a variable because it is needed for un-scheduling
328
  $resume_delay = 300;
329
  wp_schedule_single_event(time()+$resume_delay, 'updraft_backup_resume', array(1));
4
  Plugin URI: http://wordpress.org/extend/plugins/updraftplus
5
  Description: Backup and restore: All your content and your DB can be automatically backed up to Amazon S3, DropBox, Google Drive, FTP, or emailed, on separate schedules.
6
  Author: David Anderson.
7
+ Version: 1.2.25
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
10
  Author URI: http://wordshell.net
17
  //?? On 'backup now', open up a Lightbox, count down 5 seconds, then start examining the log file (if it can be found)
18
  //Should make clear in dashboard what is a non-fatal error (i.e. can be retried) - leads to unnecessary bug reports
19
  //Eventually, when everything can be resumed, we will no longer need the backup() routine; it can be replaced with the resume() routine
20
+ //Remind user to look inside their 'apps' folder in DropBox
21
  // Should we resume if the only errors were upon deletion (i.e. the backup itself was fine?) Presently we do, but it displays errors for the user to confuse them.
22
  // Separate 'retain' settings for db + files (since they are on separate schedules)
23
  // Warn the user if their zip-file creation is slooowww...
24
  // Create a "Want Support?" button/console, that leads them through what is needed, and performs some basic tests...
25
+ // Add/test FTP-over-TLS
26
+ // Resuming partial FTP uploads
27
 
28
  Encrypt filesystem, if memory allows (and have option for abort if not); split up into multiple zips when needed
29
  // Does not delete old custom directories upon a restore?
65
 
66
  class UpdraftPlus {
67
 
68
+ var $version = '1.2.25';
69
 
70
  // Choices will be shown in the admin menu in the order used here
71
  var $backup_methods = array (
324
  // Do not set the transient or schedule the resume event until now, when we know there is something to do - otherwise 'vacatated' runs (when the database is on the same schedule as the files, and they get combined, leading to an empty run) can over-write the resume event and prevent resumption (because it is 'successful' - there was nothing to do).
325
  // If we don't finish in 3 hours, then we won't finish
326
  // This transient indicates the identity of the current backup job (which can be used to find the files and logfile)
327
+ set_transient("updraftplus_backup_job_nonce", $this->nonce,3600*3);
328
+ set_transient("updraftplus_backup_job_time", $this->backup_time,3600*3);
329
+
330
+ // Schedule the event to run later, which checks on success and can resume the backup
331
  // We save the time to a variable because it is needed for un-scheduling
332
  $resume_delay = 300;
333
  wp_schedule_single_event(time()+$resume_delay, 'updraft_backup_resume', array(1));