Script to archive enabled modules

We use multi-site installations pretty much exclusively. Moving sites around (from development to production, say) can be a pain, especially when there are a large number of modules in sites/all/modules, relatively few of which are used by a given subsite.

I recently turned my hand to using drush to pick out just the enabled modules for a given subsite to make for easy migration. This is my proof of concept script; there is lots of room for improvement.

 #!/bin/sh DOMAIN="domain.tld" DRUPALROOT="/path/to/drupal" SCRIPTROOT=`pwd` # set up tarfiles TARFILE_ALL="${SCRIPTROOT}/${DOMAIN}_sites.all.modules.tar" if [ -f $TARFILE_ALL ]; then rm -f $TARFILE_ALL; fi TARFILE_SITE="${SCRIPTROOT}/${DOMAIN}_sites.${DOMAIN}.modules.tar" if [ -f $TARFILE_SITE ]; then rm -f $TARFILE_SITE; fi # tar up modules cd $DRUPALROOT for MODULE in `drush --root=$DRUPALROOT --uri=http://$DOMAIN --pipe statusmodules`; do # sites/all modules TEST="./sites/all/modules/$MODULE" if [ -d $TEST ]; then echo "ALL: $MODULE" tar --append -f $TARFILE_ALL $TEST fi # site-specific modules TEST="./sites/$DOMAIN/modules/$MODULE" if [ -d $TEST ]; then echo "SITE: $MODULE" tar --append -f $TARFILE_SITE $TEST fi done gzip $TARFILE_ALL $TARFILE_SITE




Add new comment

This question is for testing whether you are a human visitor and to prevent automated spam submissions.