1

i am trying to migrate drupal 7 private files to drupal 9

Step 1 :- i have modified below file /opt/httpd/htdocs/staging/sitename/master/web/core/modules/file/src/Plugin/migrate/source/d7/File.php

    $this->publicPath = $this->variableGet('file_public_path', 'sites/default/files');
    // $this->privatePath = $this->variableGet('file_private_path', NULL);
    $this->privatePath = NULL;
    return parent::initializeIterator();
  }```

Step 2 :-  Run command to update yml config
drush config-import --partial --source=/opt/httpd/htdocs/staging/sitename/master/web/sites/default/files/config_KgT6nWwBULNZvIEj43iZ08aLKOTZhGsExPRh0h8lsNJuieTtTgb_8AWfqg55xf21xDCxRAbWLQ/sync

Step 3 :- Run command to migrate private files
drush migrate-import upgrade_d7_file_private

but after running upgrade_d7_file_private all of the file field to migrate not even single file is migrated 

 13808/13808 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
 [notice] Processed 13808 items (0 created, 0 updated, 13808 failed, 0 ignored) in 18.2 seconds (45521.1/min) - done with 'upgrade_d7_file_private'

and when i do drush mmsg upgrade_d7_file_private it shows lots of files does not exist but why? not even a single file have been migrated.

  1       7994714                            upgrade_d7_file_private:uri:file_copy: File                                                                                
                                             '/opt/httpd/htdocs/staging/sitename/private_files/sitename.co.in/source_code_files/3432_Intercepting_Information.c' does not exist 

migrate_plus.migration.upgrade_d7_file_private.yml   file config is below

```uuid: 54d44e60-a20b-44d1-92ff-96f0b0ddb974
langcode: en
status: true
dependencies: {  }
id: upgrade_d7_file_private
class: Drupal\migrate\Plugin\Migration
field_plugin_method: null
cck_plugin_method: null
migration_tags:
  - 'Drupal 7'
  - Content
migration_group: migrate_drupal_7
label: 'Private files'
source:
  plugin: d7_file
  scheme: private
  constants:
    source_base_path: '/opt/httpd/htdocs/staging/sitename/private_files/sitename.co.in'
process:
  fid:
    -
      plugin: get
      source: fid
  filename:
    -
      plugin: get
      source: filename
  source_full_path:
    -
      plugin: concat
      delimiter: /
      source:
        - constants/source_base_path
        - filepath
  uri:
    -
      plugin: file_copy
      source:
        - '@source_full_path'
        - uri
  filemime:
    -
      plugin: get
      source: filemime
  status:
    -
      plugin: get
      source: status
  created:
    -
      plugin: get
      source: timestamp
  changed:
    -
      plugin: get
      source: timestamp
  uid:
    -
      plugin: get
      source: uid
destination:
  source_base_path: '/opt/httpd/htdocs/staging/sitename/private_files/sitename.co.in'
  plugin: 'entity:file'
migration_dependencies:
  required: {  }
  optional: {  }```
1
  • You should never modify core plugins to solve such problems. You should be able to migrate files by modifying the migration configuration alone. As a tip, I always recommend moving the files to the desired directory first, using rsync or other tools, then configuring the migration so it only creates the database entries, as the alternative is very slow. Oct 19, 2023 at 13:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.