0

I'm migrating a site from drupal 7 to 8. It has many many media files. Something like 6TB worth. And adding daily. So i want to do the db migration on my machine (not the webserver), work out kinks and modify custom code to work w/ d8, then do the real thing on the live machine over a slow weekend when i have all the steps worked out.

In the migration process, i've gotten to drush migrate-upgrade d7_node, and it (on initial run, with only a token few files in /sites/default/files) created a handful of db entries in file_managed. So i sshfs mounted the live files directory read only from my machine and re-ran migrate-upgrade d7_node from the restored db. Now it doesn't create anything in the file_managed table, so i suspect it's not working, but it gives no errors, and some grepping doesn't readily yield the code that does this work. I wouldn't mind hacking for this part only.

Hence the question. And what can i do alternatively to avoid copying 6TB of files for the preparatory migration?

Thanks.

0

Ok, i figured this one out. The magic lines are in /core/modules/migrate/src/Plugin/migrate/process/FileCopy.php

First, make sure source_base_path is correct in your config: Check drush mmsg d7_file after migrate-upgrade d7_node --limit=1 to see whether it is correctly finding the files. Use drush config:export and config:import to modify it til that works. Alter settings.php to put config/sync somewhere other than /sites/default/files

Second, mount the live site's public files dir read-only at /sites/default/files.

Third, modify /core/modules/migrate/src/Plugin/migrate/process/FileCopy.php around line 149 to comment out the action. Make it look like this:

    if (!is_dir($dir) || !is_writable($dir)) {
      if (!$this->fileSystem->prepareDirectory($dir, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS)) {
        throw new MigrateException("Could not create or write to directory '$dir'");
      }
    }

    $final_destination = $this->writeFile($source, $destination, $this->configuration['file_exists']);
    if ($final_destination) {
      return $final_destination;
    }
*/
      return $destination;```


Last, run drush migrate-upgrade d7_file

Enjoy.
1
  • I dont think it is a correct way. I might solve your problem but it can also cause unknown side effects. What you need to do is create a custom migrate plugin extending FileCopy migrate plugin and make your changes in that file and use that custom plugin instead of core plugin. – miststudent2011 Mar 2 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.