Last updated August 2, 2013. Created by mikeryan on April 1, 2013.
Edited by eojthebrave, ShaunDychko, wusel. Log in to edit this page.

As explained at Why you should run migrations in Drush rather than the UI, drush is a faster and more robust means of running large migration operations than the web-based UI is. As of Migrate 2.6, it is possible (with some advanced server-side configuration) to start migration operations from the UI that will run in the background via drush on the server.

Configuring background operations

To enable background imports and rollbacks requires some configuration on the server side. The key element is letting the Migrate module know where the drush command resides on the server, so it can be run. This is done by setting the Drupal migrate_drush_path variable to the full path of the drush command on the server, either in settings.php:

<?php
$conf
['migrate_drush_path'] = '/usr/bin/drush';
?>

or by setting the variable using drush:

$ drush vset migrate_drush_path /usr/bin/drush

On a windows server the path of the drush command has to include 'drush.bat', e.g. like C:\ProgramData\Drush\drush.bat.

Another element is to make sure that PHP is on the path for your web server. To verify this, go to http://example.com/admin/reports/status/php and look at the PATH value under Apache Environment. If the PATH does not include the directory containing PHP, you will need to set the PATH appropriately. On some systems, this may mean setting PATH in an envvars file - other system may vary.

On Mac OS X with MAMP, for example, you need to edit the file /Applications/MAMP/Library/bin/envvars and add some additional settings like the following (adjust for the version number of PHP that you're using) to the end of the envvars file and then restart MAMP for it to take effect:

PATH="/Applications/MAMP/bin/php/php5.3.20/bin:/Applications/MAMP/Library/bin:$PATH"
export PATH

Once you have set the migrate_drush_path variable, visit the Configuration page in the migrate UI. This page will validate that your server is properly configured to run drush (by running a drush status command and verifying its output), and if so it offers further options:

Import method - You can choose for the Import and Rollback operations in the UI to always run migrations through the UI or to always run them through drush. You may also choose to have the option at run time - the operations menu will include the selections Import immediately, Import in background, Rollback immediately, and Rollback in background. Thus, you can choose to use the UI for relatively quick operations, and only use drush for large import jobs.

Send email notification when a background operation completes - If checked, when a background import or rollback completes notification will be sent to the email address of the account running the operation. Whether or not you choose notification, you can always check the progress of an operation by refreshing the dashboard page. When notification is selected, you can enter the subject and body to be used for the email notification.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

If you're using MAMP on a Mac, and you need to add MAMP's PHP bin directory to the Apache environment PATH in envvars, you need to edit the file /Applications/MAMP/Library/bin/envvars and add the following (replacing the PHP version with whatever version you're using):

export PATH="$PATH:/Applications/MAMP/bin/php/php5.3.20/bin"

Additionally, if you're still not able to get drush working through the UI, you might need to comment out the DYLD_LIBRARY_PATH settings inside the same envvars file (for some reason, the settings can cause exec() to fail and exit with status code 5.

__________________
Gittip | Work: Midwestern Mac, LLC | Personal: Life is a Prayer.com

If you're using the stock Apache that comes with OSX but you have an alternate PHP (from Homebrew for example) then the environment variables are controlled by /System/Library/LaunchDaemons/org.apache.httpd.plist.

You'll need to add the following lines (replacing /usr/local/bin with your desired PATH):

<key>EnvironmentVariables</key>
<dict>
  <key>PATH</key>
  <string>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin</string>
</dict>

And then restart Apache to apply the change.

For those who run into memory issues using drush migrate, I wrote a blogpost about this issue. You can find it here http://www.jimmyhenderickx.be/drupal-migrate-memory-issues-using-drush