This tutorial covers the following topics:
Drush is a command line interface that allows to manage your Drupal web sites fast and easy. This scripting shell should be additionally installed on your hosting server in order to benefit from its features. It is pre-installed on the SiteGround servers and you can use it with your Drupal Hosting package.
First, you need to have a Drupal installation under your hosting account. It can be completed in several mouse clicks through cPanel -> Softaculous.
Second, you need SSH access to your account in order to run Drush commands.
This tutorial explains how to use Drush in order to backup and update your script, install and activate Drupal extensions, remove them and clear the script’s cache. Note that if you are using Druapl 8.3 or below, you should replace drush with drush8 in the command examples below.
Backup Website with Drush
In order to create a backup of your Drupal web site using Drush, you should first log in your account via SSH. Detailed instructions on how to use SSH can be found in our SSH tutorial. After you login to your account via SSH, navigate to the Drupal installation’s home folder.
Then run the following command:
drush archive-dump --destination=/home/USER/backup/site.tar.gz
Replace USER with your actual cPanel username. You can pick a different location for the backup and different backup file name. Executing the command above will create an archive with all the website files and a copy of your Drupal database. The output would be similar to the following one:
Database dump saved to /tmp/drush_tmp_1510221289_5a0425e916e33/USER_drup.sql [success]
Archive saved to /home/USER/backup/site.tar.gz [ok]
After the process is successfully completed, you will be able to find the backup in the specified location - /home/USER/backup/site.tar.gz.
Restore Website with Drush
If you need to restore a backup of your website use the following command:
drush archive-restore /home/USER/backup/site.tar.gz
The output will be similar to:
Archive restored to /home/USER/public_html/newdrupal [ok]
Upgrade Website with Drush
To upgrade the Drupal core, use the command below:
After the application's core is upgraded, you should make sure to update the database as well:
Update entity, if any required entity updates are needed:
Install, Enable and Uninstall Plugin with Drush
To install a chosen plugin you should download and enable it. Check the example listed below:
drush dl addtoany
The output would be similar to:
Project addtoany (8.x-1.8) downloaded to /home/USER/public_html/drupal/modules/addtoany. [success]
To enable the installed module, you should run the command below:
drush en addtoany
<em>The following extensions will be enabled: addtoany
</em><em>Do you really want to continue? (y/n): Do you really want to continue? (y/n): y
addtoany was enabled successfully. [ok]
addtoany defines the following permissions: administer addtoany</em>
Instead of AddToAny you can pick a different Drupal plugin or module. To skip the Do you really want to continue? prompt modify the command in the following way:
drush en -y addtoany
A chosen extension can be disabled and removed with the command below:
drush pm-uninstall addtoany
The following extensions will be uninstalled: addtoany
Do you really want to continue? (y/n): y
addtoany was successfully uninstalled.
Clear Cache with Drush
Often you would need to clear the script’s cache. It can be easily completed with the following command:
Enter a number to choose which cache to clear.
 : Cancel
 : drush
 : theme-registry
 : menu
 : css-js
 : module-list
 : theme-list
 : render
 : views
If you prefer to clear all types of cache at once, the following command is available:
Cache rebuild complete. [ok]
To get help on the Drush commands run the following command:
If you want to learn how to use a specific command enter the following line in the shell:
drush help command
Replace the command string with the chosen one. For example:
drush help archive-backup
More about Drush may be found in the official documentation of the project: http://drush.ws/