Backing Up the Database and Files

Keeping regular backups of your database is essential if you want to be able to restore your site after something has gone wrong. Your hosting provider might do this for you, but it's still a good idea to keep your own copies in case something catastrophic happens.

There are several plugins you can use to back up your database right from the WordPress administration screens. My favorite is WP-DB-Backup. Once you've installed it, you'll find a new Backup item under the Tools menu. On the plugin's screen, you'll see checkboxes for each of the tables in your WordPress database. A standard installation will look like Figure 11-15. If your plugins have added tables of their own, those will be shown in the column on the right, and you can choose which ones you want to include in the backup. If you have several installations of WordPress sharing a single database with different table prefixes, the tables with the other prefixes will also appear on the right.

To make a backup, simply check the tables you want to include, decide whether to include spam comments and post revisions, and choose your destination. If you save the backup to the server, a gzipped SQL file will be saved to the directory shown (a subdirectory of wp-content).

Figure 11-15. Backing up the database with the WP-DB-Backup plugin
Figure 11-16. Scheduling options with WP-DB-Backup plugin

The lower half of the plugin's option screen (Figure 11-16) lets you schedule regular backups. However, these backups must be emailed to you. Make sure the email account you enter here can handle a lot of attachments (unless you're diligent about deleting old copies when the new one comes in.) The compressed file is not all that large, but over time the size will add up.

■ Note: As of this writing, WP-DB-Backup hasn't been updated for WordPress 2.9, so it doesn't automatically back up the new *_commentmeta table. Be sure to check off that table when you make your backups.

To restore from one of these backups, you'll need some sort of interface to your MySQL database other than WordPress itself. If your host offers PHPMyAdmin, for example, you could go to the Import tab and upload your backup file. Check your host's documentation to see how you can import SQL files into your database.

Don't forget to back up your files, too. Your uploaded media files probably wouldn't be very easy to replace, and if you've made any changes to your theme, you'll need copies of those, too. In general, it's a good idea to keep backups of your entire wp-content directory. You can automate this process with a tool like rsync ( if you're feeling geeky, but I just use my FTP client's synchronize feature to download an updated copy every time I log in to make a change.

Was this article helpful?

0 0

Post a comment