UpdraftPlus WordPress Backup Plugin - Version 1.7.35

Version Description

  • 2013/10/26 =

  • FIX: Fix potential problem whereby some tables could be missed from the backup on WPMU (WP multisite) installs. Strongly recommended that all WPMU users update and take a fresh backup.

  • FIX: Work around http://bugs.mysql.com/62077 (could cause permanently stuck lock on databases with wrong collocations - if you have this problem, then no backups happen)

  • TWEAK: Don't use binzip method on OpenVZ with low memory

  • TWEAK: Suppress a couple of spurious messages in the log

  • TWEAK: Add facility to quickly download log files in the 'expert settings' section

Download this release

Release Info

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

Code changes from version 1.7.34 to 1.7.35

Files changed (6) hide show
  1. admin.php +21 -5
  2. backup.php +83 -46
  3. class-zip.php +47 -32
  4. methods/googledrive.php +1 -1
  5. readme.txt +12 -4
  6. updraftplus.php +19 -13
admin.php CHANGED
@@ -717,6 +717,7 @@ class UpdraftPlus_Admin {
717
  echo '<h3>'.__('Known backups (raw)', 'updraftplus').'</h3><pre>';
718
  var_dump($updraftplus->get_backup_history());
719
  echo '</pre>';
 
720
  echo '<h3>Files</h3><pre>';
721
  $updraft_dir = $updraftplus->backups_dir_location();
722
  $raw_output = array();
@@ -736,10 +737,21 @@ class UpdraftPlus_Admin {
736
  if (preg_match('/^log\.(.*)\.txt$/', $entry, $lmatch)) $entry = '<a target="_top" href="?action=downloadlog&page=updraftplus&updraftplus_backup_nonce='.htmlspecialchars($lmatch[1]).'">'.$entry.'</a>';
737
  $raw_output[$mtime] = empty($raw_output[$mtime]) ? sprintf("%s %s\n", $size, $entry) : $raw_output[$mtime].sprintf("%s %s\n", $size, $entry);
738
  }
 
739
  krsort($raw_output, SORT_NUMERIC);
740
  foreach ($raw_output as $line) echo $line;
741
  echo '</pre>';
742
- @$d->close();
 
 
 
 
 
 
 
 
 
 
743
  } elseif ('countbackups' == $_REQUEST['subaction']) {
744
  $backup_history = UpdraftPlus_Options::get_updraft_option('updraft_backup_history');
745
  $backup_history = (is_array($backup_history))?$backup_history:array();
@@ -1310,8 +1322,7 @@ CREATE TABLE $wpdb->signups (
1310
  // if (!is_a($updraftplus_backup, 'UpdraftPlus_Backup')) require_once(UPDRAFTPLUS_DIR.'/backup.php');
1311
  // $updraftplus_backup->backup_db();
1312
  } elseif (isset($_POST['action']) && $_POST['action'] == 'updraft_wipesettings') {
1313
- $settings = array('updraft_autobackup_default', 'updraftplus_tmp_googledrive_access_token', 'updraftplus_dismissedautobackup', 'updraft_interval', 'updraft_interval_database', 'updraft_retain', 'updraft_retain_db', 'updraft_encryptionphrase', 'updraft_service', 'updraft_dropbox_appkey', 'updraft_dropbox_secret', 'updraft_googledrive_clientid', 'updraft_googledrive_secret', 'updraft_googledrive_remotepath', 'updraft_ftp_login', 'updraft_ftp_pass', 'updraft_ftp_remote_path', 'updraft_server_address', 'updraft_dir', 'updraft_email', 'updraft_delete_local', 'updraft_debug_mode', 'updraft_include_plugins', 'updraft_include_themes', 'updraft_include_uploads', 'updraft_include_others', 'updraft_include_wpcore', 'updraft_include_wpcore_exclude', 'updraft_include_more',
1314
- 'updraft_include_blogs', 'updraft_include_mu-plugins', 'updraft_include_others_exclude', 'updraft_lastmessage', 'updraft_googledrive_clientid', 'updraft_googledrive_token', 'updraft_dropboxtk_request_token', 'updraft_dropboxtk_access_token', 'updraft_dropbox_folder', 'updraft_last_backup', 'updraft_starttime_files', 'updraft_starttime_db', 'updraft_startday_db', 'updraft_startday_files', 'updraft_sftp_settings', 'updraft_s3generic_login', 'updraft_s3generic_pass', 'updraft_s3generic_remote_path', 'updraft_s3generic_endpoint', 'updraft_webdav_settings', 'updraft_disable_ping', 'updraft_cloudfiles_user', 'updraft_cloudfiles_apikey', 'updraft_cloudfiles_path', 'updraft_cloudfiles_authurl', 'updraft_ssl_useservercerts', 'updraft_ssl_disableverify', 'updraft_s3_login', 'updraft_s3_pass', 'updraft_s3_remote_path', 'updraft_dreamobjects_login', 'updraft_dreamobjects_pass', 'updraft_dreamobjects_remote_path');
1315
 
1316
  foreach ($settings as $s) UpdraftPlus_Options::delete_updraft_option($s);
1317
 
@@ -2386,7 +2397,7 @@ CREATE TABLE $wpdb->signups (
2386
 
2387
  ?><div class="error updraftplusmethod <?php echo $extraclass; ?>"><p><?php echo $text; ?></p></div>
2388
 
2389
- <p><?php echo $text; ?></p>
2390
 
2391
  <?php
2392
 
@@ -2400,7 +2411,7 @@ CREATE TABLE $wpdb->signups (
2400
 
2401
  function curl_check($service, $has_fallback = false, $extraclass = '') {
2402
  // Check requirements
2403
- if (!function_exists("curl_init")) {
2404
 
2405
  $this->show_double_warning('<strong>'.__('Warning','updraftplus').':</strong> '.sprintf(__('Your web server\'s PHP installation does not included a <strong>required</strong> (for %s) module (%s). Please contact your web hosting provider\'s support and ask for them to enable it.', 'updraftplus'), $service, 'Curl').' '.sprintf(__("Your options are 1) Install/enable %s or 2) Change web hosting companies - %s is a standard PHP component, and required by all cloud backup plugins that we know of.",'updraftplus'), 'Curl', 'Curl'), $extraclass);
2406
 
@@ -2907,6 +2918,11 @@ ENDHERE;
2907
  return strcmp($a, $b);
2908
  }
2909
 
 
 
 
 
 
2910
  }
2911
 
2912
  ?>
717
  echo '<h3>'.__('Known backups (raw)', 'updraftplus').'</h3><pre>';
718
  var_dump($updraftplus->get_backup_history());
719
  echo '</pre>';
720
+
721
  echo '<h3>Files</h3><pre>';
722
  $updraft_dir = $updraftplus->backups_dir_location();
723
  $raw_output = array();
737
  if (preg_match('/^log\.(.*)\.txt$/', $entry, $lmatch)) $entry = '<a target="_top" href="?action=downloadlog&page=updraftplus&updraftplus_backup_nonce='.htmlspecialchars($lmatch[1]).'">'.$entry.'</a>';
738
  $raw_output[$mtime] = empty($raw_output[$mtime]) ? sprintf("%s %s\n", $size, $entry) : $raw_output[$mtime].sprintf("%s %s\n", $size, $entry);
739
  }
740
+ @$d->close();
741
  krsort($raw_output, SORT_NUMERIC);
742
  foreach ($raw_output as $line) echo $line;
743
  echo '</pre>';
744
+
745
+ echo '<h3>'.__('Options (raw)', 'updraftplus').'</h3>';
746
+ $opts = $this->get_settings_keys();
747
+ asort($opts);
748
+ // <tr><th>'.__('Key','updraftplus').'</th><th>'.__('Value','updraftplus').'</th></tr>
749
+ echo '<table><thead></thead><tbody>';
750
+ foreach ($opts as $opt) {
751
+ echo '<tr><td>'.htmlspecialchars($opt).'</td><td>'.htmlspecialchars(print_r(UpdraftPlus_Options::get_updraft_option($opt), true)).'</td>';
752
+ }
753
+ echo '</tbody></table>';
754
+
755
  } elseif ('countbackups' == $_REQUEST['subaction']) {
756
  $backup_history = UpdraftPlus_Options::get_updraft_option('updraft_backup_history');
757
  $backup_history = (is_array($backup_history))?$backup_history:array();
1322
  // if (!is_a($updraftplus_backup, 'UpdraftPlus_Backup')) require_once(UPDRAFTPLUS_DIR.'/backup.php');
1323
  // $updraftplus_backup->backup_db();
1324
  } elseif (isset($_POST['action']) && $_POST['action'] == 'updraft_wipesettings') {
1325
+ $settings = $this->get_settings_keys();
 
1326
 
1327
  foreach ($settings as $s) UpdraftPlus_Options::delete_updraft_option($s);
1328
 
2397
 
2398
  ?><div class="error updraftplusmethod <?php echo $extraclass; ?>"><p><?php echo $text; ?></p></div>
2399
 
2400
+ <p style="border:1px solid; padding: 6px;"><?php echo $text; ?></p>
2401
 
2402
  <?php
2403
 
2411
 
2412
  function curl_check($service, $has_fallback = false, $extraclass = '') {
2413
  // Check requirements
2414
+ if (!function_exists("curl_init") || !function_exists('curl_exec')) {
2415
 
2416
  $this->show_double_warning('<strong>'.__('Warning','updraftplus').':</strong> '.sprintf(__('Your web server\'s PHP installation does not included a <strong>required</strong> (for %s) module (%s). Please contact your web hosting provider\'s support and ask for them to enable it.', 'updraftplus'), $service, 'Curl').' '.sprintf(__("Your options are 1) Install/enable %s or 2) Change web hosting companies - %s is a standard PHP component, and required by all cloud backup plugins that we know of.",'updraftplus'), 'Curl', 'Curl'), $extraclass);
2417
 
2918
  return strcmp($a, $b);
2919
  }
2920
 
2921
+ function get_settings_keys() {
2922
+ return array('updraft_autobackup_default', 'updraftplus_tmp_googledrive_access_token', 'updraftplus_dismissedautobackup', 'updraft_interval', 'updraft_interval_database', 'updraft_retain', 'updraft_retain_db', 'updraft_encryptionphrase', 'updraft_service', 'updraft_dropbox_appkey', 'updraft_dropbox_secret', 'updraft_googledrive_clientid', 'updraft_googledrive_secret', 'updraft_googledrive_remotepath', 'updraft_ftp_login', 'updraft_ftp_pass', 'updraft_ftp_remote_path', 'updraft_server_address', 'updraft_dir', 'updraft_email', 'updraft_delete_local', 'updraft_debug_mode', 'updraft_include_plugins', 'updraft_include_themes', 'updraft_include_uploads', 'updraft_include_others', 'updraft_include_wpcore', 'updraft_include_wpcore_exclude', 'updraft_include_more',
2923
+ 'updraft_include_blogs', 'updraft_include_mu-plugins', 'updraft_include_others_exclude', 'updraft_lastmessage', 'updraft_googledrive_token', 'updraft_dropboxtk_request_token', 'updraft_dropboxtk_access_token', 'updraft_dropbox_folder', 'updraft_last_backup', 'updraft_starttime_files', 'updraft_starttime_db', 'updraft_startday_db', 'updraft_startday_files', 'updraft_sftp_settings', 'updraft_s3generic_login', 'updraft_s3generic_pass', 'updraft_s3generic_remote_path', 'updraft_s3generic_endpoint', 'updraft_webdav_settings', 'updraft_disable_ping', 'updraft_cloudfiles_user', 'updraft_cloudfiles_apikey', 'updraft_cloudfiles_path', 'updraft_cloudfiles_authurl', 'updraft_ssl_useservercerts', 'updraft_ssl_disableverify', 'updraft_s3_login', 'updraft_s3_pass', 'updraft_s3_remote_path', 'updraft_dreamobjects_login', 'updraft_dreamobjects_pass', 'updraft_dreamobjects_remote_path');
2924
+ }
2925
+
2926
  }
2927
 
2928
  ?>
backup.php CHANGED
@@ -44,13 +44,30 @@ class UpdraftPlus_Backup {
44
  $this->updraft_dir = $updraftplus->backups_dir_location();
45
 
46
  // false means 'tried + failed'; whereas 0 means 'not yet tried'
 
47
  if ($this->binzip === 0 && (!defined('UPDRAFTPLUS_PREFERPCLZIP') || UPDRAFTPLUS_PREFERPCLZIP != true) && (!defined('UPDRAFTPLUS_NO_BINZIP') || !UPDRAFTPLUS_NO_BINZIP) && $updraftplus->current_resumption <9) {
48
- $updraftplus->log('Checking if we have a zip executable available');
49
- $binzip = $updraftplus->find_working_bin_zip();
50
- if (is_string($binzip)) {
51
- $updraftplus->log("Zip engine: found/will use a binary zip: $binzip");
52
- $this->binzip = $binzip;
53
- $this->use_zip_object = 'UpdraftPlus_BinZip';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  }
55
  }
56
 
@@ -283,17 +300,16 @@ class UpdraftPlus_Backup {
283
  }
284
 
285
  $updraftplus->jobdata_set('jobstatus', 'pruning');
286
- $updraftplus->log("Retain: beginning examination of existing backup sets");
287
 
288
  // Number of backups to retain - files
289
- $updraft_retain = UpdraftPlus_Options::get_updraft_option('updraft_retain', 1);
290
  $updraft_retain = (is_numeric($updraft_retain)) ? $updraft_retain : 1;
291
- $updraftplus->log("Retain files: user setting: number to retain = $updraft_retain");
292
 
293
  // Number of backups to retain - db
294
  $updraft_retain_db = UpdraftPlus_Options::get_updraft_option('updraft_retain_db', $updraft_retain);
295
  $updraft_retain_db = (is_numeric($updraft_retain_db)) ? $updraft_retain_db : 1;
296
- $updraftplus->log("Retain db: user setting: number to retain = $updraft_retain_db");
 
297
 
298
  // Returns an array, most recent first, of backup sets
299
  $backup_history = $updraftplus->get_backup_history();
@@ -303,61 +319,80 @@ class UpdraftPlus_Backup {
303
 
304
  $backupable_entities = $updraftplus->get_backupable_file_entities(true);
305
 
 
 
 
 
 
 
 
306
  foreach ($backup_history as $backup_datestamp => $backup_to_examine) {
 
 
 
307
  // $backup_to_examine is an array of file names, keyed on db/plugins/themes/uploads
308
  // The new backup_history array is saved afterwards, so remember to unset the ones that are to be deleted
309
- $updraftplus->log("Examining backup set with datestamp: $backup_datestamp");
310
-
311
- if (isset($backup_to_examine['db'])) {
312
- $db_backups_found++;
313
- $fname = (is_string($backup_to_examine['db'])) ? $backup_to_examine['db'] : $backup_to_examine['db'][0];
314
- $updraftplus->log("$backup_datestamp: this set includes a database (".$fname."); db count is now $db_backups_found");
315
- if ($db_backups_found > $updraft_retain_db) {
316
- $updraftplus->log("$backup_datestamp: over retain limit ($updraft_retain_db); will delete this database");
317
- if (!empty($backup_to_examine['db'])) {
318
- foreach ($services as $service => $sd) $this->prune_file($service, $backup_to_examine['db'], $sd[0], $sd[1]);
 
 
 
 
319
  }
320
- unset($backup_to_examine['db']);
321
  $updraftplus->record_still_alive();
322
  }
323
  }
324
 
325
- $contains_files = false;
326
  foreach ($backupable_entities as $entity => $info) {
327
- if (isset($backup_to_examine[$entity])) {
328
- $contains_files = true;
329
- break;
330
- }
331
- }
332
-
333
- if ($contains_files) {
334
- $file_backups_found++;
335
- $updraftplus->log("$backup_datestamp: this set includes files; fileset count is now $file_backups_found");
336
- if ($file_backups_found > $updraft_retain) {
337
- $updraftplus->log("$backup_datestamp: over retain limit ($updraft_retain); will delete this file set");
338
- foreach ($backupable_entities as $entity => $info) {
339
- if (!empty($backup_to_examine[$entity])) {
340
- foreach ($services as $service => $sd) $this->prune_file($service, $backup_to_examine[$entity], $sd[0], $sd[1]);
341
  }
342
  unset($backup_to_examine[$entity]);
343
- $updraftplus->record_still_alive();
344
  }
345
-
346
  }
347
  }
348
 
349
- // Get new result, post-deletion
350
- $contains_files = false;
 
 
 
 
 
 
351
  foreach ($backupable_entities as $entity => $info) {
352
  if (isset($backup_to_examine[$entity])) {
353
- $contains_files = true;
 
 
 
 
 
 
 
 
354
  break;
355
  }
356
  }
357
 
358
  // Delete backup set completely if empty, o/w just remove DB
359
  // We search on the four keys which represent data, allowing other keys to be used to track other things
360
- if (!$contains_files && !isset($backup_to_examine['db']) ) {
361
  $updraftplus->log("$backup_datestamp: this backup set is now empty; will remove from history");
362
  unset($backup_history[$backup_datestamp]);
363
  if (isset($backup_to_examine['nonce'])) {
@@ -372,9 +407,10 @@ class UpdraftPlus_Backup {
372
  $updraftplus->log("$backup_datestamp: no nonce record found in the backup set, so cannot delete any remaining log file");
373
  }
374
  } else {
375
- $updraftplus->log("$backup_datestamp: this backup set remains non-empty; will retain in history");
376
  $backup_history[$backup_datestamp] = $backup_to_examine;
377
  }
 
378
  }
379
  $updraftplus->log("Retain: saving new backup history (sets now: ".count($backup_history).") and finishing retain operation");
380
  UpdraftPlus_Options::update_updraft_option('updraft_backup_history', $backup_history, false);
@@ -746,7 +782,7 @@ class UpdraftPlus_Backup {
746
  if (!$updraftplus->really_is_writable($this->updraft_dir)) {
747
  $updraftplus->log("The backup directory (".$this->updraft_dir.") is not writable.");
748
  $updraftplus->log($this->updraft_dir.": ".__('The backup directory is not writable - the database backup is expected to shortly fail.','updraftplus'), 'warning');
749
- # Why not just fail now? We saw a bizarre case when the results of really_is_writable() changed during the run.
750
  }
751
 
752
  $stitch_files = array();
@@ -771,7 +807,7 @@ class UpdraftPlus_Backup {
771
  # === is needed, otherwise 'false' matches (i.e. prefix does not match)
772
  if ( strpos($table, $this->table_prefix) === 0 ) {
773
  // Create the SQL statements
774
- $this->stow("# " . sprintf(__('Table: %s','wp-db-backup'),$updraftplus->backquote($table)) . "\n");
775
  $updraftplus->jobdata_set('dbcreating_substatus', array('t' => $table, 'i' => $total_tables, 'a' => $how_many_tables));
776
 
777
  $table_status = $wpdb->get_row("SHOW TABLE STATUS WHERE Name='$table'");
@@ -1139,6 +1175,7 @@ class UpdraftPlus_Backup {
1139
  $this->stow("# WordPress Version: $wp_version, running on PHP ".phpversion()." (".$_SERVER["SERVER_SOFTWARE"]."), MySQL $mysql_version\n");
1140
  $this->stow("# Backup of: ".site_url()."\n");
1141
  $this->stow("# Home URL: ".home_url()."\n");
 
1142
  $this->stow("# Table prefix: ".$this->table_prefix."\n");
1143
  $this->stow("# Site info: multisite=".(is_multisite() ? '1' : '0')."\n");
1144
  $this->stow("# Site info: end\n");
@@ -1514,7 +1551,7 @@ class UpdraftPlus_Backup {
1514
  $updraftplus->log(__('A zip error occurred - check your log for more details.', 'updraftplus'), 'warning', 'zipcloseerror');
1515
  $updraftplus->log("The attempt to close the zip file returned an error (".$zip->last_error."). List of files we were trying to add follows (check their permissions).");
1516
  foreach ($files_zipadded_since_open as $ffile) {
1517
- $updraftplus->log("File: ".$ffile['addas']." (exists: ".(int)@file_exists($ffile['file']).", size: ".@filesize($ffile['file']).')');
1518
  }
1519
  }
1520
  $zipfiles_added_thisbatch = 0;
44
  $this->updraft_dir = $updraftplus->backups_dir_location();
45
 
46
  // false means 'tried + failed'; whereas 0 means 'not yet tried'
47
+ // Disallow binzip on OpenVZ when we're not sure there's plenty of memory
48
  if ($this->binzip === 0 && (!defined('UPDRAFTPLUS_PREFERPCLZIP') || UPDRAFTPLUS_PREFERPCLZIP != true) && (!defined('UPDRAFTPLUS_NO_BINZIP') || !UPDRAFTPLUS_NO_BINZIP) && $updraftplus->current_resumption <9) {
49
+
50
+ if (@file_exists('/proc/user_beancounters') && @file_exists('/proc/meminfo') && @is_readable('/proc/meminfo')) {
51
+ $meminfo = @file_get_contents('/proc/meminfo', false, null, -1, 200);
52
+ if (is_string($meminfo) && preg_match('/MemTotal:\s+(\d+) kB/', $meminfo, $matches)) {
53
+ $memory_mb = $matches[1]/1024;
54
+ # If the report is of a large amount, then we're probably getting the total memory on the hypervisor (this has been observed), and don't really know the VPS's memory
55
+ $vz_log = "OpenVZ; reported memory: ".round($memory_mb, 1)." Mb";
56
+ if ($memory_mb < 1024 || $memory_mb > 8192) {
57
+ $openvz_lowmem = true;
58
+ $vz_log .= " (will not use BinZip)";
59
+ }
60
+ $updraftplus->log($vz_log);
61
+ }
62
+ }
63
+ if (empty($openvz_lowmem)) {
64
+ $updraftplus->log('Checking if we have a zip executable available');
65
+ $binzip = $updraftplus->find_working_bin_zip();
66
+ if (is_string($binzip)) {
67
+ $updraftplus->log("Zip engine: found/will use a binary zip: $binzip");
68
+ $this->binzip = $binzip;
69
+ $this->use_zip_object = 'UpdraftPlus_BinZip';
70
+ }
71
  }
72
  }
73
 
300
  }
301
 
302
  $updraftplus->jobdata_set('jobstatus', 'pruning');
 
303
 
304
  // Number of backups to retain - files
305
+ $updraft_retain = UpdraftPlus_Options::get_updraft_option('updraft_retain', 2);
306
  $updraft_retain = (is_numeric($updraft_retain)) ? $updraft_retain : 1;
 
307
 
308
  // Number of backups to retain - db
309
  $updraft_retain_db = UpdraftPlus_Options::get_updraft_option('updraft_retain_db', $updraft_retain);
310
  $updraft_retain_db = (is_numeric($updraft_retain_db)) ? $updraft_retain_db : 1;
311
+
312
+ $updraftplus->log("Retain: beginning examination of existing backup sets; user setting: retain_files=$updraft_retain, retain_db=$updraft_retain_db");
313
 
314
  // Returns an array, most recent first, of backup sets
315
  $backup_history = $updraftplus->get_backup_history();
319
 
320
  $backupable_entities = $updraftplus->get_backupable_file_entities(true);
321
 
322
+ $database_backups_found = array();
323
+
324
+ $file_entities_backups_found = array();
325
+ foreach ($backupable_entities as $entity => $info) {
326
+ $file_entities_backups_found[$entity] = 0;
327
+ }
328
+
329
  foreach ($backup_history as $backup_datestamp => $backup_to_examine) {
330
+
331
+ $files_to_prune = array();
332
+
333
  // $backup_to_examine is an array of file names, keyed on db/plugins/themes/uploads
334
  // The new backup_history array is saved afterwards, so remember to unset the ones that are to be deleted
335
+ $updraftplus->log(sprintf("Examining backup set with datestamp: %s (%s)", $backup_datestamp, gmdate('M d Y H:i:s', $backup_datestamp)));
336
+
337
+ # Databases
338
+ foreach ($backup_to_examine as $key => $data) {
339
+ if ('db' != strtolower(substr($key, 0, 2)) || '-size' == substr($key, -5, 5)) continue;
340
+
341
+ $database_backups_found[$key] = (empty($database_backups_found[$key])) ? 1 : $database_backups_found[$key] + 1;
342
+
343
+ $fname = (is_string($data)) ? $data : $data[0];
344
+ $updraftplus->log("$backup_datestamp: $key: this set includes a database (".$fname."); db count is now ".$database_backups_found[$key]);
345
+ if ($database_backups_found[$key] > $updraft_retain_db) {
346
+ $updraftplus->log("$backup_datestamp: $key: over retain limit ($updraft_retain_db); will delete this database");
347
+ if (!empty($data)) {
348
+ foreach ($services as $service => $sd) $this->prune_file($service, $data, $sd[0], $sd[1]);
349
  }
350
+ unset($backup_to_examine[$key]);
351
  $updraftplus->record_still_alive();
352
  }
353
  }
354
 
 
355
  foreach ($backupable_entities as $entity => $info) {
356
+ if (!empty($backup_to_examine[$entity])) {
357
+ $file_entities_backups_found[$entity]++;
358
+ if ($file_entities_backups_found[$entity] > $updraft_retain) {
359
+ $prune_this = $backup_to_examine[$entity];
360
+ if (is_string($prune_this)) $prune_this = array($prune_this);
361
+ foreach ($prune_this as $prune_file) {
362
+ $updraftplus->log("$entity: $backup_datestamp: over retain limit ($updraft_retain); will delete this file ($prune_file)");
363
+ $files_to_prune[] = $prune_file;
 
 
 
 
 
 
364
  }
365
  unset($backup_to_examine[$entity]);
 
366
  }
 
367
  }
368
  }
369
 
370
+ # Actually delete the files
371
+ foreach ($services as $service => $sd) {
372
+ $this->prune_file($service, $files_to_prune, $sd[0], $sd[1]);
373
+ $updraftplus->record_still_alive();
374
+ }
375
+
376
+ // Get new result, post-deletion; anything left in this set?
377
+ $contains_files = 0;
378
  foreach ($backupable_entities as $entity => $info) {
379
  if (isset($backup_to_examine[$entity])) {
380
+ $contains_files = 1;
381
+ break;
382
+ }
383
+ }
384
+
385
+ $contains_db = 0;
386
+ foreach ($backup_to_examine as $key => $data) {
387
+ if ('db' == strtolower(substr($key, 0, 2)) && '-size' != substr($key, -5, 5)) {
388
+ $contains_db = 1;
389
  break;
390
  }
391
  }
392
 
393
  // Delete backup set completely if empty, o/w just remove DB
394
  // We search on the four keys which represent data, allowing other keys to be used to track other things
395
+ if (!$contains_files && !$contains_db) {
396
  $updraftplus->log("$backup_datestamp: this backup set is now empty; will remove from history");
397
  unset($backup_history[$backup_datestamp]);
398
  if (isset($backup_to_examine['nonce'])) {
407
  $updraftplus->log("$backup_datestamp: no nonce record found in the backup set, so cannot delete any remaining log file");
408
  }
409
  } else {
410
+ $updraftplus->log("$backup_datestamp: this backup set remains non-empty ($contains_files/$contains_db); will retain in history");
411
  $backup_history[$backup_datestamp] = $backup_to_examine;
412
  }
413
+ # Loop over backup sets
414
  }
415
  $updraftplus->log("Retain: saving new backup history (sets now: ".count($backup_history).") and finishing retain operation");
416
  UpdraftPlus_Options::update_updraft_option('updraft_backup_history', $backup_history, false);
782
  if (!$updraftplus->really_is_writable($this->updraft_dir)) {
783
  $updraftplus->log("The backup directory (".$this->updraft_dir.") is not writable.");
784
  $updraftplus->log($this->updraft_dir.": ".__('The backup directory is not writable - the database backup is expected to shortly fail.','updraftplus'), 'warning');
785
+ # Why not just fail now? We saw a case when the results of really_is_writable() changed during the run. Probably caused by disk space issues.
786
  }
787
 
788
  $stitch_files = array();
807
  # === is needed, otherwise 'false' matches (i.e. prefix does not match)
808
  if ( strpos($table, $this->table_prefix) === 0 ) {
809
  // Create the SQL statements
810
+ $this->stow("# ".sprintf('Table: %s', $updraftplus->backquote($table))."\n");
811
  $updraftplus->jobdata_set('dbcreating_substatus', array('t' => $table, 'i' => $total_tables, 'a' => $how_many_tables));
812
 
813
  $table_status = $wpdb->get_row("SHOW TABLE STATUS WHERE Name='$table'");
1175
  $this->stow("# WordPress Version: $wp_version, running on PHP ".phpversion()." (".$_SERVER["SERVER_SOFTWARE"]."), MySQL $mysql_version\n");
1176
  $this->stow("# Backup of: ".site_url()."\n");
1177
  $this->stow("# Home URL: ".home_url()."\n");
1178
+ $this->stow("# Content URL: ".content_url()."\n");
1179
  $this->stow("# Table prefix: ".$this->table_prefix."\n");
1180
  $this->stow("# Site info: multisite=".(is_multisite() ? '1' : '0')."\n");
1181
  $this->stow("# Site info: end\n");
1551
  $updraftplus->log(__('A zip error occurred - check your log for more details.', 'updraftplus'), 'warning', 'zipcloseerror');
1552
  $updraftplus->log("The attempt to close the zip file returned an error (".$zip->last_error."). List of files we were trying to add follows (check their permissions).");
1553
  foreach ($files_zipadded_since_open as $ffile) {
1554
+ $updraftplus->log("File: ".$ffile['addas']." (exists: ".(int)@file_exists($ffile['file']).", is_readable: ".(int)@is_readable($ffile['file'])." size: ".@filesize($ffile['file']).')');
1555
  }
1556
  }
1557
  $zipfiles_added_thisbatch = 0;
class-zip.php CHANGED
@@ -95,43 +95,61 @@ class UpdraftPlus_BinZip extends UpdraftPlus_PclZip {
95
  $added_dirs_yet=true;
96
  }
97
 
98
- if (is_array($files)) {
99
- foreach ($files as $file) {
 
 
 
 
 
 
 
 
 
 
 
 
100
  // Send the list of files on stdin
101
  fwrite($pipes[0], $file."\n");
 
102
  }
103
- }
104
- fclose($pipes[0]);
105
-
106
- while (!feof($pipes[1])) {
107
- $w = fgets($pipes[1], 1024);
108
- // Logging all this really slows things down; use debug to mitigate
109
- if ($w && $updraftplus_backup->debug) $updraftplus->log("Output from zip: ".trim($w), 'debug');
110
- if (time() > $last_recorded_alive + 5) {
111
- $updraftplus->record_still_alive();
112
- $last_recorded_alive = time();
113
- }
114
- if (file_exists($this->path)) {
115
- $new_size = @filesize($this->path);
116
- if (!$something_useful_happened && $new_size > $orig_size + 20) {
117
- $updraftplus->something_useful_happened();
118
- $something_useful_happened = true;
119
  }
120
- clearstatcache();
121
- # Log when 20% bigger or at least every 50Mb
122
- if ($new_size > $last_size*1.2 || $new_size > $last_size + 52428800) {
123
- $updraftplus->log(basename($this->path).sprintf(": size is now: %.2f Mb", round($new_size/1048576,1)));
124
- $last_size = $new_size;
 
 
 
 
 
 
 
125
  }
126
  }
127
- }
128
 
129
- fclose($pipes[1]);
 
 
 
 
 
 
 
 
130
 
131
- while (!feof($pipes[2])) {
132
- $last_error = fgets($pipes[2]);
133
- if (!empty($last_error)) $this->last_error = rtrim($last_error);
134
  }
 
 
135
  fclose($pipes[2]);
136
 
137
  $ret = proc_close($process);
@@ -192,15 +210,12 @@ class UpdraftPlus_PclZip {
192
  }
193
 
194
  public function statIndex($i) {
195
-
196
  if (empty($this->statindex[$i])) return array('name' => null, 'size' => 0);
197
-
198
  return array('name' => $this->statindex[$i]['filename'], 'size' => $this->statindex[$i]['size']);
199
-
200
  }
201
 
202
  public function open($path, $flags = 0) {
203
- if(!class_exists('PclZip')) require_once(ABSPATH.'/wp-admin/includes/class-pclzip.php');
204
  if(!class_exists('PclZip')) {
205
  $this->last_error = "No PclZip class was found";
206
  return false;
95
  $added_dirs_yet=true;
96
  }
97
 
98
+ $read = array($pipes[1], $pipes[2]);
99
+ $except = null;
100
+
101
+ if (!is_array($files) || 0 == count($files)) {
102
+ fclose($pipes[0]);
103
+ $write = array();
104
+ } else {
105
+ $write = array($pipes[0]);
106
+ }
107
+
108
+ while ((!feof($pipes[1]) || !feof($pipes[2]) || (is_array($files) && count($files)>0)) && false !== ($changes = stream_select($read, $write, $except, 0, 100))) {
109
+
110
+ if (in_array($pipes[0], $write) && is_array($files) && count($files)>0) {
111
+ $file = array_pop($files);
112
  // Send the list of files on stdin
113
  fwrite($pipes[0], $file."\n");
114
+ if (0 == count($files)) fclose($pipes[0]);
115
  }
116
+
117
+ if (in_array($pipes[1], $read)) {
118
+ $w = fgets($pipes[1]);
119
+ // Logging all this really slows things down; use debug to mitigate
120
+ if ($w && $updraftplus_backup->debug) $updraftplus->log("Output from zip: ".trim($w), 'debug');
121
+ if (time() > $last_recorded_alive + 5) {
122
+ $updraftplus->record_still_alive();
123
+ $last_recorded_alive = time();
 
 
 
 
 
 
 
 
124
  }
125
+ if (file_exists($this->path)) {
126
+ $new_size = @filesize($this->path);
127
+ if (!$something_useful_happened && $new_size > $orig_size + 20) {
128
+ $updraftplus->something_useful_happened();
129
+ $something_useful_happened = true;
130
+ }
131
+ clearstatcache();
132
+ # Log when 20% bigger or at least every 50Mb
133
+ if ($new_size > $last_size*1.2 || $new_size > $last_size + 52428800) {
134
+ $updraftplus->log(basename($this->path).sprintf(": size is now: %.2f Mb", round($new_size/1048576,1)));
135
+ $last_size = $new_size;
136
+ }
137
  }
138
  }
 
139
 
140
+ if (in_array($pipes[2], $read)) {
141
+ $last_error = fgets($pipes[2]);
142
+ if (!empty($last_error)) $this->last_error = rtrim($last_error);
143
+ }
144
+
145
+ // Re-set
146
+ $read = array($pipes[1], $pipes[2]);
147
+ $write = (is_array($files) && count($files) >0) ? array($pipes[0]) : array();
148
+ $except = null;
149
 
 
 
 
150
  }
151
+
152
+ fclose($pipes[1]);
153
  fclose($pipes[2]);
154
 
155
  $ret = proc_close($process);
210
  }
211
 
212
  public function statIndex($i) {
 
213
  if (empty($this->statindex[$i])) return array('name' => null, 'size' => 0);
 
214
  return array('name' => $this->statindex[$i]['filename'], 'size' => $this->statindex[$i]['size']);
 
215
  }
216
 
217
  public function open($path, $flags = 0) {
218
+ if(!class_exists('PclZip')) include_once(ABSPATH.'/wp-admin/includes/class-pclzip.php');
219
  if(!class_exists('PclZip')) {
220
  $this->last_error = "No PclZip class was found";
221
  return false;
methods/googledrive.php CHANGED
@@ -19,7 +19,7 @@ class UpdraftPlus_BackupModule_googledrive {
19
  }
20
 
21
  // Get a Google account access token using the refresh token
22
- function access_token( $token, $client_id, $client_secret ) {
23
 
24
  global $updraftplus;
25
  $updraftplus->log("Google Drive: requesting access token: client_id=$client_id");
19
  }
20
 
21
  // Get a Google account access token using the refresh token
22
+ function access_token($token, $client_id, $client_secret) {
23
 
24
  global $updraftplus;
25
  $updraftplus->log("Google Drive: requesting access token: client_id=$client_id");
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === UpdraftPlus - WordPress Backup and Restoration ===
2
  Contributors: Backup with UpdraftPlus, DavidAnderson
3
- Tags: backup, backups, restore, database, rackspace, amazon, s3, amazon s3, s3 compatible, dropbox, google drive, rackspace cloud files, rackspace, cloud files, dreamhost, dreamobjects, ftp, webdav, google cloud storage, cloudian, cloudn, connectria, constant cloud, eucalyptus, nifty, nimbula, back up, multisite, restoration, sftp, ftps, scp, migrate, duplicate, copy, updraft, schedule, mysql backup, database backup, db backup, website backup, wordpress backup, full backup
4
  Requires at least: 3.2
5
  Tested up to: 3.7
6
- Stable tag: 1.7.34
7
  Author URI: http://updraftplus.com
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
@@ -16,7 +16,7 @@ Easy and complete backups + restoration. Manual or automated backups (backup to
16
 
17
  <strong>Top-quality:</strong> UpdraftPlus is the <a href="http://rankwp.com/plugins/updraftplus">highest-ranking backup plugin on rankwp.com</a> (ranks 16th out of 28,000 WordPress plugins for quality on rankwp.com - last checked 28th September 2013).
18
 
19
- <strong>Tens of thousands of users:</strong> widely tested and reliable (over 325,000 downloads). Ranks in the top 100 most used of all WordPress plugins on rankwp.com. Millions of backups completed!
20
 
21
  * Supports WordPress backups to Amazon S3 (or compatible), Dropbox, Rackspace Cloud Files, Google Drive, Google Cloud Storage, DreamHost DreamObjects, FTP and email. Also (via an add-on) FTP over SSL, SFTP, SCP and WebDAV. (Note: Microsoft forbid SkyDrive to be used by backup software). Some examples of S3-compatible providers: Cloudian, Connectria, Constant, Eucalyptus, Nifty, Nimbula, Cloudn.
22
  * Quick restore (both file and database backups)
@@ -131,6 +131,14 @@ Thanks for asking - yes, I have. Check out my profile page - http://profiles.wor
131
 
132
  The <a href="http://updraftplus.com/news/">UpdraftPlus backup blog</a> is the best place to learn in more detail about any important changes.
133
 
 
 
 
 
 
 
 
 
134
  = 1.7.34 - 2013/10/21 =
135
 
136
  * FEATURE: Options in the "Backup Now" dialog to exclude files or database from the backup (http://updraftplus.com/more-flexibility-in-backup-now/)
@@ -631,4 +639,4 @@ Furthermore, reliance upon any non-English translation is at your own risk. Updr
631
 
632
 
633
  == Upgrade Notice ==
634
- * 1.7.3: Fix 3 bugs - recommended upgrade for all
1
  === UpdraftPlus - WordPress Backup and Restoration ===
2
  Contributors: Backup with UpdraftPlus, DavidAnderson
3
+ Tags: backup, backups, restore, database, rackspace, amazon, s3, amazon s3, s3 compatible, dropbox, google drive, rackspace cloud files, rackspace, cloud files, dreamhost, dreamobjects, ftp, ftp backup, webdav, google cloud storage, cloudian, cloudn, connectria, constant cloud, eucalyptus, nifty, nimbula, back up, multisite, restoration, sftp, ftps, scp, migrate, duplicate, copy, updraft, schedule, mysql backup, database backup, db backup, website backup, wordpress backup, full backup
4
  Requires at least: 3.2
5
  Tested up to: 3.7
6
+ Stable tag: 1.7.35
7
  Author URI: http://updraftplus.com
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
16
 
17
  <strong>Top-quality:</strong> UpdraftPlus is the <a href="http://rankwp.com/plugins/updraftplus">highest-ranking backup plugin on rankwp.com</a> (ranks 16th out of 28,000 WordPress plugins for quality on rankwp.com - last checked 28th September 2013).
18
 
19
+ <strong>Tens of thousands of users:</strong> widely tested and reliable (over 340,000 downloads). Ranks in the top 100 most used of all WordPress plugins on rankwp.com. Millions of backups completed!
20
 
21
  * Supports WordPress backups to Amazon S3 (or compatible), Dropbox, Rackspace Cloud Files, Google Drive, Google Cloud Storage, DreamHost DreamObjects, FTP and email. Also (via an add-on) FTP over SSL, SFTP, SCP and WebDAV. (Note: Microsoft forbid SkyDrive to be used by backup software). Some examples of S3-compatible providers: Cloudian, Connectria, Constant, Eucalyptus, Nifty, Nimbula, Cloudn.
22
  * Quick restore (both file and database backups)
131
 
132
  The <a href="http://updraftplus.com/news/">UpdraftPlus backup blog</a> is the best place to learn in more detail about any important changes.
133
 
134
+ = 1.7.35 - 2013/10/26 =
135
+
136
+ * FIX: Fix potential problem whereby some tables could be missed from the backup on WPMU (WP multisite) installs. Strongly recommended that all WPMU users update and take a fresh backup.
137
+ * FIX: Work around http://bugs.mysql.com/62077 (could cause permanently stuck lock on databases with wrong collocations - if you have this problem, then no backups happen)
138
+ * TWEAK: Don't use binzip method on OpenVZ with low memory
139
+ * TWEAK: Suppress a couple of spurious messages in the log
140
+ * TWEAK: Add facility to quickly download log files in the 'expert settings' section
141
+
142
  = 1.7.34 - 2013/10/21 =
143
 
144
  * FEATURE: Options in the "Backup Now" dialog to exclude files or database from the backup (http://updraftplus.com/more-flexibility-in-backup-now/)
639
 
640
 
641
  == Upgrade Notice ==
642
+ * 1.7.35: Fix bug that could cause tables to be missed from backup on WPMU (multisite) installs
updraftplus.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: UpdraftPlus - Backup/Restore
4
  Plugin URI: http://updraftplus.com
5
  Description: Backup and restore: take backups locally, or backup to Amazon S3, Dropbox, Google Drive, Rackspace, (S)FTP, WebDAV & email, on automatic schedules.
6
  Author: UpdraftPlus.Com, DavidAnderson
7
- Version: 1.7.34
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
10
  Text Domain: updraftplus
@@ -15,13 +15,17 @@ Author URI: http://updraftplus.com
15
  TODO - some of these are out of date/done, needs pruning
16
  // After Oct 15 2013: Remove page(s) from websites discussing W3TC
17
  // Change migrate window: 1) Retain link to article 2) Have selector to choose which backup set to migrate - or a fresh one 3) Have option for FTP/SFTP/SCP despatch 4) Have big "Go" button. Have some indication of what happens next. Test the login first. Have the remote site auto-scan its directory + pick up new sets. Have a way of querying the remote site for its UD-dir. Have a way of saving the settings as a 'profile'. Or just save the last set of settings (since mostly will be just one place to send to). Implement an HTTP/JSON method for sending files too.
18
- // Log Cpanel quota
 
 
19
  // Detect low-memory VPSes, and don't use BinZip
20
  // Change default setting of retain 1 backup set? (Auto-backup could replace it in that case... don't perform pruning when doing auto-backup?)
 
21
  // Change add-ons screen, to be less confusing for people who haven't yet updated but have connected
22
  // Put a 'what do I get if I upgrade?' link into the mix
23
  // Add to admin bar (and make it something that can be turned off)
24
  // New reporting add-on: Multiple email addresses, send backup to 1st only, option to send email only on failure, include checksums (SHA1) in report (store these in job data immediately post-creation; then aggregate them into the backup history on job finish), option to include log file always, option to log to syslog
 
25
  // Strategy for what to do if the updraft_dir contains untracked backups. Automatically rescan?
26
  // MySQL manual: See Section 8.2.2.1, Speed of INSERT Statements.
27
  // Exempt UD itself from a plugins restore? (will options be out-of-sync? exempt options too?)
@@ -33,6 +37,7 @@ TODO - some of these are out of date/done, needs pruning
33
  // The delete-em at the end needs to be made resumable. And to only run on last run-through (i.e. no errors, or no resumption)
34
  // Incremental - can leverage some of the multi-zip work???
35
  // Put in a help link to explain what WordPress core (including any additions to your WordPress root directory) does (was asked for support)
 
36
  // Multiple files in more-files
37
  // On multisite, the settings should be in the network panel. Connection settings need migrating into site options.
38
  // On restore, raise a warning for ginormous zips
@@ -40,6 +45,7 @@ TODO - some of these are out of date/done, needs pruning
40
  // Log migrations/restores, and have an option for auto-emailing the log
41
  # Email backup method should be able to force split limit down to something manageable - or at least, should make the option display. (Put it in email class. Tweak the storage dropdown to not hide stuff also in expert class if expert is shown).
42
  // What happens if you restore with a database that then changes the setting for updraft_dir ? Should be safe, as the setting is cached during a run: double-check.
 
43
  // Import/slurp backups from other sites. See: http://www.skyverge.com/blog/extending-the-wordpress-xml-rpc-api/
44
  // More sophisticated options for retaining/deleting (e.g. 4/day for X days, then 7/week for Z weeks, then 1/month for Y months)
45
  // Unpack zips via AJAX? Do bit-by-bit to allow enormous opens a better chance? (have a huge one in Dropbox)
@@ -53,7 +59,6 @@ TODO - some of these are out of date/done, needs pruning
53
  // Give a help page to go with the message: A zip error occurred - check your log for more details (reduce support requests)
54
  // Exclude .git and .svn by default from wpcore
55
  // Add option to add, not just replace entities on restore/migrate
56
- // Warnings of unreadable files upon PclZip fall-back may need to be more visible - test
57
  // Add warning to backup run at beginning if -old dirs exist
58
  // Auto-alert if disk usage passes user-defined threshold / or an automatically computed one. Auto-alert if more backups are known than should be (usually a sign of incompleteness). Actually should just delete unknown backups over a certain age.
59
  // Generic S3 provider: add page to site. S3-compatible storage providers: http://www.dragondisk.com/s3-storage-providers.html
@@ -66,8 +71,6 @@ TODO - some of these are out of date/done, needs pruning
66
  // Get link - http://www.rackspace.com/knowledge_center/article/how-to-use-updraftplus-to-back-up-cloud-sites-to-cloud-files
67
  // 'Delete from your webserver' should trigger a rescan if the backup was local-only
68
  // Notify user only if backup fails
69
- // Log file SHA1 after finishing creation
70
- // Add more info to email - e.g. names + sizes + checksums of uploads + locations
71
  // Encrypt archives - http://www.frostjedi.com/phpbb3/viewtopic.php?f=46&t=168508&p=391881&e=391881
72
  // Option for additive restores - i.e. add content (themes, plugins,...) instead of replacing
73
  // Testing framework - automated testing of all file upload / download / deletion methods
@@ -96,10 +99,8 @@ TODO - some of these are out of date/done, needs pruning
96
  // More DB add-on (other non-WP tables; even other databases)
97
  // Unlimited customers should be auto-emailed each time they add a site (security)
98
  // Update all-features page at updraftplus.com (not updated after 1.5.5)
99
- // Add in downloading in the 'Restore' modal, and remove the advice to do so manually.
100
  // Save database encryption key inside backup history on per-db basis, so that if it changes we can still decrypt
101
  // Switch to Google Drive SDK. Google folders. https://developers.google.com/drive/folder
102
- // Convert S3.php to use WP's native HTTP functions
103
  // AJAX-ify restoration
104
  // Ability to re-scan existing cloud storage
105
  // Dropbox uses one mcrypt function - port to phpseclib for more portability
@@ -161,7 +162,7 @@ if (!defined('UPDRAFTPLUS_WARN_FILE_SIZE')) define('UPDRAFTPLUS_WARN_FILE_SIZE',
161
  if (!defined('UPDRAFTPLUS_WARN_DB_ROWS')) define('UPDRAFTPLUS_WARN_DB_ROWS', 150000);
162
 
163
  # The smallest value (in megabytes) that the "split zip files at" setting is allowed to be set to
164
- if (!defined('UPDRAFTPLUS_SPLIT_MIN')) define('UPDRAFTPLUS_SPLIT_MIN', 75);
165
 
166
  // Load add-ons and various files that may or may not be present, depending on where the plugin was distributed
167
  if (is_file(UPDRAFTPLUS_DIR.'/premium.php')) require_once(UPDRAFTPLUS_DIR.'/premium.php');
@@ -392,7 +393,7 @@ class UpdraftPlus {
392
  public function get_table_prefix() {
393
  global $wpdb;
394
  #if (!empty($wpdb->base_prefix)) return $wpdb->base_prefix;
395
- return $wpdb->get_blog_prefix();
396
  }
397
 
398
  public function show_admin_warning_unreadablelog() {
@@ -687,7 +688,7 @@ class UpdraftPlus {
687
  return (false == $ciphertext) ? $rijndael->decrypt(file_get_contents($fullpath)) : $rijndael->decrypt($ciphertext);
688
  }
689
 
690
- function encrypt($fullpath, $key) {
691
  if (!function_exists('mcrypt_encrypt')) {
692
  $this->log(sprintf(__('Your web-server does not have the %s module installed.', 'updraftplus'), 'mcrypt').' '.__('Without it, encryption will be a lot slower.', 'updraftplus'), 'warning', 'nomcrypt');
693
  }
@@ -697,7 +698,9 @@ class UpdraftPlus {
697
  $this->ensure_phpseclib('Crypt_Rijndael', 'Crypt/Rijndael');
698
  $rijndael = new Crypt_Rijndael();
699
  $rijndael->setKey($key);
700
- return $rijndael->encrypt(file_get_contents($fullpath));
 
 
701
  }
702
 
703
  function detect_safe_mode() {
@@ -997,6 +1000,8 @@ class UpdraftPlus {
997
 
998
  // Restore state
999
  $resumption_extralog = '';
 
 
1000
  if ($resumption_no > 0) {
1001
  $this->nonce = $bnonce;
1002
  $this->backup_time = $this->jobdata_get('backup_time');
@@ -1027,7 +1032,6 @@ class UpdraftPlus {
1027
  }
1028
  }
1029
 
1030
- $prev_resumption = $resumption_no - 1;
1031
  if (isset($time_passed[$prev_resumption])) {
1032
  $resumption_extralog = ", previous check-in=".round($time_passed[$prev_resumption], 1)."s";
1033
  } else {
@@ -1061,9 +1065,11 @@ class UpdraftPlus {
1061
 
1062
  if ($resumption_no > 0 && isset($runs_started[$prev_resumption])) {
1063
  $our_expected_start = $runs_started[$prev_resumption] + $resume_interval;
 
 
1064
  # More than 12 minutes late?
1065
  if ($time_now > $our_expected_start + 720) {
1066
- $this->log('Long time past since expected resumption time: approx expected= '.round($our_expected_start,1).", now=".round($time_now, 1).", diff=".round($time_now-$our_expected_start,1));
1067
  $this->log(__('Your website is visited infrequently and UpdraftPlus is not getting the resources it hoped for; please read this page:', 'updraftplus').' http://updraftplus.com/faqs/why-am-i-getting-warnings-about-my-site-not-having-enough-visitors/', 'warning', 'infrequentvisits');
1068
  }
1069
  }
4
  Plugin URI: http://updraftplus.com
5
  Description: Backup and restore: take backups locally, or backup to Amazon S3, Dropbox, Google Drive, Rackspace, (S)FTP, WebDAV & email, on automatic schedules.
6
  Author: UpdraftPlus.Com, DavidAnderson
7
+ Version: 1.7.35
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
10
  Text Domain: updraftplus
15
  TODO - some of these are out of date/done, needs pruning
16
  // After Oct 15 2013: Remove page(s) from websites discussing W3TC
17
  // Change migrate window: 1) Retain link to article 2) Have selector to choose which backup set to migrate - or a fresh one 3) Have option for FTP/SFTP/SCP despatch 4) Have big "Go" button. Have some indication of what happens next. Test the login first. Have the remote site auto-scan its directory + pick up new sets. Have a way of querying the remote site for its UD-dir. Have a way of saving the settings as a 'profile'. Or just save the last set of settings (since mostly will be just one place to send to). Implement an HTTP/JSON method for sending files too.
18
+ // Place in maintenance mode during restore - ?
19
+ // Add more info to email - e.g. names + sizes + checksums of uploads + locations. Make the report beautiful!
20
+ // Warn/prevent if trying to migrate between sub-domain/sub-folder based multisites
21
  // Detect low-memory VPSes, and don't use BinZip
22
  // Change default setting of retain 1 backup set? (Auto-backup could replace it in that case... don't perform pruning when doing auto-backup?)
23
+ // Update updates checker so that it checks for updates on a sliding-scale: those who've not updated in last X only end up checking every Y
24
  // Change add-ons screen, to be less confusing for people who haven't yet updated but have connected
25
  // Put a 'what do I get if I upgrade?' link into the mix
26
  // Add to admin bar (and make it something that can be turned off)
27
  // New reporting add-on: Multiple email addresses, send backup to 1st only, option to send email only on failure, include checksums (SHA1) in report (store these in job data immediately post-creation; then aggregate them into the backup history on job finish), option to include log file always, option to log to syslog
28
+ // If migrated database from somewhere else, then add note about revising UD settings
29
  // Strategy for what to do if the updraft_dir contains untracked backups. Automatically rescan?
30
  // MySQL manual: See Section 8.2.2.1, Speed of INSERT Statements.
31
  // Exempt UD itself from a plugins restore? (will options be out-of-sync? exempt options too?)
37
  // The delete-em at the end needs to be made resumable. And to only run on last run-through (i.e. no errors, or no resumption)
38
  // Incremental - can leverage some of the multi-zip work???
39
  // Put in a help link to explain what WordPress core (including any additions to your WordPress root directory) does (was asked for support)
40
+ // More databases
41
  // Multiple files in more-files
42
  // On multisite, the settings should be in the network panel. Connection settings need migrating into site options.
43
  // On restore, raise a warning for ginormous zips
45
  // Log migrations/restores, and have an option for auto-emailing the log
46
  # Email backup method should be able to force split limit down to something manageable - or at least, should make the option display. (Put it in email class. Tweak the storage dropdown to not hide stuff also in expert class if expert is shown).
47
  // What happens if you restore with a database that then changes the setting for updraft_dir ? Should be safe, as the setting is cached during a run: double-check.
48
+ // Multi-site manager at updraftplus.com
49
  // Import/slurp backups from other sites. See: http://www.skyverge.com/blog/extending-the-wordpress-xml-rpc-api/
50
  // More sophisticated options for retaining/deleting (e.g. 4/day for X days, then 7/week for Z weeks, then 1/month for Y months)
51
  // Unpack zips via AJAX? Do bit-by-bit to allow enormous opens a better chance? (have a huge one in Dropbox)
59
  // Give a help page to go with the message: A zip error occurred - check your log for more details (reduce support requests)
60
  // Exclude .git and .svn by default from wpcore
61
  // Add option to add, not just replace entities on restore/migrate
 
62
  // Add warning to backup run at beginning if -old dirs exist
63
  // Auto-alert if disk usage passes user-defined threshold / or an automatically computed one. Auto-alert if more backups are known than should be (usually a sign of incompleteness). Actually should just delete unknown backups over a certain age.
64
  // Generic S3 provider: add page to site. S3-compatible storage providers: http://www.dragondisk.com/s3-storage-providers.html
71
  // Get link - http://www.rackspace.com/knowledge_center/article/how-to-use-updraftplus-to-back-up-cloud-sites-to-cloud-files
72
  // 'Delete from your webserver' should trigger a rescan if the backup was local-only
73
  // Notify user only if backup fails
 
 
74
  // Encrypt archives - http://www.frostjedi.com/phpbb3/viewtopic.php?f=46&t=168508&p=391881&e=391881
75
  // Option for additive restores - i.e. add content (themes, plugins,...) instead of replacing
76
  // Testing framework - automated testing of all file upload / download / deletion methods
99
  // More DB add-on (other non-WP tables; even other databases)
100
  // Unlimited customers should be auto-emailed each time they add a site (security)
101
  // Update all-features page at updraftplus.com (not updated after 1.5.5)
 
102
  // Save database encryption key inside backup history on per-db basis, so that if it changes we can still decrypt
103
  // Switch to Google Drive SDK. Google folders. https://developers.google.com/drive/folder
 
104
  // AJAX-ify restoration
105
  // Ability to re-scan existing cloud storage
106
  // Dropbox uses one mcrypt function - port to phpseclib for more portability
162
  if (!defined('UPDRAFTPLUS_WARN_DB_ROWS')) define('UPDRAFTPLUS_WARN_DB_ROWS', 150000);
163
 
164
  # The smallest value (in megabytes) that the "split zip files at" setting is allowed to be set to
165
+ if (!defined('UPDRAFTPLUS_SPLIT_MIN')) define('UPDRAFTPLUS_SPLIT_MIN', 50);
166
 
167
  // Load add-ons and various files that may or may not be present, depending on where the plugin was distributed
168
  if (is_file(UPDRAFTPLUS_DIR.'/premium.php')) require_once(UPDRAFTPLUS_DIR.'/premium.php');
393
  public function get_table_prefix() {
394
  global $wpdb;
395
  #if (!empty($wpdb->base_prefix)) return $wpdb->base_prefix;
396
+ return $wpdb->get_blog_prefix(0);
397
  }
398
 
399
  public function show_admin_warning_unreadablelog() {
688
  return (false == $ciphertext) ? $rijndael->decrypt(file_get_contents($fullpath)) : $rijndael->decrypt($ciphertext);
689
  }
690
 
691
+ function encrypt($fullpath, $key, $rformat = 'inline') {
692
  if (!function_exists('mcrypt_encrypt')) {
693
  $this->log(sprintf(__('Your web-server does not have the %s module installed.', 'updraftplus'), 'mcrypt').' '.__('Without it, encryption will be a lot slower.', 'updraftplus'), 'warning', 'nomcrypt');
694
  }
698
  $this->ensure_phpseclib('Crypt_Rijndael', 'Crypt/Rijndael');
699
  $rijndael = new Crypt_Rijndael();
700
  $rijndael->setKey($key);
701
+ if ('inline' === $rformat) {
702
+ return $rijndael->encrypt(file_get_contents($fullpath));
703
+ }
704
  }
705
 
706
  function detect_safe_mode() {
1000
 
1001
  // Restore state
1002
  $resumption_extralog = '';
1003
+ $prev_resumption = $resumption_no - 1;
1004
+
1005
  if ($resumption_no > 0) {
1006
  $this->nonce = $bnonce;
1007
  $this->backup_time = $this->jobdata_get('backup_time');
1032
  }
1033
  }
1034
 
 
1035
  if (isset($time_passed[$prev_resumption])) {
1036
  $resumption_extralog = ", previous check-in=".round($time_passed[$prev_resumption], 1)."s";
1037
  } else {
1065
 
1066
  if ($resumption_no > 0 && isset($runs_started[$prev_resumption])) {
1067
  $our_expected_start = $runs_started[$prev_resumption] + $resume_interval;
1068
+ # If the previous run increased the resumption time, then it is timed from the end of the previous run, not the start
1069
+ if (isset($time_passed[$prev_resumption]) && $time_passed[$prev_resumption]>0) $our_expected_start += $time_passed[$prev_resumption];
1070
  # More than 12 minutes late?
1071
  if ($time_now > $our_expected_start + 720) {
1072
+ $this->log('Long time past since expected resumption time: approx expected='.round($our_expected_start,1).", now=".round($time_now, 1).", diff=".round($time_now-$our_expected_start,1));
1073
  $this->log(__('Your website is visited infrequently and UpdraftPlus is not getting the resources it hoped for; please read this page:', 'updraftplus').' http://updraftplus.com/faqs/why-am-i-getting-warnings-about-my-site-not-having-enough-visitors/', 'warning', 'infrequentvisits');
1074
  }
1075
  }