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.
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
This is a simple method to create, upload and verify an SSH Key with Drupal.org
Generate a key for the first time
Open the Git Bash window and change to the .ssh directory
If the .ssh directory does not exist, change to the user directory then create the .ssh directory and enter it.
NOTE: Do not include any spaces in your keyname as it can cause problem when you upload your public key to some sites.
At the Git Bash prompt, enter:
ssh-keygen -t rsa (optional " -C keyname" where keyname is anything you want)
You should see:
Generating public/private rsa key pair.
Enter file in which to save the key (/u/.ssh/id_rsa):
Press 'Enter' here to accept the default
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Press enter to leave the passphrase empty.
Your identification has been saved in /u/.ssh/id_rsa.
Your public key has been saved in /u/.ssh/id_rsa.pub.
The key fingerprint is:
Copy your Key
At the Git Bash prompt, type:
You should see something like: