7 min read

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.

LEAVE A REPLY

Please enter your comment!
Please enter your name here