Using Drush to Bulk Export Views

Soon we will implement the drush views bulkexport function to help ease revision control of views. This will make backing up views and controlling them in git much easier and more straight forward. The first thing you will need to do (if you haven't already) is install  drush. This is a command line utility to new to drupal. For drush installation, see  this page or explore the  drush project page.

Once you have drush installed, everything should be ready for our views export magic to happen. Go to a command line, within your repository, and type in the following command:

drush sm bulkexport views path/to/the/views/module views_moduleName

If this looks daunting, don't worry it's not so bad. You simply need the following information:

  • path/to/the/views/module this will be something like sites/all/modules/views_ussfhome/includes
  • views_moduleName which should be something like views_ussfhome

The above examples can be used for the www.ussf2010.org domains, other domains will have different module names. Here's an actual example of a views bulkexport from the command line.

0 ross@guattari:~$ drush sm bulkexport views sites/all/modules/views_ussfhome/includes views_ussfhome

Once you have entered this command, you will be prompted to select a tag, like this:

 	1: Calendar
	2: Date
	3: default
	4: ussfhome
Type the tag number you would like to export: 

You will need to select the domain specific tag number. In this case, number 4. Enter the number, and when prompted confirm by entering 'y'.

Test your local views, make sure everything is in order, then commit and push your changes following the standard git practices.

Another Option

If you would like to simply view the output without writing it to a file, you can use this command:

drush sm bulkexport views - views_moduleName

Note on Building Views

Make sure to tag your views with the site specific tag so they can be exported using this method.