In Windows, after installing Drush through the installer, some extra configuration is needed in order to execute commands in remote systems or synchronize data.
First of all, unless you are sure that when you installed Drush you marked the components "cwRsync" and "Register Environment Variables", launch the Drush installer again, click on Change and install them. This will set up your PATH variable with the location of every program that Drush needs and install cwRsync in order to use the Drush command core-rsync.
That being done, you will have to create your home path where cwRsync has been installed. this directory will be used to store your SSH key. Follow these steps to generate your SSH key and copy it to the remote host:
- Open the command line interpreter by going to Start > Execute > type cmd and hit Enter.
- Go to the cwRsync installation directory:
cd C:\Program Files\Propeople\Drush\cwRsync
- Create your home directory at this level. It should be "home/your Windows username". If you type your username wrong, you will get an error later on when we execute a command for a remote Drupal site which will let you know how should the folder under home be called.
The following example is a template to set up an alias for the local site and another alias for the site in the development server.
* @file yoursite.aliases.drushrc.php
* Site aliases for [your site domain]
* Place this file at ~/.drush/ (~/ means your home path)
* To copy the development database to your local site:
* $ drush sql-sync @yoursite.dev @yoursite.local
* To copy your local database to the development site:
* $ drush sql-sync @yoursite.local @yoursite.dev -structure-tables-key=common --no-ordered-dump --sanitize=0 --no-cache
* To copy the production database to your local site:
* $ drush sql-sync @yoursite.prod @yoursite.local
* To copy all files in development site to your local site:
* $ drush rsync @yoursite.dev:%files @yoursite.local:%files
* Clear the cache in production:
* $ drush @yoursite.prod clear-cache all
* You can copy the site alias configuration of an existing site into a file
* with the following commands:
* $ cd /path/to/settings.php/of/the/site/
* $ drush site-alias @self --full --with-optional >> ~/.drush/mysite.aliases.drushrc.php
* Local alias
* Set the root and site_path values to point to your local site
$aliases['local'] = array(
'root' => '/path/to/drupal/root',
'uri' => 'yoursite.localhost',
'path-aliases' => array(
Following are some useful Unix/Linux commands which are helpful if you are dealing with large sites (files and db size). I find these really handy when moving sites from one server to other, taking backups of Files, Database etc.
Note: To get access to the Unix command line, you will need an SSH client (e.g. Putty). You can also use WinSCP if you are not comfortable with Command line. WinSCP has a feature to enter custom commands using its interface.
Please add other command-line commands that you use while setting up, developing and managing your Drupal sites.
Zip Contents of current directory
zip -r zipfile.zip *
Unzip Contents into current directory
Unzip (and extract) the tar'd, gzipped archive (tarball) Contents into current directory
tar zxvf tarballfile.tar.gz
Remove a directory and its contents (Use with extra care)
rm -rf directoryname
mysqldump dbname -uUSERNAME -pPASSWORD --host HOST > filename.sql
mysql -u root -p[root_password] [database_name] < dumpfilename.sql
Copy all files / directories from one server to other (Both servers should have SSH Support)
rsync -avz --progress username@servername:sourcefolder destinationfolder