Lullabot/lmm

Drupal script manager

e0ipso opened this issue · 1 comments

Not sure if it will be useful for anyone else, but I though I'd share.

I have been using this extremely simple script to roll back to previous states of the db when doing features related work.

#!/bin/bash

ROOT_UID=0     # Only users with $UID 0 have root privileges.
E_NOTROOT=87   # Non-root exit error.

# Run as root, of course.
if [ "$UID" -ne "$ROOT_UID" ]
then
  echo "Must be root to run this script."
  exit $E_NOTROOT
fi

OLD_WD=$(pwd)
cd /var/www/docroot/sites/nbcunbc

if [ -z "$1" ]
then
  echo USAGE: $0 new_lmm_db [old_lmm_db]
  echo The new_lmm_db will be deleted as part of the process if an old_lmm_db is provided.
  lmm status
  exit 0
fi

if [ -n "$2" ]
then
  lmm checkout $2
  lmm delete $1
  lmm branch $1
  lmm checkout $1
else
  echo Omitted old lmm database. Current snapshot will be updated instead.
fi

drush rr --no-cache-clear && drush updb -y && drush fra -y && drush en -y devel,stage_file_proxy && drush uli
cd $OLD_WD

Since this assumes drush etc, would it make sense to include this as a helper script in trusty32-lamp's root directory along with the php-debug helper?