Showing posts with label drush. Show all posts
Showing posts with label drush. Show all posts

Update DRUPAL 7 Core using DRUSH

Before you begin

If not already done, it is suggested to read this Introduction. Which summarized all your options to choose from when updating your Drupal 7.

Update Drupal 7 core using Drush

Steps to update Drupal 7 core using Drush version 8 or earlier. Drush is the Drupal Shell.

1. Backup everything

Drush backs up the Drupal 7 core installation for you when updating, but you might want to back-up the sites directory just in case something goes wrong. You also want to take a backup of the database. Use the command below to back up everything:
drush archive-dump

2. Put your site in maintenance mode

drush vset --exact maintenance_mode 1 
drush cache-clear all 

3. Update Drupal with drush

drush pm-update drupal
Drush will also update your database if necessary.

4. Check that everything works

Go around your site and test everything! If you had modified robots.txt or .htaccess, make sure the modifications are reapplied. (Sometimes you can just copy the old files back.) If you used a custom installation profile, you might have to copy that back too. If the configuration file has changed, make sure your file has the latest and correct information - compare sites/default/settings.php and sites/default/default.settings.php.

5. Put your site online again

drush vset --exact maintenance_mode 0 
drush cache-clear all 

Alternative Drush commands

Alternatively, you might be interested in those other Drush commands:
  • drush pm-update is the same as running drush pm-updatecode and then drush updatedb, so you can optionally run the latter two commands to break up the process.
  • drush pm-updatecode has a number of options you can use with drush pm-update, including --security-only. Learn more here. You can run update commands with -n to prevent it from automatically answering 'y' to every 'y/n' request for user input.

Troubleshooting

  • No code updates available for "drush pm-update drupal"
    Run following code which will refresh the available releases.
     
    drush rf
    
    and rerun
    drush pm-update drupal

Installing DRUSH as a GLOBAL - Ubuntu 18.04

Tip: Install Drush 8 for Drupal 7 
Drush is a great tool and is well worth setting up in your development environment, it speeds your workflow up incredibly and gets easier to use over time as you learn by heart the various and most commonly used commands.
I couldn't find a tutorial online which gave me the correct path for my .bashrc file so I thought I would document what worked for me here, maybe it will help someone out.
My first step was to install composer globally, if you are not all that familiar with the command line you don't need to include the $ sign.
$ curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer
Next step is to install drush globally.
$ composer global require drush/drush
Now we need to add a path to the Bashrc file, this basically enables us to use drush as a shorthand command rather than it's full path. If you don't have a .bashrc file in your home directory then you will need to create one.
Most other tutorials I found were telling me to use the following for my PATH.
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
However upon investigation my Drush folder was not in this directory and was actually 
export PATH="$HOME/.composer/vendor/drush/drush:$PATH"
If neither of these work you will need to do some investigating to find out where Drush was installed, if you can't see the .composer or .config folders you will need to show hidden files, in Ubuntu you can usually do this by clicking on one of the icons in the top right of your folder, then look for 'show hidden files' or something to that effect.

Installing Drush for Drupal 7 
Installing Drush provides a way of managing your Drupal installs using a familiar method, the command line.  Drush can simplify your life by allowing you to perform admin duties.
In this tutorial, we will be using Composer as our package manager, as it is necessary to install Drush’s dependencies.  It does take at least 1 GB worth of memory, so be sure to have that before starting this tutorial.

Step 1:  Updating

As a matter of good practices, we’ll update our system
apt-get update

Step 2:  Install Zip

Most likely you’ll already have the zip command but if you don’t go ahead and install.
apt-get install zip unzip

Step 3: Install Curl

apt-get install curl php7-cli git

Step 4: Install Composer

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

Step 5: Install Drush

Using the following command will install the newest version of Drush, at this time it is
composer global require drush/drush
Alternatively, you can install the Drush version of your choice by appending the version needed.  If you’d like Drush 8 use…
composer global require drush/drush:8

Step 6: Add Drush Directory to Your Path

If performing the version check in Step 6 gives you the message of “command not found” then open your .bashrc file and input the following into the file
#path for Drush
export PATH="$HOME/.composer/vendor/bin:$PATH"
Run source show recognize the changes to the file.
source .bashrc

Step 7: Verify the Installation of Drush

You’ll be able to verify the version of the Drush install and other useful information by running the following command.
drush status
Output:
PHP binary    : /usr/bin/php7.0
PHP config    : /etc/php/7.0/cli/php.ini
PHP OS        : Linux
Drush script  : /root/.composer/vendor/bin/drush
Drush version : 9.5.2
Drush temp    : /tmp
Drush configs : /root/.composer/vendor/drush/drush/drush.yml
Drupal root   : /root/.composer/vendor/drush/drush/sut
Issues
A) having trouble installing composer
  1. Goto a directory you can write to:
    cd ~
  2. get composer:
  3. move composer into a bin directory in your $PATH var:
    sudo mv composer.phar /usr/local/bin/composer
  4. double check composer works
    composer about
  5. (optional) Update composer:
    sudo composer self-update