Useful tips about How to backup Drupal installation


Drupal is one of the big three CMS. Together with WordPress and Joomla offers a complete solution to build a working website in a few hours with minimum knowledge about PHP, HTML or CSS. If you already run a few Drupal powered websites, you should think about its backups. Beware of hackers, server failures or your own errors.

There are many ways how to make a Drupal database and filesystem backup. I will show you a few tips how to do this backup in relatively user friendly way. If you run some really big website you should use your webhoster backup solutions (like cPanel backup in Hostgator) or do the backup manually using the mysql and gzip commands.

1. Install the DB Maintenance module

Before you will start any database backup in your Drupal installation, I highly recommend to optimize and repair your database tables. This will help to speed up your website and, what’s maybe more important, the database backup will be smaller. Install the DB Maintenance module.

After the installation go to the Site Configuration, DB Maintenance. Enable the Attempt REPAIR of table if OPTIMIZE is problematic option and select all tables in your database. Don’t forget to go here after a new module installation and add the new tables to optimization process.

Select the optimization interval (Weekly is enough) and take a look below the tables list. There are some options about database and files backup. Select the backup interval for database and files. Check the paths, provide your e-mail address for notification and save the settings.

Very important: To check how the Drupal backup with this module works, set up the backup for each cron run and after saving the configuration, run the cron.php process. After that, check the output folder for backup. If you don’t see file called like 20090220_10-46-13_maxiorel_maxiorelcom_db.sql you have to check the path settings. The common problem is wrong backup folder specified. For example, Hostgator users should use the server path. Since you don’t have access to /tmp folder you have to use /home/yourname/tmp folder.

Security info: Do not save the backup to public folder visible from web browser!

2. Backup Files module

This is another backup solution, but it works only with your Drupal files. Since you have backup them to your computer very easily via FTP, I don’t think that this module will be very useful for you. What’s very important, this module doesn’t backup your Drupal’s database. And without database are your files useless.

But if you can try Backup Files module, enable it and go to the Content management, Backup Files. Specify the directories you would like to backup. The files folder is default, I recommend to add your own themes, so the sites/all/themes folder and maybe the sites/all/modules too. The rest can be restored using the Drupal installation package, so you don’t have to backup it each time.

Don’t forget to set up the paths and try to Test settings using the appropriate button.

Note: There are some situation, when the DB Maintenance couldn’t be used but the Backup Files will do the backup job. More info is below.

3. Backup and Migrate

The last backup module I would like to mention is Backup and Migrate. This module is intended to users who are preparing to move their Drupal installation from one webhosting to another. Enable this module and go to the Content Management, Backup and Migrate. There are four tabs available.

Backup/Export DB – select tables you would like to exclude (I do not recommend) and tables which content you would like to exclude (I recommend accesslog and all cache_ tables). Provide the backup file name (using replacement patterns), set up the compression and click the backup Database. You backup will be created immediately.

Restore/Import DB – if you have moved to the new server, upload here your previously created backup. Remember, that this feature is useless for most of the websites, since the database backup are often bigger than maximum file size for upload.

Saved Backups – this feature will allow you to work with backups created in the past and optionally restore them. The backup files has to be in your backup directory.

Backup Schedule – only two options are available here. Provide the number of each hours the backup is created and the number of old backups to be kept.

Think about your needs

Each of the Drupal modules mentioned above is intended to another user or solution. For regular backup I highly recommend the DB Maintenance, because it could run on scheduled interval and backup the files together with databases.

Backup Files module is useful when you would like to create the backup of your files and download the directly via the web browser.

And finally, if you are going to server migrate process, you will find the Backup and Migrate module useful.

The differences between files backups in DB Maintenance and Backup Files module is in using the command to create a backup. The DB Maintenance uses the tar command and create the tar.gz files with better compression. The Backup Files module uses Archive_Tar from PEAR Package and can be run where you don’t have access to the tar command directly.

I hope that this article is useful for you and help you to decide which Drupal backup solution is right for you. If you are interested in another Drupal related articles, I recommend you my another website at (English) or (video tutorials for Drupal, but here only in Czech).