UpdraftPlus WordPress Backup Plugin - Version 1.1.14

Version Description

  • 01/07/2013 =
  • Requested feature: more frequent scheduling options requested
  • Fixed bug which mangled default suggestion for backup working directory on Windows
  • Provide a 'Test S3 Settings' button for Amazon S3 users
Download this release

Release Info

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

Code changes from version 1.1.13 to 1.1.14

Files changed (4) hide show
  1. methods/googledrive.php +12 -5
  2. methods/s3.php +43 -5
  3. readme.txt +6 -4
  4. updraftplus.php +28 -2
methods/googledrive.php CHANGED
@@ -186,8 +186,13 @@ class UpdraftPlus_BackupModule_googledrive {
186
  $res = $location;
187
  $updraftplus->log("Uploading file with title ".$title);
188
  $d = 0;
 
 
189
  do {
190
- $updraftplus->log("Google Drive upload: chunk d: $d, loc: $res");
 
 
 
191
  $res = $gdocs_object->upload_chunk();
192
  if (is_string($res)) set_transient($transkey, $res, 3600*3);
193
  $p = $gdocs_object->get_upload_percentage();
@@ -283,8 +288,10 @@ class UpdraftPlus_BackupModule_googledrive {
283
  if ( is_wp_error( $this->gdocs_access_token ) ) return $access_token;
284
 
285
  $this->gdocs = new UpdraftPlus_GDocs( $this->gdocs_access_token );
286
- $this->gdocs->set_option( 'chunk_size', 1 ); # 1Mb; change from default of 512Kb
287
- $this->gdocs->set_option( 'request_timeout', 10 ); # Change from default of 10s
 
 
288
  $this->gdocs->set_option( 'max_resume_attempts', 36 ); # Doesn't look like GDocs class actually uses this anyway
289
  }
290
  return true;
@@ -321,7 +328,7 @@ class UpdraftPlus_BackupModule_googledrive {
321
  </tr>
322
  <tr class="updraftplusmethod googledrive">
323
  <th>Google Drive Folder ID:</th>
324
- <td><input type="text" style="width:332px" name="updraft_googledrive_remotepath" value="<?php echo htmlspecialchars(get_option('updraft_googledrive_remotepath')); ?>" /> <em>(To get a folder's ID navigate to that folder in Google Drive in your web browser and copy the ID from your browser's address bar. It is the part that comes after <kbd>#folders/.</kbd> Leave empty to use your root folder)</em></td>
325
  </tr>
326
  <tr class="updraftplusmethod googledrive">
327
  <th>Authenticate with Google:</th>
@@ -334,4 +341,4 @@ class UpdraftPlus_BackupModule_googledrive {
334
 
335
  }
336
 
337
- ?>
186
  $res = $location;
187
  $updraftplus->log("Uploading file with title ".$title);
188
  $d = 0;
189
+ // This counter is only used for when deciding what to log
190
+ $counter = 0;
191
  do {
192
+ $log_string = ($counter == 0) ? "Upload %: $d, URL: $res" : "Upload %: $d";
193
+ $counter++; if ($counter >= 20) $counter=0;
194
+ $updraftplus->log($log_string);
195
+
196
  $res = $gdocs_object->upload_chunk();
197
  if (is_string($res)) set_transient($transkey, $res, 3600*3);
198
  $p = $gdocs_object->get_upload_percentage();
288
  if ( is_wp_error( $this->gdocs_access_token ) ) return $access_token;
289
 
290
  $this->gdocs = new UpdraftPlus_GDocs( $this->gdocs_access_token );
291
+ // We need to be able to upload at least one chunk within the timeout (at least, we have seen an error report where the failure to do this seemed to be the cause)
292
+ // If we assume a user has at least 16kb/s (we saw one user with as low as 22kb/s), and that their provider may allow them only 15s, then we have the following settings
293
+ $this->gdocs->set_option( 'chunk_size', 0.2 ); # 0.2Mb; change from default of 512Kb
294
+ $this->gdocs->set_option( 'request_timeout', 15 ); # Change from default of 5s
295
  $this->gdocs->set_option( 'max_resume_attempts', 36 ); # Doesn't look like GDocs class actually uses this anyway
296
  }
297
  return true;
328
  </tr>
329
  <tr class="updraftplusmethod googledrive">
330
  <th>Google Drive Folder ID:</th>
331
+ <td><input type="text" style="width:332px" name="updraft_googledrive_remotepath" value="<?php echo htmlspecialchars(get_option('updraft_googledrive_remotepath')); ?>" /> <em><strong>This is NOT a folder name</strong>. To get a folder's ID navigate to that folder in Google Drive in your web browser and copy the ID from your browser's address bar. It is the part that comes after <kbd>#folders/.</kbd> Leave empty to use your root folder)</em></td>
332
  </tr>
333
  <tr class="updraftplusmethod googledrive">
334
  <th>Authenticate with Google:</th>
341
 
342
  }
343
 
344
+ ?>
methods/s3.php CHANGED
@@ -163,24 +163,62 @@ class UpdraftPlus_BackupModule_s3 {
163
  <td></td>
164
  <td><em>Amazon S3 is a great choice, because UpdraftPlus supports chunked uploads - no matter how big your blog is, UpdraftPlus can upload it a little at a time, and not get thwarted by timeouts.</em></td>
165
  </tr>
 
 
 
 
 
166
  <tr class="updraftplusmethod s3">
167
  <th>S3 access key:</th>
168
- <td><input type="text" autocomplete="off" style="width: 292px" name="updraft_s3_login" value="<?php echo htmlspecialchars(get_option('updraft_s3_login')) ?>" /></td>
169
  </tr>
170
  <tr class="updraftplusmethod s3">
171
  <th>S3 secret key:</th>
172
- <td><input type="text" autocomplete="off" style="width: 292px" name="updraft_s3_pass" value="<?php echo htmlspecialchars(get_option('updraft_s3_pass')); ?>" /></td>
173
  </tr>
174
  <tr class="updraftplusmethod s3">
175
  <th>S3 location:</th>
176
- <td>s3://<input type="text" style="width: 292px" name="updraft_s3_remote_path" value="<?php echo htmlspecialchars(get_option('updraft_s3_remote_path')); ?>" /></td>
177
  </tr>
178
- <tr class="updraftplusmethod s3">
179
  <th></th>
180
- <td><p>Get your access key and secret key from your AWS page, then pick a (globally unique) bucket name (letters and numbers) (and optionally a path) to use for storage. This bucket will be created for you if it does not already exist.</p></td>
181
  </tr>
182
  <?php
183
  }
184
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  }
186
  ?>
163
  <td></td>
164
  <td><em>Amazon S3 is a great choice, because UpdraftPlus supports chunked uploads - no matter how big your blog is, UpdraftPlus can upload it a little at a time, and not get thwarted by timeouts.</em></td>
165
  </tr>
166
+ <tr class="updraftplusmethod s3">
167
+ <th></th>
168
+ <td>
169
+ <p>Get your access key and secret key <a href="http://aws.amazon.com/console/">from your AWS console</a>, then pick a (globally unique - all Amazon S3 users) bucket name (letters and numbers) (and optionally a path) to use for storage. This bucket will be created for you if it does not already exist.</p>
170
+ </td></tr>
171
  <tr class="updraftplusmethod s3">
172
  <th>S3 access key:</th>
173
+ <td><input type="text" autocomplete="off" style="width: 292px" id="updraft_s3_apikey" name="updraft_s3_login" value="<?php echo htmlspecialchars(get_option('updraft_s3_login')) ?>" /></td>
174
  </tr>
175
  <tr class="updraftplusmethod s3">
176
  <th>S3 secret key:</th>
177
+ <td><input type="text" autocomplete="off" style="width: 292px" id="updraft_s3_apisecret" name="updraft_s3_pass" value="<?php echo htmlspecialchars(get_option('updraft_s3_pass')); ?>" /></td>
178
  </tr>
179
  <tr class="updraftplusmethod s3">
180
  <th>S3 location:</th>
181
+ <td>s3://<input type="text" style="width: 292px" name="updraft_s3_remote_path" id="updraft_s3_path" value="<?php echo htmlspecialchars(get_option('updraft_s3_remote_path')); ?>" /></td>
182
  </tr>
183
+ <tr>
184
  <th></th>
185
+ <td><p><button id="updraft-s3-test" type="button" class="button-primary" style="font-size:18px !important">Test S3 Settings</button></p></td>
186
  </tr>
187
  <?php
188
  }
189
 
190
+ function s3_test($key, $secret, $path) {
191
+ $bucket = (preg_match("#^([^/]+)/(.*)$#", $path, $bmatches)) ? $bmatches[1] : $path;
192
+
193
+ if (empty($bucket)) {
194
+ echo "Failure: No bucket details were given.";
195
+ return;
196
+ }
197
+ if (empty($key)) {
198
+ echo "Failure: No API key was given.";
199
+ return;
200
+ }
201
+ if (empty($secret)) {
202
+ echo "Failure: No API secret was given.";
203
+ return;
204
+ }
205
+
206
+ if (!class_exists('S3')) require_once(UPDRAFTPLUS_DIR.'/includes/S3.php');
207
+ $s3 = new S3($key, $secret);
208
+
209
+ $location = @$s3->getBucketLocation($bucket);
210
+ if ($location) {
211
+ echo "Success: this bucket exists (Amazon region: $location) and we have access to it.";
212
+ } else {
213
+ $try_to_create = @$s3->putBucket($bucket, S3::ACL_PRIVATE);
214
+ if ($try_to_create) {
215
+ echo "Success: We have successfully created this bucket in your S3 account.";
216
+ } else {
217
+ echo "Failure: We could not successfully access or create such a bucket. Please check your access credentials, and if those are correct then try another bucket name (as another S3 user may already have taken this name).";
218
+ }
219
+ }
220
+
221
+ }
222
+
223
  }
