UpdraftPlus WordPress Backup Plugin - Version 1.2.24

Version Description

  • 01/14/2013 =
  • Fixed bug with DropBox deletions
Download this release

Release Info

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

Code changes from version 1.2.20 to 1.2.24

Files changed (4) hide show
  1. methods/dropbox.php +35 -7
  2. methods/email.php +6 -1
  3. readme.txt +4 -1
  4. updraftplus.php +57 -81
methods/dropbox.php CHANGED
@@ -71,7 +71,8 @@ class UpdraftPlus_BackupModule_dropbox {
71
 
72
  try {
73
  //$put = $dropbox->putFile($updraft_dir.'/'.$file, $dropbox_folder.$file);
74
- $dropbox->chunkedUpload($updraft_dir.'/'.$file, $file, $dropbox_folder, true, $offset, $upload_id, array($this, 'chunked_callback'));
 
75
  } catch (Exception $e) {
76
  $updraftplus->log('DropBox error: '.print_r($e, true));
77
  $updraftplus->error("DropBox error: failed to upload file $file (see full log for more)");
@@ -120,10 +121,24 @@ class UpdraftPlus_BackupModule_dropbox {
120
  $dropbox->delete($file);
121
  } catch (Exception $e) {
122
  $updraftplus->log('DropBox error: '.print_r($e, true));
123
- $updraftplus->error("DropBox error: failed to delete file ($file): see log file for more info");
 
 
124
  $file_success = 0;
125
  }
126
- if ($file_success) $updraftplus->log('DropBox: delete succeeded');
 
 
 
 
 
 
 
 
 
 
 
 
127
 
128
  }
129
 
@@ -145,13 +160,26 @@ class UpdraftPlus_BackupModule_dropbox {
145
 
146
  $updraft_dir = $updraftplus->backups_dir_location();
147
  $microtime = microtime(true);
148
- $file_success = 1;
149
 
 
150
  try {
151
- $put = $dropbox->getFile($file, $updraft_dir.'/'.$file);
152
  } catch (Exception $e) {
153
- $updraftplus->error('DropBox error: '.print_r($e, true));
154
- $file_success = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  }
156
 
157
  }
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)");
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
  }
129
+ if ($file_success) {
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)');
141
+ }
142
 
143
  }
144
 
160
 
161
  $updraft_dir = $updraftplus->backups_dir_location();
162
  $microtime = microtime(true);
 
163
 
164
+ $try_the_other_one = false;
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);
177
+ try {
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
 
185
  }
methods/email.php CHANGED
@@ -18,7 +18,12 @@ class UpdraftPlus_BackupModule_email {
18
  }
19
 
20
  function config_print() {
21
- return false;
 
 
 
 
 
22
  }
23
 
24
  }
18
  }
19
 
20
  function config_print() {
21
+ ?>
22
+ <tr class="updraftplusmethod email">
23
+ <th>Note:</th>
24
+ <td>If choosing &quot;E-Mail&quot;, then be aware that mail servers tend to have size limits; typically around 10-20Mb; backups larger than any limits will not arrive.</td>
25
+ </tr>
26
+ <?php
27
  }
28
 
29
  }
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.20
7
  Donate link: http://david.dw-perspective.org.uk/donate
8
  License: GPLv3 or later
9
 
@@ -112,6 +112,9 @@ Thanks for asking - yes, I have. Check out my profile page - http://profiles.wor
112
 
113
  == Changelog ==
114
 
 
 
 
115
  = 1.2.20 - 01/12/2013 =
116
  * DropBox no longer limited to 150Mb uploads
117
  * DropBox can upload in chunks and resume uploading chunks
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
 
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
120
  * DropBox can upload in chunks and resume uploading chunks
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.20
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
10
  Author URI: http://wordshell.net
@@ -18,6 +18,9 @@ TODO
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
 
22
  Encrypt filesystem, if memory allows (and have option for abort if not); split up into multiple zips when needed
23
  // Does not delete old custom directories upon a restore?
@@ -59,7 +62,7 @@ define('UPDRAFT_DEFAULT_OTHERS_EXCLUDE','upgrade,cache,updraft,index.php');
59
 
