Update Your Drupal 6 Core Files
You should always update to the latest version of Drupal to take advantage of updates and to also guard your site’s security. It’s not a difficult process, but there are quite a few steps if you want to avoid errors and get it right the first time. This tutorial shows you every step involved.
Here’s how to update your Drupal 6 core files:
Backing up your site files and your database before you begin
You need two elements to constitute a complete backup.
- A copy of all the files in your current Drupal home directory. You can use FTP to download them, or your server’s file manager to copy them to another directory.
- A copy of your data base. You can use phpMyAdmin to export an SQL file to save.
Here are some tutorials we have you might want to review to hone your backup skills.
- Changing the database connection in Drupal’s settings.php
- Drupal’s Backup and Migrate Module
- Migrate or Duplicate a Drupal Site
If you want the Drupal Backup and Migrate module, you can download it here: http://drupal.org/project/backup_migrate
Step 1. Checking for updates
Go to Administrator. If you require security upgrades you will see a warning message. Inside the warning message is a link to check for available updates.
You can also check for Available updates under the Reports menu. Running a Status Report is also a good idea. You’ll see the status of your entire installation.
Checking Available Updates will tell you your current version, the recommended version and links for downloading what you need. You can go directly from 6.22 to 6.25. You can skip 6.23 completely.
Step 2. Create a duplicate of your current site
Don’t upgrade a live site. Always work on a copy.
We have a great tutorial on making duplicates of your site using the Backup and Migrate module. Check it out for detailed instructions. If you prefer you can simply download your entire database using phpMyAdmin and use FTP to download all the files in you drupal directory, and keep those downloads as a backup.
Step 3. Login to your site as User 1
Login to Drupal as User ID #1. This user has special privileges, including use of the Backup and Migrate module if you are using it. But to run the upgrade.php script, which we’ll do in a later step, you need to be logged in as user ID #1. You can find our more about Drupal User 1 here.
Step 4. Take your site Off-line for maintenance
Go to Site Configuration > Site Maintenance. Choose Off-line and click Save Configuration.
Step 5. Disable all contributed or custom modules
Go to Site Building > Modules. Uncheck the contributed modules. Click Save configuration.
Step 6. Switch to a core theme
Switch to a core theme (for instance, Blue Marine) or any of the ones that originally came with the basic drupal installation.
Step 7. Remove all Drupal files except for the sites folder.
Use your file manager or FTP program or a shell command to remove everything EXCEPT edited files and the sites folder. Keep any files you’ve edited, such as the .htaccess or robots.txt files.
The sites folder has everything you’ve added and all the files you’ve modified. Everything except the drupal core files and the database. If you followed the Drupal principle of “Never hack core” you’ll be able to get everything back to normal as long as you have a sites folder that is intact. This is one reason you want to be working on a copy and have a backup.
Step 8. Decompress the upgrade, and load the files to the server using FTP – except for the sites folder.
The thing to make sure of here is that the new files do not overwrite anything you’ve saved from the original version. After you decompress the files, delete the new sites folder so there is no chance of overwriting the one you are upgrading,.
As you can see, I’ve created a test directory called UPGRADE and I’ve removed everything but the sites folder. Upload all the new folders and files to the UPGRADE directory, except for one.
NOTE: There are several procedures you could use for file transferring. For example, you could alternately decompress the upgrade file into on the server, delete the sites folder, and then copy the original site folder into the new directory. Either way, you want all your old sites folder and all brand new core files. Don’t forget any htaccess or robots.txt files from the original site as well.
The problem with this for beginners, is trying to copy and transfer files in the sites/default directory. The default directory permissions may be 555 and the settings.php file 444, so a copying and saving things there might fail. You need to deal with the permissions in the sites directory. You will need to CHMOD all the folders recursively from sites on down to 755. You will also need to make all the files at least 644 (especially the settings.php file). Change them back when you’re done for security.
If you try to visit your test site, by going to your URL you will see that it is offline.
Step 10. Login again
Login to your site’s admin by going to http://yourSite.com/user?locallogin. (in my case http://yourSite.com/UPGRADE/user?locallogin. Enter the username and password for User 1.
Step 11. Run update.php
Once you are logged in, enter http://yoursite.com/update.php (in my case it’s /UPGRADE/update.php) You must be logged in as user 1 to begin the upgrade. Otherwise you will get a message telling you how to edit the configuration file to allow the update to proceed.
Click Continue. If you made the backup before you started you don’t have to do it again.
The image above shows a successful update response. If you get error messages at this point you need to try to correct them before moving on.
Step 12. Enable all the installed modules.
- Return to Administration Pages.
- Go to Site building > Modules.
- Place checks next to all the modules you want to activate.
- Scroll to the bottom of the page and Save.
- Run update.php AGAIN to update the database tables for the modules.
Step 13. Run update.php after module installation
This time you can run update.php from a link on the modules page.
Step 14. Run Reports – Available Updates
Go to Reports > Available updates. Everything should be green, and your new version number should be visible. If anything needs to be updated you’ll spot it here and be able to download the newer version.
Step 15. Give it a test run.
It would be a good idea to give it a test run at this point and check out some common tasks.
- Create content.
- Upload files.
- Check for broken links.
- Check out all your modules and make sure everything is running correctly.
If everything is OK, you can now you can activate your theme. I usually do a check before I introduce the theme to keep the number of variables to a minimum.
Step 16. Activate or upload your custom theme.
- Go to Site building > Themes.
- Upload or activate a theme.
- Run update.php again.
- Transfer and test any edits or hacks you made to module or themes. Make sure you have the correct .htaccess file and robots.txt file and any others you need.
- Do a thorough final check of the test site.
- After that you’re ready to go live.
Step 17. Put your site back Online
Go to Administer > Site configuration >Site Maintenance as you did in Step 4. and change the Site status back to Online.
Save the configuration.
If all is going well you are ready to open to the public. Move your newly updated site to your main directory.
TIP: Move or copy your old site to a backup directory instead of deleting it. It makes for an easy recovery if something breaks.
Question: If I do all this on my Development server, do I need to repeat the steps on my Production server or just FTP everything up & restore the database?
You could either repeat this on production or migrate all the files and the database.
Thanks Steve. Love the [url=http://ostraining.com]ostraining.com[/url] website!!
You’re welcome, Bazinga 🙂
Should I run update.php after I restore the Production DB from my Development server or should it be all set?
Not needed if you copied over both the files and the database.
Hummm, did not work for some reason, everything stayed the same on my Production site, neither the Drupal core or the modules got updated?
Not sure what I did wrong.
Ok, ran it again and the Drupal core was updated but not the Modules that required updates, I know how to fix that. Sorry to bother you.
I am attempting to do a Drupal 6.33 update, and I’ve been having
trouble since 6.31….I have done repeated updates and checked dates to
see that the files I’ve updated are current, and yet my Available
Updates page refuses to update. It keeps telling me I have security
updates to run, and I’ve run them multiple times!!!
you know what could be causing this and HOW to fix it? and on modules
page, it still says I’m running the 6.30 Core. But I’ve updated to 6.31,
then 6.33, when it just came out.