224
  ?>
readme.txt CHANGED
@@ -3,12 +3,12 @@ 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.1.13
7
  Donate link: http://david.dw-perspective.org.uk/donate
8
  License: GPLv3 or later
9
 
10
  == Upgrade Notice ==
11
- Big code re-organisation to make programming new cloud methods easier. Note that Google Drive users may need to re-authenticate - please check. Also, more operations made resumable.
12
 
13
  == Description ==
14
 
@@ -22,6 +22,7 @@ UpdraftPlus simplifies backups (and restoration). Backup into the cloud (Amazon
22
  * Select which files to backup (plugins, themes, content, other)
23
  * Databases can be encrypted for security
24
  * Debug mode that gives full logging
 
25
 
26
  == Installation ==
27
 
@@ -111,11 +112,12 @@ Thanks for asking - yes, I have. Check out my profile page - http://profiles.wor
111
 
112
  == Changelog ==
113
 
114
- = 1.1.13 - 05/01/2013 =
115
  * Requested feature: more frequent scheduling options requested
116
  * Fixed bug which mangled default suggestion for backup working directory on Windows
 
117
 
118
- = 1.1.11 - 04/01/2013 =
119
  * Bug fix: some backup runs were erroneously being identified as superfluous and cancelled
120
 
121
  = 1.1.9 - 12/31/2012 =
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.1.14
7
  Donate link: http://david.dw-perspective.org.uk/donate
8
  License: GPLv3 or later
9
 
10
  == Upgrade Notice ==
11
+ Provide a 'Test S3 Settings' button for Amazon S3 users
12
 
13
  == Description ==
14
 
22
  * Select which files to backup (plugins, themes, content, other)
23
  * Databases can be encrypted for security
24
  * Debug mode that gives full logging
25
+ * Thousands of users: widely tested and reliable
26
 
27
  == Installation ==
28
 
112
 
113
  == Changelog ==
114
 
115
+ = 1.1.14 - 01/07/2013 =
116
  * Requested feature: more frequent scheduling options requested
117
  * Fixed bug which mangled default suggestion for backup working directory on Windows
118
+ * Provide a 'Test S3 Settings' button for Amazon S3 users
119
 
120
+ = 1.1.11 - 01/04/2013 =
121
  * Bug fix: some backup runs were erroneously being identified as superfluous and cancelled
122
 
123
  = 1.1.9 - 12/31/2012 =
updraftplus.php CHANGED
@@ -4,7 +4,7 @@ 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.1.13
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
10
  Author URI: http://wordshell.net
@@ -56,7 +56,7 @@ define('UPDRAFT_DEFAULT_OTHERS_EXCLUDE','upgrade,cache,updraft,index.php');
56
 
57
  class UpdraftPlus {
58
 
59
- var $version = '1.1.13';
60
 
61
  // Choices will be shown in the admin menu in the order used here
62
  var $backup_methods = array (
@@ -85,7 +85,9 @@ class UpdraftPlus {
85
  add_action('updraft_backup_all', array($this,'backup_all'));
86
  # this is our runs-after-backup event, whose purpose is to see if it succeeded or failed, and resume/mom-up etc.
87
  add_action('updraft_backup_resume', array($this,'backup_resume'));
 
88
  add_action('wp_ajax_updraft_download_backup', array($this, 'updraft_download_backup'));
 
89
  # http://codex.wordpress.org/Plugin_API/Filter_Reference/cron_schedules
90
  add_filter('cron_schedules', array($this,'modify_cron_schedules'));
91
  add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2);
@@ -1072,6 +1074,14 @@ class UpdraftPlus {
1072
  return $updraft_dir;
1073
  }
1074
 
 
 
 
 
 
 
 
 
1075
  function updraft_download_backup() {
1076
  $type = $_POST['type'];
1077
  $timestamp = (int)$_POST['timestamp'];
@@ -1322,6 +1332,11 @@ class UpdraftPlus {
1322
  }
1323
  }
1324
 
 
 
 
 
 
1325
  function add_admin_pages() {
1326
  add_submenu_page('options-general.php', "UpdraftPlus", "UpdraftPlus", "manage_options", "updraftplus",
1327
  array($this,"settings_output"));
@@ -1765,6 +1780,17 @@ echo $delete_local; ?> /> <br>Check this to delete the local backup file (only s
1765
  <?php
1766
  if ($active_service) echo "jQuery('.${active_service}').show();";
1767
  ?>
 
 
 
 
 
 
 
 
 
 
 
1768
  });
1769
  /* ]]> */
1770
  </script>
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.1.14
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
10
  Author URI: http://wordshell.net
56
 
57
  class UpdraftPlus {
58
 
59
+ var $version = '1.1.14';
60
 
61
  // Choices will be shown in the admin menu in the order used here
62
  var $backup_methods = array (
85
  add_action('updraft_backup_all', array($this,'backup_all'));
86
  # this is our runs-after-backup event, whose purpose is to see if it succeeded or failed, and resume/mom-up etc.
87
  add_action('updraft_backup_resume', array($this,'backup_resume'));
88
+ add_action('wp_enqueue_scripts', array($this, 'ajax_enqueue') );
89
  add_action('wp_ajax_updraft_download_backup', array($this, 'updraft_download_backup'));
90
+ add_action('wp_ajax_updraft_s3_test', array($this, 'updraft_s3_test'));
91
  # http://codex.wordpress.org/Plugin_API/Filter_Reference/cron_schedules
92
  add_filter('cron_schedules', array($this,'modify_cron_schedules'));
93
  add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2);
1074
  return $updraft_dir;
1075
  }
1076
 
1077
+ // Called via AJAX
1078
+ function updraft_s3_test() {
1079
+ // Test the credentials, return a code
1080
+ require_once(UPDRAFTPLUS_DIR.'/methods/s3.php');
1081
+ UpdraftPlus_BackupModule_s3::s3_test($_POST['apikey'], $_POST['apisecret'], $_POST['path']);
1082
+ die;
1083
+ }
1084
+
1085
  function updraft_download_backup() {
1086
  $type = $_POST['type'];
1087
  $timestamp = (int)$_POST['timestamp'];
1332
  }
1333
  }
1334
 
1335
+ function ajax_enqueue() {
1336
+ wp_enqueue_script('updraftplus-ajax', plugins_url('/includes/ajax.js', __FILE__) );
1337
+ wp_localize_script('updraftplus-ajax', 'updraft_test_s3', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
1338
+ }
1339
+
1340
  function add_admin_pages() {
1341
  add_submenu_page('options-general.php', "UpdraftPlus", "UpdraftPlus", "manage_options", "updraftplus",
1342
  array($this,"settings_output"));
1780
  <?php
1781
  if ($active_service) echo "jQuery('.${active_service}').show();";
1782
  ?>
1783
+ jQuery('#updraft-s3-test').click(function(){
1784
+ var data = {
1785
+ action: 'updraft_s3_test',
1786
+ apikey: jQuery('#updraft_s3_apikey').val(),
1787
+ apisecret: jQuery('#updraft_s3_apisecret').val(),
1788
+ path: jQuery('#updraft_s3_path').val()
1789
+ };
1790
+ jQuery.post(ajaxurl, data, function(response) {
1791
+ alert('Settings test result: ' + response);
1792
+ });
1793
+ });
1794
  });
1795
  /* ]]> */
1796
  </script>