Thursday, March 6, 2014

BACKUP & RESTORE DRUPAL SITE WITH DRUSH

This will back up both site's files and database, so we can have a good night sleep.

1. Back up
The easy way to backup Drupal is to run Drush commands inside Drupal Root (The installed directory of Drupal on your Linux host), for me this is folder: /var/www/drupal, let move into Drupal root on your host
$ cd /var/www/drupal

Back up the site’s database and files with this command, we have the output back up file in this command line too:
$ drush archive-dump --destination=/var/backup/drupal_20140306_17.tar.gz

After backup finish, explore the tar file drupal_20140306_17.tar.gz, we can see database script and files of the site.
And the MANIFEST.ini content here, so that we can recognize that db script, files, back up information is correct.
[Global]
datestamp = "1394100202"
formatversion = "1.0"
generator = "Drush archive-dump"
generatorversion = "6.2.0"
archiveformat = "platform"

[default]
docroot = "/var/www/drupal"
sitedir = "sites/default"
files-public = "sites/default/files"
database-default-file = "drupal2.sql"
database-default-driver = "mysql"

So that is the back up file to be restored later if we get problem with our Drupal site.

2. Restore
Now we can try to restore the Drupal site from backup file, in the restore command we have backup file, restored destination, database credential information.

$ sudo drush archive-restore /var/backup/example.com.tar.gz \ --destination=/var/www/example.com \ --db-su=root --db-su-pw=password --overwrite

Parameters:
--db-su: database admin account.
--db-su-pw: database admin password
--overwrite: overwrite restoration.

Just wait for the restoration finish, and you are back with your Drupal.

Wednesday, March 5, 2014

INSTALL DRUPAL BY USING DRUSH


Drush is well known powerful tool for drupal admin. After have Drush installed on your Linux host, then you can do these following actions to install Drupal very quickly.

1. Install Drupal in /var/www:
Move to /var/www to install Drupal for having it running on apache2
$ cd /var/wwww

2. Download Drupal:
$ drush dl drupal --package-handler=git_drupalorg
This statement need you already has GIT and php-gd installed on your machine, if you still have not git then you have to install them:
$ sudo apt-get install git
$ sudo apt-get install php5-gd

3. Rename Drupal Source Folder:
After you have downloaded drupal source “drupal-7.xx”, you have to rename it, then move into renamed folder:
$ mv drupal-7.xx drupal
$ cd drupal

4. Install drupal:
$ drush si standard --db-url=mysql://dbusername:dbpassword@localhost:port/dbname --db-su=name --db-su-pw=password --site-name="Your New Site"

When the installation finished, you will be informed about drupal site admin account, please take note it for login the site later.

5. Restart apache2:
$ sudo /etc/init.d/apache2 restart

6. Run drupal:
http://localhost/drupal