60
  class UpdraftPlus {
61
 
62
- var $version = '1.2.20';
63
 
64
  // Choices will be shown in the admin menu in the order used here
65
  var $backup_methods = array (
@@ -482,7 +485,7 @@ class UpdraftPlus {
482
  function uploaded_file($file, $id = false) {
483
  # We take an MD5 hash because set_transient wants a name of 45 characters or less
484
  $hash = md5($file);
485
- $this->log("$file: $hash: recording as successfully uploaded");
486
  set_transient("updraft_".$hash, "yes", 3600*4);
487
  if ($id) {
488
  $ids = get_option('updraft_file_ids', array() );
@@ -609,18 +612,44 @@ class UpdraftPlus {
609
  }
610
  return true;
611
  }
612
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
613
  function backup_dirs() {
 
614
  if(!$this->backup_time) $this->backup_time_nonce();
615
- $wp_themes_dir = WP_CONTENT_DIR.'/themes';
616
- $wp_upload_dir = wp_upload_dir();
617
- $wp_upload_dir = $wp_upload_dir['basedir'];
618
- $wp_plugins_dir = WP_PLUGIN_DIR;
619
 
620
  if(!class_exists('PclZip')) require_once(ABSPATH.'/wp-admin/includes/class-pclzip.php');
621
 
622
  $updraft_dir = $this->backups_dir_location();
623
- if(!is_writable($updraft_dir)) $this->error('Backup directory is not writable, or does not exist.','fatal');
 
 
 
 
624
 
625
  //get the blog name and rip out all non-alphanumeric chars other than _
626
  $blog_name = str_replace(' ','_',get_bloginfo());
@@ -631,70 +660,27 @@ class UpdraftPlus {
631
 
632
  $backup_array = array();
633
 
634
- # Plugins
635
- @set_time_limit(900);
636
- if (get_option('updraft_include_plugins', true)) {
637
- $this->log("Beginning backup of plugins");
638
- $full_path = $backup_file_base.'-plugins.zip';
639
- $plugins = new PclZip($full_path);
640
- # The paths in the zip should then begin with 'plugins', having removed WP_CONTENT_DIR from the front
641
- if (!$plugins->create($wp_plugins_dir,PCLZIP_OPT_REMOVE_PATH,WP_CONTENT_DIR)) {
642
- $this->error('Could not create plugins zip. Error was '.$php_errmsg,'fatal');
643
- $this->log('ERROR: PclZip failure: Could not create plugins zip');
644
- } else {
645
- $this->log("Created plugins zip - file size is ".filesize($full_path)." bytes");
646
- }
647
- $backup_array['plugins'] = basename($full_path);
648
- } else {
649
- $this->log("No backup of plugins: excluded by user's options");
650
- }
651
-
652
- $this->check_backup_race($backup_array);
653
 
654
- # Themes
655
- @set_time_limit(900);
656
- if (get_option('updraft_include_themes', true)) {
657
- $this->log("Beginning backup of themes");
658
- $full_path = $backup_file_base.'-themes.zip';
659
- $themes = new PclZip($full_path);
660
- if (!$themes->create($wp_themes_dir,PCLZIP_OPT_REMOVE_PATH,WP_CONTENT_DIR)) {
661
- $this->error('Could not create themes zip. Error was '.$php_errmsg,'fatal');
662
- $this->log('ERROR: PclZip failure: Could not create themes zip');
663
- } else {
664
- $this->log("Created themes zip - file size is ".filesize($full_path)." bytes");
665
- }
666
- $backup_array['themes'] = basename($full_path);
667
- } else {
668
- $this->log("No backup of themes: excluded by user's options");
669
- }
670
 
671
- $this->check_backup_race($backup_array);
672
-
673
- # Uploads
674
- @set_time_limit(900);
675
- if (get_option('updraft_include_uploads', true)) {
676
- $this->log("Beginning backup of uploads");
677
- $full_path = $backup_file_base.'-uploads.zip';
678
- $uploads = new PclZip($full_path);
679
- if (!$uploads->create($wp_upload_dir,PCLZIP_OPT_REMOVE_PATH,WP_CONTENT_DIR)) {
680
- $this->error('Could not create uploads zip. Error was '.$php_errmsg,'fatal');
681
- $this->log('ERROR: PclZip failure: Could not create uploads zip');
682
  } else {
683
- $this->log("Created uploads zip - file size is ".filesize($full_path)." bytes");
684
  }
685
- $backup_array['uploads'] = basename($full_path);
686
- } else {
687
- $this->log("No backup of uploads: excluded by user's options");
688
  }
689
 
690
- $this->check_backup_race($backup_array);
691
-
692
  # Others
693
- @set_time_limit(900);
694
  if (get_option('updraft_include_others', true)) {
695
  $this->log("Beginning backup of other directories found in the content directory");
696
- $full_path=$backup_file_base.'-others.zip';
697
- $others = new PclZip($full_path);
698
  // http://www.phpconcept.net/pclzip/user-guide/53
699
  /* First parameter to create is:
700
  An array of filenames or dirnames,
@@ -703,17 +689,11 @@ class UpdraftPlus {
703
  or
704
  A string containing a list of filename or dirname separated by a comma.
705
  */
706
- // First, see what we can find. We always want to exclude these:
707
- $wp_themes_dir = WP_CONTENT_DIR.'/themes';
708
- $wp_upload_dir = wp_upload_dir();
709
- $wp_upload_dir = $wp_upload_dir['basedir'];
710
- $wp_plugins_dir = WP_PLUGIN_DIR;
711
- $updraft_dir = untrailingslashit(get_option('updraft_dir'));
712
 
713
  # Initialise
714
  $other_dirlist = array();
715
-
716
- $others_skip = preg_split("/,/",get_option('updraft_include_others_exclude',UPDRAFT_DEFAULT_OTHERS_EXCLUDE));
717
  # Make the values into the keys
718
  $others_skip = array_flip($others_skip);
719
 
@@ -727,20 +707,16 @@ class UpdraftPlus {
727
  elseif ($candidate == $wp_upload_dir) { $this->log("$entry: skipping: this is the uploads directory"); }
728
  elseif ($candidate == $wp_plugins_dir) { $this->log("$entry: skipping: this is the plugins directory"); }
729
  elseif (isset($others_skip[$entry])) { $this->log("$entry: skipping: excluded by options"); }
730
- else { $this->log("$entry: adding to list"); array_push($other_dirlist,$candidate); }
731
  }
732
  } else {
733
  $this->log('ERROR: Could not read the content directory: '.WP_CONTENT_DIR);
 
734
  }
735
 
736
  if (count($other_dirlist)>0) {
737
- if (!$others->create($other_dirlist,PCLZIP_OPT_REMOVE_PATH,WP_CONTENT_DIR)) {
738
- $this->error('Could not create other zip. Error was '.$php_errmsg,'fatal');
739
- $this->log('ERROR: PclZip failure: Could not create other zip');
740
- } else {
741
- $this->log("Created other directories zip - file size is ".filesize($full_path)." bytes");
742
- }
743
- $backup_array['others'] = basename($full_path);
744
  } else {
745
  $this->log("No backup of other directories: there was nothing found to back up");
746
  }
@@ -1844,7 +1820,7 @@ echo $delete_local; ?> /> <br>Check this to delete the local backup file (only s
1844
  </select></td>
1845
  </tr>
1846
  <tr class="backup-service-description">
1847
- <td></td><td>Choose your backup method. If choosing &quot;E-Mail&quot;, then be aware that mail servers tend to have size limits; typically around 10-20Mb; backups larger than any limits will not arrive.</td>
1848
 
1849
  </tr>
1850
  <?php
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
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
 
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 (
485
  function uploaded_file($file, $id = false) {
486
  # We take an MD5 hash because set_transient wants a name of 45 characters or less
487
  $hash = md5($file);
488
+ $this->log("Recording as successfully uploaded: $file ($hash)");
489
  set_transient("updraft_".$hash, "yes", 3600*4);
490
  if ($id) {
491
  $ids = get_option('updraft_file_ids', array() );
612
  }
613
  return true;
614
  }
615
+
616
+ function create_zip($whichone, $backup_file_base, $create_from_dir) {
617
+ // Note: $create_from_dir can be an array or a string
618
+ @set_time_limit(900);
619
+
620
+ if ($whichone != "others") $this->log("Beginning backup of $whichone");
621
+
622
+ $full_path = $backup_file_base.'-'.$whichone.'.zip';
623
+ $zip_object = new PclZip($full_path);
624
+
625
+ $microtime_start = microtime(true);
626
+ # The paths in the zip should then begin with '$whichone', having removed WP_CONTENT_DIR from the front
627
+ if (!$zip_object->create($create_from_dir, PCLZIP_OPT_REMOVE_PATH, WP_CONTENT_DIR)) {
628
+ $this->error("Could not create $whichone zip. Consult the log file for more information.");
629
+ $this->log("ERROR: PclZip failure: Could not create $whichone zip");
630
+ return false;
631
+ } else {
632
+ $timetaken = max(microtime(true)-$microtime_start, 0.000001);
633
+ $kbsize = filesize($full_path)/1024;
634
+ $rate = round($kbsize/$timetaken, 1);
635
+ $this->log("Created $whichone zip - file size is ".round($kbsize,1)." Kb in ".round($timetaken,1)." s ($rate Kb/s)");
636
+ }
637
+ $this->check_backup_race($backup_array);
638
+ return basename($full_path);
639
+ }
640
+
641
  function backup_dirs() {
642
+
643
  if(!$this->backup_time) $this->backup_time_nonce();
 
 
 
 
644
 
645
  if(!class_exists('PclZip')) require_once(ABSPATH.'/wp-admin/includes/class-pclzip.php');
646
 
647
  $updraft_dir = $this->backups_dir_location();
648
+ if(!is_writable($updraft_dir)) {
649
+ $this->error('Backup directory is not writable, or does not exist.','fatal');
650
+ $this->log('Backup directory is not writable, or does not exist');
651
+ return array();
652
+ }
653
 
654
  //get the blog name and rip out all non-alphanumeric chars other than _
655
  $blog_name = str_replace(' ','_',get_bloginfo());
660
 
661
  $backup_array = array();
662
 
663
+ $wp_themes_dir = WP_CONTENT_DIR.'/themes';
664
+ $wp_upload_dir = wp_upload_dir();
665
+ $wp_upload_dir = $wp_upload_dir['basedir'];
666
+ $wp_plugins_dir = WP_PLUGIN_DIR;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
667
 
668
+ $possible_backups = array ('plugins' => $wp_plugins_dir, 'themes' => $wp_themes_dir, 'uploads' => $wp_upload_dir);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
669
 
670
+ # Plugins, themes, uploads
671
+ foreach ($possible_backups as $youwhat => $whichdir) {
672
+ if (get_option("updraft_include_$youwhat", true)) {
673
+ $created = $this->create_zip($youwhat, $backup_file_base, $whichdir);
674
+ if ($created) $backup_array[$youwhat] = $created;
 
 
 
 
 
 
675
  } else {
676
+ $this->log("No backup of $youwhat: excluded by user's options");
677
  }
 
 
 
678
  }
679
 
 
 
680
  # Others
 
681
  if (get_option('updraft_include_others', true)) {
682
  $this->log("Beginning backup of other directories found in the content directory");
683
+
 
684
  // http://www.phpconcept.net/pclzip/user-guide/53
685
  /* First parameter to create is:
686
  An array of filenames or dirnames,
689
  or
690
  A string containing a list of filename or dirname separated by a comma.
691
  */
 
 
 
 
 
 
692
 
693
  # Initialise
694
  $other_dirlist = array();
695
+
696
+ $others_skip = preg_split("/,/",get_option('updraft_include_others_exclude', UPDRAFT_DEFAULT_OTHERS_EXCLUDE));
697
  # Make the values into the keys
698
  $others_skip = array_flip($others_skip);
699
 
707
  elseif ($candidate == $wp_upload_dir) { $this->log("$entry: skipping: this is the uploads directory"); }
708
  elseif ($candidate == $wp_plugins_dir) { $this->log("$entry: skipping: this is the plugins directory"); }
709
  elseif (isset($others_skip[$entry])) { $this->log("$entry: skipping: excluded by options"); }
710
+ else { $this->log("$entry: adding to list"); array_push($other_dirlist, $candidate); }
711
  }
712
  } else {
713
  $this->log('ERROR: Could not read the content directory: '.WP_CONTENT_DIR);
714
+ $this->error('Could not read the content directory: '.WP_CONTENT_DIR);
715
  }
716
 
717
  if (count($other_dirlist)>0) {
718
+ $created = $this->create_zip('others', $backup_file_base, $other_dirlist);
719
+ if ($created) $backup_array['others'] = $created;
 
 
 
 
 
720
  } else {
721
  $this->log("No backup of other directories: there was nothing found to back up");
722
  }
1820
  </select></td>
1821
  </tr>
1822
  <tr class="backup-service-description">
1823
+ <td></td><td>Choose your backup method.</td>
1824
 
1825
  </tr>
1826
  <?php