Created
July 2, 2011 06:18
-
-
Save brockboland/1059791 to your computer and use it in GitHub Desktop.
Drupal dev site: recreate template from current site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z "$1" ]; then | |
echo "Usage: ./recreate drupal_version, for example: ./recreate 6" | |
else | |
# Prep a bunch of vars | |
versionname=d$1 | |
deploydir=~/src/templates/$versionname | |
sitesdir=$versionname.local | |
sitesfullpath=~/Sites/$sitesdir | |
dbname=dev_$versionname | |
backupdir=$deploydir/backup | |
timestamp=`date +%Y.%m.%d-%H.%M` | |
# Only continue if the given version number corresponds to a site directory | |
if [ -d "$sitesfullpath" ]; then | |
echo "Re-creating template files" | |
echo "Backup previous save" | |
# Make sure the backup directory exists | |
if [ ! -d "$backupdir" ]; then | |
mkdir $backupdir | |
fi | |
mv $deploydir/db.sql $backupdir/db-$timestamp.sql | |
mv $deploydir/files.tar $backupdir/files-$timestamp.tar | |
echo "Clear caches" | |
drush @$sitesdir cache-clear all | |
echo "Dump DB" | |
# Dump DB | |
mysqldump --opt -uuser -ppass $dbname > $deploydir/db.sql | |
echo "Tar files" | |
# Change into Sites dir and re-tar the dir | |
cd ~/Sites | |
tar -pczf $deploydir/files.tar $sitesdir/ | |
echo "All done!" | |
else | |
echo "The sites directory can't be found: $sitesfullpath" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment