Last updated 9 January 2008. Created on 3 May 2006.
Edited by joachim, add1sun, AjK, Senpai. Log in to edit this page.


This tutorial assumes you are familiar with the command line, whether you're using a Mac or Linux. It utilizes wget, a package that comes standard on all *nix machines, but must be manually installed on any recent Mac. If you're using a 10.3 or 10.4 Mac, please download a copy of, uncompress it, then to install it, type sudo cp -R pathToDecompressedWgetDirectory /usr/local/bin. You should now have a working copy of wget on all OS 10.3 and OS 10.4.x Tiger systems. To test the install, type wget --help

Replacing your Drupal files

Archive the old files

You'll want to move all the old core files into an archived folder for safekeeping using sudo mv /path/to/old/drupal/site/ /path/to/newly/desired/archive/ where path/to/old/drupal/site/ is your root drupal installation and path/to/newly/desired/archive/ is your desired archived folder location. Most people use ~/Sites/archivedDrupal/ for this, but you may use whatever you desire, as long as you can remember where you created the archive, because you'll need it later.

Wget the new files

Download and decompress the new core files into your base website directory using these three commands (where "drupal-5.5.tar.gz" is replaced with tarball name for the latest version of Drupal):

cd path/to/old/drupal-site/
tar -xzvpf drupal-5.5.tar.gz

Restore necessary files from the archived directory

Copy the following files from the backup directory into your Drupal site directory:

  • .htaccess
  • sites/default/settings.php (but see section on older sites below)
  • the 'files' directory
  • any other files you need from the 'backup' directory, such as your cron scripts in scripts/ or subdomain folders

Older sites

If you are upgrading from a version of Drupal that is older than Drupal 4.5 , then you will have to look in your archived directory for a file called: includes/conf.php and use a text editor to copy the following three lines as they appear in your conf.php file:

$db_url = mysql://user:pass@localhost/drupal_db';
$base_url = '';
$db_prefix = '';

And paste them over the lines in your new Drupal file located at sites/default/settings.php

It's simply a matter of overwriting the above three lines in settings.php with the lines in conf.php.
These settings are responsible for connecting your Drupal to the database and to the files it needs. The file name and location was changed from Drupal 4.5 to 4.6, hence the need to move these lines to the new file.

Looking for support? Visit the forums, or join #drupal-support in IRC.


gtcaz’s picture

On my system that tar command unpacks everything into ./drupal-5.5, not the . directory. I had to cp -R * .htaccess path/to/old/drupal-site/ to install the folders correctly.

rjbrown99’s picture

It took me a bit of Googling, but if you want to extract the new drupal instance with Tar and NOT have it go into a subdirectory called drupal-6.X/, the appropriate tar command is:

tar -xzvpf ./drupal-6.X.tar.gz --strip-components 1

The --strip-components will get rid of the subdirectory inside of the tar and extract it right to your current dir. You still have to copy .htaccess and other stuff back but at least it gets rid of the copying steps for the actual drupal instance.

spangaroo’s picture

Thanks for that tip rjbrown99. I'll give it a shot when I have to upgrade to D7. (Hoping my contributed modules will be supported soon after it's released.)

Currently I have my drupal 6.11 installation in my root. When I used the instructions in the tutorial, it uncompressed version 6.12 into public_html/drupal-6.12. I just left it alone and did it all through FTP, but man it takes a *lot* longer.

Thanks again for sharing.

bhagman’s picture

Been working on a way to make a seamless upgrade (e.g. high traffic site - upgrade with few/no 404's).

The key is to make sure that the maintenance page does not break during the process.

The new themed maintenance pages in d6 makes things great. Here are my preliminary steps. If you have anything else to add, please do so.

1) Backup everything (Cardinal rule).
--- For copying the file structure, I recommend:
cp -Rpv /current/location/of/drupal/.htaccess /current/location/of/drupal/* /tmp/drupalbackup

2) Follow the standard upgrade preparation procedures (i.e. Login as user 1, set offline, disable contrib modules, etc.).

3) Extract the new tarball (e.g. /tmp/newdrupal/) -- ENSURE timestamps are maintained.

4) rm -f /tmp/newdrupal/sites/default/settings.php
--- Unless something major has changed with settings.php - I highly doubt it. if so, you will have to hand modify.

5) \cp -Rvupf /tmp/newdrupal/* /current/location/of/drupal/
--- this will upgrade only the newer files (n.b. Yes, that's a "\" backslash at the beginning. That's to override any aliases.)
--- if there are any major changes to .htaccess/robots.txt, you will have to hand modify that file.

6) Follow the remaining steps of the standard upgrade procedures, starting at update.php

7) Don't forget about upgrading your contributed modules as well.

Here you will see that you don't need to delete/move any files, and hence, the server should be able to return some sort of formatted response, themed along with your site - i.e. few/no 404's.

Kami Petersen’s picture

move is instant. For minimum downtime, wouldn't it be better to prepare your new site in a copy of your live site somewhere on the same file system, then

sudo mv live archive && sudo mv new live

jppi_Stu’s picture

The -u option is apparently specific to gnu cp and thus may not be available. Since -u is key to only updating newer files, it seems necessary to use rsync instead, if use of the -u option returns an error. For example, something like:

rsync -avu /tmp/newdrupal/ /current/location/of/drupal

With significant care(!) --delete could be used to also clean up any old files that are no longer needed, provided that --exclude was also used with installation-specific details to preserve any non-Drupal-core files that should be kept. See man rsync for details!

bendshead’s picture

After you get and unzip the files, they will be in a folder on your server called drupal-x.x

You'll want to move them to your base directory, perhaps /www or /public_html or what have you...

You can go back to the first-time install documentation to refresh your memory how to do this with command line: