Update drupal modules by command line

Posted on December 9, 2019

When FTP is not an option and only you hace acces ssh to the server, drupal is not an easy an task to update. This is a case of drupal 7 that I wanted to update at version 7.61. You change the versions accordingly.

Go inside your drupal installation (for example /var/www/mysite/web)

Remove all your files on the folder except the folder sites any file that was edited from you.

You can rename it temporaly

sudo mv sites _mysites

Download latest version of drupal:

sudo wget https://ftp.drupal.org/files/projects/drupal-7.61.zip

Unzip the folder. The files will be extracted in a new folder.

unzip drupal-7.61.zip

Move the extracted files in the current folder.

mv drupal-7.61/* .

Restore sites folder

sudo rm -R sites
sudo mv _mysites sites

Run the yoursite.com/update.php in your browser. After core is updated we can go for the modules.

At yoursite.com/admin/modules/update you can see the list of the modules that need update. If you click on them you visit the site of the module where you can copy the link to the zip file to download.

You move on modules directory /var/www/mysite/web/sites/all/modules

The following steps are for all modules you need to update. Eliminate the existing folder, download the new version and extract it. This example is only for modules views that needs to be updated on version 7.x-3.20

sudo rm -R views
wget https://ftp.drupal.org/files/projects/views-7.x-3.20.zip
unzip views-7.x-3.20.zip

When you are done, you can run again yoursite.com/update.php in your browser.