Updating and reverting Drupal 7 Features with Drush

Updating and reverting is an essential part of managing Features on Drupal sites. After you create a Feature, if you make further configuration changes the Feature will become overridden. This means that the configuration settings that you have made in the UI are stored in the database but do not match the feature module code.

You have two options at this point, you either update the Feature, or you revert the Feature. If you update it, you are telling Drupal to update the code to match what is in the UI (and therefore database). If you revert, you are telling Drupal to undo the changes in the database and revert back to what is stored in code. The module code will not be changed. Instead, the database configuration will revert back to the settings that are stored in code.

Drush makes updating and reverting Features a piece of cake.

Features update

To update a specific Feature, use the feature-update command with the name of the Feature you want to update. The alias for feature-update is fu.

  1. $ drush fu [feature_name]

To update more than one feature with the same command, add multiple feature names and separate each with space between each name.

  1. $ drush fu [feature_name] [feature_name]

Example

A typical example of using feature update is when you are working on an existing feature. You make a configuration change (e.g. change a setting in a content type). The feature will then be overridden, so you need to update the feature to include the configuration change that you have made.

Update all features

It may be easier to update all features at the same time. You can do this with the feature-update-all command. The alias is fua. To update all features at the same time:

  1. $ drush fua

You can exclude some features by passing in their name as an argument.

  1. $ drush fua [feature_name]

Features Revert

You can revert a feature in Drush using the feature-revert command with the name of the feature you want to revert. The alias is fr.

  1. $ drush fr [feature_name]

Example of using feature revert

You might want to revert a feature if you have made a configuration change that you want to undo. For example, you change a setting on a content type but you no longer want that change. As long as the feature has not been updated, or re-exported, yet, you can revert it. This will revert everything in that feature back to the version that exists in code.

Revert all features

It may be easier to revert all features at the same time. You can do this with the feature-revert-all command. The alias is fra. To revert all features using Drush:

  1. $ drush fra

You can exclude some features by passing in their name as an argument.

  1. $ drush fra [feature_name]

New to Features?

Check out the Learn Features email course below.

Learn Drupal Features

Make your life easier by packaging up Drupal site building settings in Features modules. No coding required! 

Free 5 day course where you will learn to create and update your own Drupal Feature module.

Get Day 1 now

Add new comment