How to backup and upgrade drupal to latest version on a linux server using ssh and simple shell commands

If you use Drupal you will be both pleasantly surprised and frustrated by the frequency of updates and security patches.

This How To will help you quickly backup and upgrade your Drupal installation via ssh and simple shell commands.
You must have ssh access to your server in order to follow this tutorial.

  1. If you have ssh access, just follow these simple steps
  2. SSH into your server (duh!)
    ssh username@host
  3. change directories so you can see your public_html (web root) sometimes this is welcome or home but usually it will be public_html.
    Backing up from here will keep the backup private, and make it easy to back up your whole web directory.
    cd ~/
    will do the trick on most systems
  4. Make a backup of your public_html directory
    tar cvfz public_html_bak.tgz public_html
  5. Make a database backup
    mysqldump -u username -p dbname | gzip | mysql_bak.sql.gz
  6. Change into your public_html directory
    cd public_html
  7. Goto http://www.drupal.org and copy the location for the latest drupal version for this example lets say this is http://ftp.drupal.org/files/projects/drupal-6.13.tar.gz
    wget http://ftp.drupal.org/files/projects/drupal-6.13.tar.gz
  8. Extract the tar contents into the current directory stripping of the first directory (drupal-6.13) in this example.
    tar xvfz drupal-6.13.tar.gz --strip-components=1
  9. Run upgrade.php

All done, now wasn't that quick and painless?

Be sure to see the next How To Restore Drupal from backup on a linux server