Last active
February 1, 2024 14:19
-
-
Save jonhattan/79c18e3b7afd302cc073baf59e783d7b to your computer and use it in GitHub Desktop.
[DRUPAL] Shell script to run a migration in chunks of 3k
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALIAS=@foo | |
MIGRATION=foo_news | |
LOG_FILE=/tmp/foo-migrate-logs/migration-foo_news.log | |
rm -f $LOG_FILE | |
date > $LOG_FILE | |
# Run migrations in chunks of 3000 items. | |
THRESHOLD=3000 | |
TOTAL=$(COLUMNS=160 drush $ALIAS migrate-status $MIGRATION | tail -n 1 | awk '{print $3}') | |
if [ $TOTAL -gt $THRESHOLD ]; then | |
START=1 | |
while [ ! $START -gt $TOTAL ]; do | |
let END="$START + $THRESHOLD - 1" | |
echo "### migrate [$START,$END] items ###" >> $LOG_FILE | |
drush $ALIAS -d -y migrate-import $MIGRATION --limit=$THRESHOLD >> $LOG_FILE 2>&1 | |
echo "### migrate-messages ###" >> $LOG_FILE | |
drush $ALIAS -y migrate-messages $MIGRATION >> $LOG_FILE 2>&1 | |
let START="$END + 1" | |
done | |
fi | |
# Do a last pass for all items to ensure no one is left over. | |
echo "### migrate items (last pass) ###" >> $LOG_FILE | |
drush $ALIAS -d -y migrate-import $MIGRATION >> $LOG_FILE 2>&1 | |
echo "### migrate-messages ###" >> $LOG_FILE | |
drush $ALIAS -y migrate-messages $MIGRATION >> $LOG_FILE 2>&1 | |
echo "### migrate-status ###" >> $LOG_FILE | |
drush $ALIAS migrate-status $MIGRATION >> $LOG_FILE 2>&1 | |
date >> $LOG_FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For a 6100 items migration it runs 4 times: