Drush alias help me to run the drush command on the remote server from my local computer.
How to setup ?
Setting up the aliases is quite easy, It just required file named in this below format
in your drush folder. Most of the time location of your drush folder should be ~/.drush.
Putting it in home folder makes it accessible from anywhere.
Content for [my-site.]aliases.drushrc.php
// You can create as many environments you want. $aliases['dev'] = array( 'remote-host' => 'ssh-host', 'remote-user' => 'ssh-user', 'root' => 'my-drupal-root', 'uri' => 'my-site-name', );
To add more environments, create one more alias array in the same file. Like this
$aliases['prod'] = array( 'remote-host' => 'ssh-host', 'remote-user' => 'ssh-user', 'root' => 'my-drupal-root', 'uri' => 'my-site-name', );
Below is the command to access your remote site via drush
drush @my-site.dev status // Dev env drush @my-site.prod status //Prod env
To list all Drush alias run the below command
Now we are ready to run almost every drush command locally to control our remote drupal site.
drush @my-site.dev sql-dump > dbdump.sql drush rsync @my-site.dev:sites/default/files/ sites/default/files/