current_file_hash, $uploadid, 3600*3); set_transient('updraf_dbof_'.$this->current_file_hash, $offset, 3600*3); if ($this->current_file_size > 0) { $percent = round(100*($offset/$this->current_file_size),1); $updraftplus->log("Dropbox: Chunked Upload: ${percent}% ($uploadid, $offset)"); } else { $updraftplus->log("Dropbox: Chunked Upload: $offset bytes uploaded"); } } function backup($backup_array) { global $updraftplus; $updraftplus->log("Dropbox: begin cloud upload"); if (UpdraftPlus_Options::get_updraft_option('updraft_dropboxtk_request_token', 'xyz') == 'xyz') { $updraftplus->log('You do not appear to be authenticated with Dropbox'); $updraftplus->error('You do not appear to be authenticated with Dropbox'); return false; } try { $dropbox = $this->bootstrap(); $dropbox->setChunkSize(524288); // 512Kb } catch (Exception $e) { $updraftplus->log('Dropbox error: '.$e->getMessage().' (line: '.$e->getLine().', file: '.$e->getFile().')'); $updraftplus->error('Dropbox error: '.$e->getMessage().' (see log file for more)'); return false; } $updraft_dir = $updraftplus->backups_dir_location(); $dropbox_folder = trailingslashit(UpdraftPlus_Options::get_updraft_option('updraft_dropbox_folder')); foreach($backup_array as $file) { $updraftplus->log("Dropbox: Attempt to upload: $file"); $file_success = 1; $hash = md5($file); $this->current_file_hash=$hash; $filesize = filesize($updraft_dir.'/'.$file); $this->current_file_size = $filesize; // Into Kb $filesize = $filesize/1024; $microtime = microtime(true); if ($upload_id = get_transient('updraf_dbid_'.$hash)) { # Resume $offset = get_transient('updraf_dbof_'.$hash); $updraftplus->log("This is a resumption: $offset bytes had already been uploaded"); } else { $offset = 0; $upload_id = null; } // I did erroneously have $dropbox_folder as the third parameter in chunkedUpload... this causes a sub-directory to be created // Old-style, single file put: $put = $dropbox->putFile($updraft_dir.'/'.$file, $dropbox_folder.$file); $ourself = $this; try { $dropbox->chunkedUpload($updraft_dir.'/'.$file, $file, '', true, $offset, $upload_id, array($ourself, 'chunked_callback')); } catch (Exception $e) { $updraftplus->log("Exception: ".$e->getMessage()); if (preg_match("/Submitted input out of alignment: got \[(\d+)\] expected \[(\d+)\]/i", $e->getMessage(), $matches)) { // Try the indicated offset $we_tried = $matches[1]; $dropbox_wanted = $matches[2]; $updraftplus->log("Dropbox alignment error: tried=$we_tried, wanted=$dropbox_wanted; will attempt recovery"); try { $dropbox->chunkedUpload($updraft_dir.'/'.$file, $file, '', true, $dropbox_wanted, $upload_id, array($ourself, 'chunked_callback')); } catch (Exception $e) { $updraftplus->log('Dropbox error: '.$e->getMessage().' (line: '.$e->getLine().', file: '.$e->getFile().')'); $updraftplus->error("Dropbox error: failed to upload file $file (see full log for more)"); $file_success = 0; } } else { $updraftplus->log('Dropbox error: '.$e->getMessage()); $updraftplus->error("Dropbox error: failed to upload file $file (see full log for more)"); $file_success = 0; } } if ($file_success) { $updraftplus->uploaded_file($file); $microtime_elapsed = microtime(true)-$microtime; $speedps = $filesize/$microtime_elapsed; $speed = sprintf("%.2d",$filesize)." Kb in ".sprintf("%.2d",$microtime_elapsed)."s (".sprintf("%.2d", $speedps)." Kb/s)"; $updraftplus->log("Dropbox: File upload success (".$file."): $speed"); delete_transient('updraft_duido_'.$hash); delete_transient('updraft_duidi_'.$hash); } } $updraftplus->prune_retained_backups('dropbox', $this, null); } function defaults() { return array('Z3Q3ZmkwbnplNHA0Zzlx', 'bTY0bm9iNmY4eWhjODRt'); } function delete($file) { global $updraftplus; $updraftplus->log("Dropbox: request deletion: $file"); if (UpdraftPlus_Options::get_updraft_option('updraft_dropboxtk_request_token', 'xyz') == 'xyz') { $updraftplus->log('You do not appear to be authenticated with Dropbox'); //$updraftplus->error('You do not appear to be authenticated with Dropbox'); return false; } try { $dropbox = $this->bootstrap(); } catch (Exception $e) { $updraftplus->log('Dropbox error: '.$e->getMessage().' (line: '.$e->getLine().', file: '.$e->getFile().')'); //$updraftplus->error('Dropbox error: failed to access Dropbox (see log file for more)'); return false; } $dropbox_folder = trailingslashit(UpdraftPlus_Options::get_updraft_option('updraft_dropbox_folder')); $file_success = 1; try { // Apparently $dropbox_folder is not needed $dropbox->delete($file); } catch (Exception $e) { $updraftplus->log('Dropbox error: '.$e->getMessage().' (line: '.$e->getLine().', file: '.$e->getFile().')'); // TODO // Add this back October 2013 when removing the block below //$updraftplus->error("Dropbox error: failed to delete file ($file): see log file for more info"); $file_success = 0; } if ($file_success) { $updraftplus->log('Dropbox: delete succeeded'); } else { $file_success = 1; // We created the file in the wrong place for a while. This code is needed until October 2013, when it can be removed. try { $dropbox->delete($dropbox_folder.'/'.$file); } catch (Exception $e) { $updraftplus->log('Dropbox error: '.$e->getMessage().' (line: '.$e->getLine().', file: '.$e->getFile().')'); $file_success = 0; } if ($file_success) $updraftplus->log('Dropbox: delete succeeded (alternative path)'); } } function download($file) { global $updraftplus; if (UpdraftPlus_Options::get_updraft_option('updraft_dropboxtk_request_token', 'xyz') == 'xyz') { $updraftplus->error('You do not appear to be authenticated with Dropbox'); return false; } try { $dropbox = $this->bootstrap(); } catch (Exception $e) { $updraftplus->log('Dropbox error: '.$e->getMessage().' (line: '.$e->getLine().', file: '.$e->getFile().')'); return false; } $updraft_dir = $updraftplus->backups_dir_location(); $microtime = microtime(true); $try_the_other_one = false; try { $get = $dropbox->getFile($file, $updraft_dir.'/'.$file); } catch (Exception $e) { // TODO: Remove this October 2013 (we stored in the wrong place for a while...) $try_the_other_one = true; $possible_error = $e->getMessage(); } // TODO: Remove this October 2013 (we stored in the wrong place for a while...) if ($try_the_other_one) { $dropbox_folder = trailingslashit(UpdraftPlus_Options::get_updraft_option('updraft_dropbox_folder')); $updraftplus->error('Dropbox error: '.$e); try { $get = $dropbox->getFile($file, $updraft_dir.'/'.$file); } catch (Exception $e) { $updraftplus->error($possible_error); $updraftplus->error($e->getMessage()); } } } function config_print() { ?>
Dropbox 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.
(You appear to be already authenticated)."; ?> After you have saved your settings (by clicking "Save Changes" below), then come back here once and click this link to complete authentication with Dropbox.
Warning: Your web server's PHP installation does not included a required module (MCrypt). Please contact your web hosting provider's support. UpdraftPlus's Dropbox module requires MCrypt. Please do not file any support requests; there is no alternative.
Warning: Your web server's PHP installation does not included a required module (Curl). Please contact your web hosting provider's support. UpdraftPlus's Dropbox module requires Curl. Your only options to get this working are 1) Install/enable curl or 2) Hire us or someone else to code additional support options into UpdraftPlus. 3) Wait, possibly forever, for someone else to do this.
Warning: Your web server's PHP/Curl installation does not support https access. We cannot access Dropbox without this support. Please contact your web hosting provider's support. UpdraftPlus's Dropbox module requires Curl+https. Your only options to get this working are 1) Install/enable curl with https or 2) Hire us or someone else to code additional support options into UpdraftPlus. 3) Wait, possibly forever, for someone else to do this.