Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drush archive restore “Unable to determine mime type” #1292

Closed
stupid-genius opened this issue Mar 27, 2015 · 2 comments
Closed

Drush archive restore “Unable to determine mime type” #1292

stupid-genius opened this issue Mar 27, 2015 · 2 comments

Comments

@stupid-genius
Copy link

I created a backup with drush archive-dump --description, but when I try to restore with drush arr ./drush-backups/archive-dump/.tar.gz --db-url=mysql:// --destination=/home/ I get an error "Unable to determine mime type for ". After the error, the command continues and appears to correctly restore the doc dir, but the db remains empty.

Also asked here.

@minorOffense
Copy link
Contributor

The issue is that when drupal.sql is checked through drush_mime_content_type() this code

if (class_exists('finfo')) {
    $finfo = new finfo(FILEINFO_MIME_TYPE);
    $content_type = $finfo->file($filename);
    if ($content_type == 'application/octet-stream') {
      drush_log(dt('Mime type for !file is application/octet-stream.', array('!file' => $filename)), 'debug');
      $content_type = FALSE;
    }
  }

Will set $content_type to false because application/octet-stream is the mime type that is returned for a .sql file from the finfo class. But this function assumes that application/octet-stream means "I have no idea what mime type that is supposed to be" from the finfo class.

Further down, there are other attempts to determine the mime type, but those all fail for .sql since that special case isn't present.

Since technically speaking, a .sql file has no mime-type meaning that octet-stream is the right one, what we need is to add an entry in the array (similarly to what .tar files have) for the .sql file.

This

    $extension_mimetype = array(
      '.tar'     => 'application/x-tar',
    );

Should be

    $extension_mimetype = array(
      '.tar'     => 'application/x-tar',
      '.sql'     => 'application/octet-stream',
    );

I'll post a pull request in a few minutes.

minorOffense added a commit to coldfrontlabs/drush that referenced this issue Jul 28, 2015
weitzman added a commit that referenced this issue Jul 28, 2015
weitzman pushed a commit that referenced this issue Jul 28, 2015
@kenrbnsn
Copy link

I realize this problem was "fixed" almost 3 years ago, but I just got the same problem using Drush v8.1.9:

$ drush -vvv arr ...
Executing: tar  -C /tmp/drush_tmp_1487030989_58a24acd75091 -xzf  ...
Executing: mysql --defaults-extra-file=/tmp/drush_ftLtPK ...
Executing: mysql --defaults-extra-file=/tmp/drush_OmEozF ...
Unable to determine mime type from header bytes 0x2d2d of  (extracted file)

I restored the DB manually and moved site worked fine.

I didn't expect this to be a problem, since it was reported as "fixed".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants