Can I use drush to compare the running modules on two sites on the same server?
Question
Is there a way to use drush to compare the list of running modules on two Drupal 6 sites?
I have two sites running locally (with two code bases if that matters) with different modules, but a very similar odd problem (discussed about here). In trying to find the modules that might causing this problem, it would be really helpful to get a list of modules that are running on both sites.
Solution
I don't know if there is a direct way, but this should work with bash or a similar shell. No idea about how to do that with Windows :) Please comment and I'll integrate it into the answer.
First, save the enabled modules of both sites into a textfield with this command:
drush pm-list --status=enabled > enabled_modules_site_x.txt
Then, you can easily compare the output of these two files with diff.
diff first_file second_file
OTHER TIPS
Here is my adaptation:
diff -b -s --suppress-common-lines <(drush @sa1 pm-list --status=enabled --fields=package,name) <(drush @sa2 pm-list --status=enabled --fields=package,name)
It doesn't care about versions to get a quick overview of which modules haven't been enabled on the other server.
Berdir's answer works, mostly, but there is a more direct way to do it, and you can compare across multiple machines if you have drush aliases set up to allow it.
diff -b -s --suppress-common-lines --side-by-side <(drush @uat pm-list --status=enabled) <(drush @dev pm-list --status=enabled)
(Obviously you need to replace @uat
and @dev
with the aliases that are appropriate in your case.)
You normally only care about the differences, so --suppress-common-lines
is a useful option. I find it easier to see differences when they are side-by-side, so the --side-by-side
option may be helpful to you too. Remove it if you prefer standard diff
output. -b
ignores whitespace differences, which is very handy. -s
tells you if the results are identical, which is nice to get feedback about, rather than the default, which is diff
saying nothing if there are no differences.
This isn't guaranteed to always work perfectly, however, because under certain conditions you might get your output formatted differently between the two servers.
It should, however, get you most of the way to a very quick and easy, single-step, way of comparing enabled modules on two Drupal installations, that works in 95% of cases.