Friday, October 25, 2013

Drupal backup and restore using Drush

 

Drush is a very poweful command line tool to manage Drupal efficiently.

You can manage your drupal site very well using this tool. 

Starting from Drupal installation, you can 

1) Download themes and modules
2) Enable themes and modules
3) Disable themes and modules
4) uninstall modules
5) Clearing cache
6) Backup root files & database
7) Restore them to new site

Some useful drush commands :

Before running the command, first go to desired directory.

Ex: If you want to enable commerce module, first go to /var/www/docroot/sites/all/modules/contrib
drush dl commerce  - will download the commerce module.
drush en commerce - will enable it
drush uninstall commerce - will uninstall it
drush dis commerce - will disable it&nbsp
drush cc all - will clear all cache&nbsp

Backup and restore :

Backup:

As i said before go to your root directory before running below command.
drush archive-dump --destination=/var/back_up/yoursite_today.com.tar.gz

( or )

drush ard --destination=/var/back_up/yoursite_today.com.tar.gz



 Restore :

drush archive-restore /var/back_up/yoursite_today.com.tar.gz --destination=/var/www/new_site.com

( or )

drush arr /var/back_up/yoursite_today.com.tar.gz --destination=/var/www/new_site.com

When you go to your backup directory, there will be one MANIFEST.ini which will contain backup details as in below.

[Global]
datestamp = "1382704323"
formatversion = "1.0"
generator = "Drush archive-dump"
generatorversion = "6.0-beta1"
archiveformat = "platform"

[default]
docroot = "/var/www/beta_bbd"
sitedir = "sites/default"
files-public = "sites/default/files"
database-default-file = "beta_bbd.sql"
database-default-driver = "mysql"
 
Click here to see more about Drush . Another useful link.