Backing Up Your Site

If you don't do anything else on this list of administrative tasks, at least make sure that your data is safe and recoverable in the case of an unexpected disaster. It's easy to put off backing up your site, as it's likely that you'll rarely need to go back and restore your site from a backup. But speaking from experience, the first time you need to restore your site and you don't have a backup is the last time you won't have backups in place from the start. Take it from the voice of experience: the few minutes it takes to set up backups are well spent.

There are two paths to take to address backups on your new site: you can use utilities that your hosting provider gives to you to backup your database and directories, or you can use a Drupal module called "Backup and Migrate" to automatically back up your site on a defined schedule, and, just as important, to easily restore your site from a previous backup. Both approaches work equally as well, and the "Backup and Migrate" module is a perfect solution for those who are less inclined to use operating-system-level commands to schedule backups and to create the scripts necessary to back up your Drupal site.

You will need to install the module, because it is not part of Drupal core. You can find details for this module at www.drupal.org/project/backup_migrate. To install the module, follow the steps covered in Chapter 8.

To access the "Backup and Migrate" configuration page, go to http://localhost/admin/content/backup_migrate (note: replace "localhost" with the appropriate domain name if your site is not running on your local PC). After clicking Enter, you will see the configuration panel for the "Backup and Migrate" module.

The first step in configuring the "Backup and Migrate" module is to define where backup files will be stored on the server. Click on the Destinations tab at the top of the page, revealing the page shown in Figure 14-1. There are two settings for where files will be stored: one for manual backups, where the site administrator clicks on a "Backup now" link to perform the backup, and the automatic backup. I'll explain how to set up automatic backups in a minute. You can also set the database that you want backed up. By default, the module automatically detects the database that your site is running on and sets the parameter. You may choose to override the default directories and database that are set during the process of installing the module, or you may, as I do, leave the defaults.

Backup and Migrate o backup restore destinations profiles schedules be&tinailprts ."ire :he placesyehu can sa'.e yD'Jr haduip files to □ r the^> losd from.

+ Add Öestliutktn

NAME

TYPE

LOCATION

OPERATIONS

Manual Backups Directory

Server Directory

sites/default/private/files/bad<up_m ¡grate/manual

list files override

Scheduled Backups

Server

sites/default/private/files/backup_migrate

list files override

Directory

Directory

/scheduled

Default Database

MySQL Database

mys q 1: / / d [email protected] ocal host/d7

override

Figure 14-1. Setting the destination directories for backups

The next step is to set the schedule for automatic backups. To do so, click on the Schedules tab at the top of the page, revealing the configuration options shown in Figure 14-2. If you haven't set a schedule previously, the page will simply display an "Add schedule" link. Click on that link to view the parameters that you can set for scheduling backups. First, enter a name for the Schedule. We are going to set the backups to be performed on a daily basis, so enter "Daily backups" as the name. Next, set the "Backup every" field to 1 Day(s). Finally, set the "Number of backup files to keep" to 14, meaning Drupal will retain 14 days' of backups before deleting the oldest backup file and storing the newest file. This helps protect you from consuming massive amounts of disk space for old backup files. Set this value carefully. You may have legal requirements in your industry that require that you keep backup files for a certain number of days, weeks, months, or years. Finally, click the "Save schedule" button.

The number of backup Files to keep before deleting old ones. Use 0 to never delete backups„ Other files in the destination directory will get deleted if you specify a limit.

Choose where the backup file will be saved. Backup files contain sensitive data, so be careful where you save them. Create new destination

Figure 14-2. Setting up the automatic backup schedule

Drupal will now automatically back up the site on a daily basis. The last step is to perform a manual backup of your site. To do so, click on the Backup tab (see Figure 14-3). On the resulting page, select the Default Database as the database to back up, set the "to" option to the Manual Backups Directory (you can also select Download, which will download the backup to your local computer), and set the "using" option to Default Settings. Finally, click the "Backup now" button.

Backup and Migrate o backup restore destinations profiles schedules

B*Ttra 1 Advanced Backup

Use this form to run simple manual backups of your database, v si: the help page for more help using this module QUICK BACKUP

Backup from Default Database to Manual Backups Directory using Default Settings _*J Backup now

For more backup options, try the advanced backup page.

Figure 14-3. Manually backing up your site

When the backup is completed, Drupal will redisplay the screen with information including the name of the backup file that was generated, the directory where it was stored, and how long the backup took to execute.

Restoring a Backup

If, for some reason, you needed to restore your system to a previously backed up state, you can return to the "Backup and Migrate" administration page (http://localhost/admin/content/backup_migrate) and select the backup file to restore. Click on the Destinations tab, revealing the list of destination directories where backups are stored. See Figure 14-4.

Backup and Migrate o

DESTINATIONS

Destinations are the y nu can live your backup hies to or then load t + Add Destination

NAME

TYPE

LOCATION

OPERATIONS

Manual Backups Directory

Server Directory

sites/default/private/files/backup_migrate/manual

list files override

Scheduled Backups Directory

Server Directory

sites/default/private/files/backup_migrate/scheduled

list files override

Default Database

MySQL Database

mysql://[email protected]/d7

Figure 14-4. Listing the backup directories where backup files are stored

Because we backed up our system using the manual backup process, click on the "List files" link for "Manual Backups Directory," revealing the page shown in Figure 14-5.

<em dass="placeholderll>Manua! Backups Directorv</em> Files o

BACKUP RESTORE DESTINATIONS PROFILES SOIEDULE5

<em dass="placeholderll>Manua! Backups Directorv</em> Files o

BACKUP RESTORE DESTINATIONS PROFILES SOIEDULE5

FILENAME

DATE

ACE -r SIZE

OPERATIONS

Drupal 7DemoSite-20l0-Q4-Q9T21-38-52.mysql

Fri, 04/09/2010 - 21:33

5 min 702.81 KB

d™„i„d

restore

delete

Figure 14-5. The manual backups directory and the file to restore

In this example, we could restore our system to the state it was in at the time we did the manual backup by simply clicking on the Restore link for that backup file. If you have scheduled backups enabled and have not manually backed up your system, the process described would be identical, with the exception of selecting the "List files" link for the scheduled backups directory. Clicking that link would reveal a list of backup files that were automatically created based on the schedule that you set in the previous steps.

Backing Up the File System

The "Backup and Migrate" module only backs up the contents of your Drupal database. The Drupal installation itself, meaning Drupal core, all of the contributed modules you have installed, all of the themes you have installed, any customizations you have made to modules, and any files that users have uploaded will not be saved by the "Backup and Migrate" module.

There are several options for backing up the file system, starting with simply copying the entire Drupal directory to another destination (for example, downloading the site to your local PC if you are running on a hosted server), copying the Drupal directory to a USB/CD/DVD if you are running on your local desktop/laptop, or, in the case of a hosted environment, working with your provider to ensure that your Drupal directory is being backed up often enough to ensure minimal disruption in the case of a disaster. Whichever scenario you choose, you should back up the file system on a frequent basis if users are uploading and attaching files to content (even daily, just as you do with your "Backup and Migrate" schedule), and in a case where you do not allow file attachments and uploads, it is still a good idea to back up your file system on at least a weekly basis (due to module updates).

0 0

Post a comment