Category: Content Management with TYPO3
Wednesday, May 16, 2007
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:
mysqldump -u db-username -p -h database-hostname -D name-of-database > mysite.sql
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:
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 typo3_src/typo3/ext and typo3_src/typo3/sysext if you've stored anything there.
Except where otherwise noted, all content on this site is provided under the terms of the Creative Commons Attribution-ShareAlike license.
If you think anything I write here represents the opinions of anybody but myself, you need more help than I can give you. The opinions are all mine, folks. Nobody else's.
If that's too hard to understand... well, I'm sorry. There's only so much I can do. I'm not a therapist, and I'm not a miracle worker. I wish I could help you work through your delusional belief that I'm speaking for anyone else but myself. Honestly, I do. But in the end, that's a monkey you'll have to get off your back on your own. Sorry.
Leave a comment