Skip to content

Instantly share code, notes, and snippets.

@yanniboi
Created July 14, 2014 13:59
Show Gist options
  • Select an option

  • Save yanniboi/869368b7e15fcdfa821b to your computer and use it in GitHub Desktop.

Select an option

Save yanniboi/869368b7e15fcdfa821b to your computer and use it in GitHub Desktop.
Drush Rebuild script template
<?php
/**
* @file
* DrushRC file for http://project.com
*/
$aliases['local'] = array (
'root' => '/var/www/project/site',
'uri' => 'http://project.dev',
'databases' =>
array (
'default' =>
array (
'default' =>
array (
'database' => 'database',
'username' => 'username',
'password' => 'password',
'host' => 'localhost',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
),
),
),
);
$aliases['live'] = array (
'root' => '/home/sites/project/site',
'uri' => 'http://project.com/',
'remote-host' => 'project.com',
//'remote-user' => 'user',
'path-aliases' =>
array (
'%drush' => '/usr/local/lib/drush',
'%site' => 'sites/default/',
'%files' => 'sites/default/files',
),
'databases' =>
array (
'default' =>
array (
'default' =>
array (
'database' => 'database',
'username' => 'username',
'password' => 'password',
'host' => 'localhost',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
),
),
),
);
#!/bin/sh
# Run this script from the gitroot of the project.
if [ ! -e ./site/index.php ]
then
echo "You need to run this script from the root of the project."
exit
fi
# Sync
echo "Downloading 'project' database.\n"
drush @project.live sql-dump > db/project.sql
# MySQL
echo "Dropping 'project' database.\n"
mysql -u root -p -e "drop database project"
mysql -u root -p -e "create database project"
echo "Importing 'project' database.\n"
mysql -u root -p project < db/project.sql
# File sync
echo "Syncing files with live repo.\n"
drush -r site rsync -y @project.live:%files @self:sites/default
echo "Setting values and clearing caches.\n"
drush @project.local vset cron_safe_threshold 0
drush @project.local cc all
echo "Loggin in as root.\n"
drush @project.local uli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment