Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1

Exclusive offer: get 50% off this eBook here
Drupal 6 Site Builder Solutions

Drupal 6 Site Builder Solutions — Save 50%

Build powerful website features for your business and connect to your customers through blogs, product catalogs, newsletters, and maps

$26.99    $13.50
by Mark Noble | August 2009 | Drupal Open Source

In this two-part article by Mark Noble, we will explore various maintenance tasks to keep our site operating at peak performance. We will begin by discussing how to back up our web site and then restore it again, to protect it against hardware failures or malicious users. Next, we will discuss performance tuning to ensure that your site can meet any level of traffic demand. Finally, we will review managing and moderating content. At the end of the article, you will be prepared to publish your web site to the world, knowing that you are prepared for anything.

We will consider the example of an imaginary web site created for a restaurant called Good Eatin' Bistro. Chef Wanyama is the owner of the Good Eatin' Bistro, a popular upscale restaurant. You can check this web site at http://goodeatin.drupalbyexample.com/.

Web site backups

A strong backup plan is critical for any successful web site. A good backup plan will protect against hardware failure, allow you to transfer your web site to another host, and allow you to recover from malicious hacking into your web site.

When you create a backup plan, you should also test the restoration from this backup to make sure that the backup works correctly.

In this section, we will explore ways of performing backups regardless of the host that you are using. Your hosting provider may also offer a solution that will back up files and databases either one time, or on a recurring basis. If your host does provide backup capabilities, you should review them to see if they suit your needs completely, or if you want to augment them or replace them with the techniques in this section.

Manually backing up a site

Good Eatin' Goal: Back up the web site without using a custom backup module.

Additional modules needed: None.

Basic steps

If you do not want to use a dedicated module to perform your backups, you can manually download the files and the database information that make up the site. However, this can be more time-intensive and error-prone than using a custom backup module.

A manual backup has two steps, in which you must first back up the files that make up the site and then back up the database information.

To back up the files for the web site, use the following procedure:

  1. Begin by opening the utility that you use to transfer files to the web site. This could be an FTP client, or an online file manager. My favorite FTP client is FileZilla, which is a freely-available open source client. The FileZilla client can be downloaded from http://filezilla-project.org/.
  2. Select the backup location on your local computer to which you want to copy the files, and select the root directory of your web server as the remote directory. You may want to date the backup folder so that you can maintain a history of the site.
  3. Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1

  4. Next, download the files to your local directory. If you want, you can compress the files into a ZIP file or a compressed archive.
  5. To reduce the amount of data that you need to download, you should be able to download just the sites directory, because that folder contains all of the custom files, pictures, themes, and modules that you have added to the site.

To back up the database information, you can use your web site provider's database management utility. Many hosts provide phpMyAdmin for this purpose. If you are unsure whether or not your host gives you access to phpMyAdmin, you can contact their customer support group to check.

  1. Begin by opening phpMyAdmin and selecting the database that has your site information within it. The screen should be similar to the following:
  2. Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1

  3. If you have multiple databases available on the host, you may need to select the database that you want to work with in the drop-down list at the upper left corner of the screen.
  4. Next, select the Export tab at the top of the screen. phpMyAdmin will prompt you to select the tables that you want to download and the format that you want to download in, as shown in the following screenshot:
  5. Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1

  6. If you want to be able to rebuild the database at a later time, you should export all the tables in SQL format.
  7. Next, you will need to specify the name of the file to download to. You can use __DB__ as the database name.
  8. Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1

    You may want to zip the file to reduce storage space.

  9. Then click Go to begin the download process. You will be prompted for the location to which you want to save the exported data.

When you are ready to restore the web site from backup, you simply reverse the process.

  1. You should always import into a blank database, to avoid conflicts with existing data. You can either drop or delete all of the titles in the existing database, or you can create a new database to import the data into.
  2. After you have cleaned out your database, select the Import tab in phpMyAdmin.
  3. Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1

  4. Now navigate to the file that you exported earlier, and click Go to begin the import. You may need to delete all of the tables in the database before you import the data, depending on the options you chose when you exported the data.
  5. To reload the files, simply open your FTP client, select the same directories that you used when creating the backup and then upload the files, rather than downloading them.

Automatic site backups

Good Eatin' Goal: Back up a web site so that it can be stored for easy recovery.

Additional modules needed: Backup and Migrate (http://drupal.org/project/backup_migrate).

Basic steps

Although you can manually back up your files and database, this process can be time-consuming and error prone. Luckily, the Backup and Migrate module makes this process easier, and optimizes the backups to exclude unnecessary data.

  1. Begin by downloading and installing the Back up and Migrate module.
  2. You can now back up your data by selecting Content management and then Backup and migrate, from the Administer menu.
  3. The Backup and Migrate module allows you to fully customize the backup files that are created. You can control which tables are included in the backup, and whether or not the data in the table is backed up. By default, the Backup and Migrate module does not back up cache information, session information, or watchdog information, because data in these tables is temporary and can easily be re-created.
  4. Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1

  5. There are a variety of other options that you can choose from, which control how the resulting file is named, how it is compressed, and where it is compressed to.
  6. Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1

  7. Once you have set the options as desired, click Backup Database to begin the backup process. If you have selected the Download option, the file will be sent to your computer so that you can store it. If you select the Save to Files Directory option, the backup file will be saved onto the server so that you can download it later, either directly from the server or using the Saved Backups tab.
  8. Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1

  9. If you would like the Backup and Migrate module to back up your database automatically on a regular basis, you can schedule the back up to occur at specified intervals by clicking on the Backup Schedule tab, as shown here:
  10. Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1

Please note that the backups created by the Backup and Migrate module do not include the files from the site, so you will still need to back up these files independently. You can minimize the backup file size by only backing up the files that the users can upload. These files are typically stored in the files directory. The process for backing up files is identical to the process used in the section on manual backups.

Restoring a site from a backup

Good Eatin' Goal: Restore information from a backup file created by the Backup and Migrate module.

Additional modules needed: Backup and Migrate (http://drupal.org/project/backup_migrate).

Basic steps

Restoring a backup created by the Backup and Migrate module is a simple process.

  1. Navigate to the Backup and Migrate manager by selecting Content management and then Backup and Migrate, from the Administer menu.
  2. Next, click on the Restore/Import DB tab.
  3. Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1

  4. Navigate to the location of your backup file.
  5. After you have selected the backup file, click on Restore Database to begin the restore process. Please read all displayed warnings carefully, and make sure that you test the import on a test installation for your site before running it on your production site. If you are sure that you want to proceed with the import, agree to the confirmation and click restore.
  6. Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1

  7. You may also need to import any saved files, if the server file system is not fully up-to-date. We discussed this previously in the section on manual backups.
Drupal 6 Site Builder Solutions Build powerful website features for your business and connect to your customers through blogs, product catalogs, newsletters, and maps
Published: December 2008
eBook Price: $26.99
Book Price: $44.99
See more
Select your format and quantity:

Web site optimization

If your web site has a moderate to large number of visitors, you should tune your web site for maximum performance. This will ensure that all your visitors have a positive experience, and are not frustrated by delays in loading pages or accessing the web site.

We will discuss ways to optimize both the back end database, and the front end of the web site that displays the information to the visitor.

Optimizing the database tables

Good Eatin' Goal: Optimize the database where your site content is stored, to ensure the best possible performance.

Additional modules needed: DB Maintenance (http://drupal.org/project/db_maintenance).

Basic steps

When a database is used as frequently as the Drupal database is, it can become less optimized over time, because having a large number of records inserted and deleted from each table can result in the database having wasted space. All databases will allow you to run an optimization process that removes unused space and rebuilds the indexes to make the search for information faster.

The DB Maintenance module can automatically perform the optimization process for you when cron is run.

  1. Begin by downloading and installing the DB Maintenance module.
  2. You can edit the settings for the DB Maintenance module by selecting Site configuration and then DB maintenance, from the Administer menu.
  3. The settings allow you to control several options, including:
    • Whether or not to write to the log when each optimization is performed.
    • Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1

    • How often the tables are optimized, with options from hourly to bi-monthly, or at each cron run.
    • Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1

    • Finally, you can control which tables are optimized. This allows you to not optimize tables that do not change frequently, which will allow the maintenance task to complete faster.

Once you have configured the settings properly, you simply save the settings, and the DB maintenance module will automatically perform the optimization at the specified intervals.

Using caching to improve performance

Good Eatin' Goal: Use caching to improve the performance of content display.

Additional modules needed: None.

Basic steps

Because dynamically-generated pages, such as those created with Drupal, can be time-consuming and resource-intensive to generate. Drupal uses a sophisticated caching mechanism to pre-load sections of content for display to users.

To set up the Drupal cache, carry out the following steps:

  1. Access the settings for the Drupal cache by selecting Site configuration and then Performance, from the Administer menu.
  2. The first section of settings relate to the Page cache, which is used to cache entire pages of data. The Page cache system will only cache pages for anonymous users, to prevent personal data for one user being made visible to other users, and also because it is simpler to ensure that the pages are successfully cached only if anonymous users are served cached content.
  3. Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1

    Most sites should enable Normal caching as this can significantly improve load times for your visitors without any possibility of adverse side effects.

  4. If you choose to use Aggressive site caching, you need to be aware of any modules that may have problems. Drupal will identify these modules for you and highlight them in red. You should only enable the Aggressive cache if there are no potential incompatibilities, or if the module maintainer of a potentially incompatible module states that the module is acceptable for use with Aggressive caching. Some modules are not compatible with Aggressive mode due to the initialization or cleanup code that is run when a page is loaded normally, but not when it has been aggressively cached.
  5. If your site is exceptionally busy, you may want to enforce a minimum cache lifetime, which is the minimum amount of time that Drupal will wait for, before rebuilding cached pages. If your site receives infrequent updates, you may see a performance benefit by increasing this number to match your update schedule.
  6. Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1

  7. The Page compression controls whether or not the cached pages are compressed. This can be left as Enabled unless your web server automatically caches all web pages.
  8. Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1

  9. Drupal also provides a Block cache, which caches just the content of the blocks rather than the entire page. Unlike the page cache, the block cache works for both anonymous users as well as users who have logged into the site.
  10. Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1

  11. The final type of optimization provided by Drupal relates to minimizing the amount of content that is sent to the user, by combining the CSS files and JavaScript files created by each module into a single CSS file and a single JavaScript file, which can be downloaded once by the user. These options are disabled if you are using the private filesystem. If you want to make use of these options, you will need to use the public filesystem on your site.
  12. Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1

  13. Although Drupal caching makes your site faster and gives users a better experience, it can interfere with your development of the web site because the cache may prevent you from seeing the most recent changes to your site. If this is the case, you can clear the cached data by clicking on the Clear cached data button.
  14. Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 1

>> Continue Reading Maintaining, Optimizing and Upgrading Your Site in Drupal 6: Part 2

 

[ 1 | 2 ]
Drupal 6 Site Builder Solutions Build powerful website features for your business and connect to your customers through blogs, product catalogs, newsletters, and maps
Published: December 2008
eBook Price: $26.99
Book Price: $44.99
See more
Select your format and quantity:

About the Author :


Mark Noble

Mark Noble has worked in software development and website design for over 13 years in a variety of capacities including development, quality assurance, and management. He takes pride in developing software and websites to make businesses run more effectively and delights in helping users to get their jobs done more easily.

Mark currently works developing websites to help libraries manage their books. He also does occasional contract work for clients in a variety of industries.

When he isn’t in front of a computer, Mark enjoys playing with his family, photography, and geocaching.

Books From Packt

Papervision3D Essentials
Papervision3D Essentials

WordPress MU 2.7: Beginner's Guide
WordPress MU 2.7: Beginner's Guide

Joomla! 1.5x Customization: Make Your Site Adapt to Your Needs
Joomla! 1.5x Customization: Make Your Site Adapt to Your Needs

Learning Ext JS
Learning Ext JS

Joomla! 1.5 SEO
Joomla! 1.5 SEO

Drupal 6 Content Administration
Drupal 6 Content Administration

JasperReports 3.5 for Java Developers
JasperReports 3.5 for Java Developers

PHP Team Development
PHP Team Development

 

 

No votes yet

Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Y
D
d
i
j
g
Enter the code without spaces and pay attention to upper/lower case.
Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software