This module doesn't work with Backup and Migrate version 3.

Any advance on this?

Comments

ytwater’s picture

StatusFileSize
new2.09 KB

I played with the code abit and I've gotten this module to work with Backup and Migrate 3 with a few small changes.

I'm attaching a patchfile, or you can update the two files below.

Hope it works for you!

Manual Update:
backup_migrate_dropbox.module

/**
 * Implements hook_backup_migrate_destination_types().
 */
function backup_migrate_dropbox_backup_migrate_destination_subtypes() {
  return array(
    'dropbox' => array(
      'type_name' => t('Dropbox'),
      'description' => t('Save the backup files to a !link account.', array('!link' => l(t('Dropbox'), 'http://www.dropbox.com/'))),
      'file' => drupal_get_path('module', 'backup_migrate_dropbox') . '/destinations.dropbox.inc',
      'class' => 'backup_migrate_destination_dropbox',
      'can_create' => TRUE,
      'remote' => TRUE,
    ),
  );
}

destinations.dropbox.inc

class backup_migrate_destination_dropbox extends backup_migrate_destination_remote {
  var $supported_ops = array('scheduled backup', 'manual backup', 'remote backup');
  var $dropbox = NULL;

 /**
   * Save to to the Dropbox destination.
   */
  function save_file($file, $settings) {
    $dropbox = $this->dropbox_object();
    $filename = $file->file_info['filename'] . '.' . implode('.', $file->ext);
    $dest_filename = realpath(variable_get('file_temporary_path', '')) . '/' . $filename;
    rename($file->filepath(), $dest_filename);

    try {
      $handle = fopen($dest_filename, "r");
      $put = $dropbox->putStream($handle, $filename);
      fclose($handle);
    } catch (Exception $e) {
      watchdog(
        'backup_migrate',
        'There was a problem when we tried to save the file to Dropbox, the error message was: !error',
        array('!error' => $e->getMessage()),
        WATCHDOG_ERROR);
      return FALSE;
    }
    return $file;
  }
strategicweb’s picture

The patch worked for me when I manually backed up to Dropbox, except scheduled backups aren't working for me.

When cron runs I get the following message in the logs
Warning: Cannot modify header information - headers already sent by (output started at includes/common.inc:2726) in Dropbox\OAuth\Consumer\ConsumerAbstract->authorise() (line 84 of /sites/all/libraries/dropbox/Dropbox/OAuth/Consumer/ConsumerAbstract.php).

When I manually run cron I get the Dropbox screen to authorize the app and then it still won't backup. Any ideas?

*** Update: resaved the Dropbox destination and it seems to be working now

drupalgideon’s picture

Patch looks good.

However, originally I got an Error - The website has encountered an unexpected error. Checking the logs revealed I needed to enable MCrypt on my PHP. Once that was done, it has worked with a manual backup. Hopefully the scheduled backup will work later!

Maybe this could be added as a requirement of the module?

WRT the patch, you might want to change the hook "Implements" text to - Implements hook_backup_migrate_destination_types() to reflect the function name change :)

drupalgideon’s picture

Patch for the implements text

botris’s picture

Status: Active » Reviewed & tested by the community

Confirming #4 to work.

wundo’s picture

Status: Reviewed & tested by the community » Fixed
wundo’s picture

botris’s picture

Just had a look the new function is only part of B&M 3 and not 2.
So I'm afraid that by committing #4 we broke compatibility for B&M 2.
If there is a need to support B&M 2 we should create a separate branche for that.

  • wundo committed e044567 on 7.x-1.x
    Issue #2369649 by SkidNCrashwell, ytwater: Support for Backup and...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.