Backing Up Your TYPO3 Sites

An important part of managing any Web site is having a comprehensive backup and recovery strategy. As far as I can tell, though, nobody has ever taken the time to write up what such a strategy should look like for those of us who manage one or more TYPO3 sites. So I thought I’d share my backup approach, which has evolved over time into a relatively simple system that I have used to recover complete sites from backup successfully. It’s also useful for migrating TYPO3 sites from one server to another.

(One caveat: I’m assuming that, like most people, you use the dummy site package as the basis for your TYPO3 sites’ directory layout. If you don’t, these instructions might need some modification to work properly for you.) 

First, make a list of all the TYPO3 sites you’re running; you’ll want to go through the following steps for each of them.  Then grab a copy of the application source and dummy site packages for your version of TYPO3 from typo3.org; you’ll want to include those in your backup. (You should keep copies handy locally at all times, in case typo3.org is inaccessible when you need them.)

Here’s the plan you’ll follow for each of your sites:

  1. The first thing we’re going to do is back up the database for the site. Assuming your backend is MySQL and you’re using the standard MyISAM tables, you can do this with the mysqldump utility, like so:

    mysqldump -u db-username -p -h database-hostname -D name-of-database >  mysite.sql

  2. Now we’re going to back up your site’s TYPO3 files.  Because many of the "core" files come in the dummy site package, you don’t need to back up the entire site directory. You only need to backup the five things that contain material specific to your site:
    • The /fileadmin directory
    • The /typo3conf directory
    • The /uploads directory
    • The .htaccess file (if you use one)
    • The robots.txt file (if you use one)

    You can dump all of these into a single bzip2-compressed archive file with the tar command:

    tar -cjvf mysite.tar.bz2 -C path-to-your-site-root-directory fileadmin typo3conf uploads .htaccess robots.txt

Once you have these two files — a SQL dump of the database, and an archive of the site-specific files — you have everything you need to restore your site from scratch. (For multiple sites, the steps above are easily cron-able so that you can keep, say, 7 days’ worth of backups for each site.) If you’re worried about the two files getting separated, just tar them together into a single archive for easy storage.

Should you ever need to recover from backup, it’s simple if you used the above method:

  1. Install core TYPO3 application from source package
  2. Create directory for site to recover with dummy site package
  3. Un-tar the backup file archive into the directory you created with the dummy package so that the files fill the appropriate directories
  4. Clear out the old database, re-fill it with the MySQL dumpfile

The same process works if you’re migrating to a new server — just remember to check the file typo3conf/localconf.php when you’re done and update any server-specific settings to use the address of the new server.

UPDATE: It occurred to me this afternoon that there’s one potential extra step I left out. Most people will never deal with it, because they install their TYPO3 extensions as local extensions, like they should. But if you have installed any extensions as "system" or "global" extensions, you will need to back them up separately from your sites (these extensions are installed in the TYPO3 source directory, not your site’s directory).  So be sure you back up  typo3src/typo3/ext and typo3src/typo3/sysext if you’ve stored anything there.


Comments

Surjit Sidhu

October 22, 2010
4:32 am

i have bugs on site how to fix them