(See also Copying a Plone site)
What to backup?
You should backup at least:
- Your content. This usually resides in the Zope database file Data.fs in the var directory of your Zope instance. If you're using BLOB storage (which became a default in Plone 4 for Images and Files), you'll have to backup also the blob-objects. They are stored by default in the var/blobstorage folder of your buildout.
- Customizations you may have made on the file system.
- All products that are installed. These are required to restore your site in a fresh Plone installation. Backup the entire Products directory of your Zope instance, as well as any directories where symbolic links in Products may be pointing to. You don't necessarily need to backup products that you can restore from archives on the Internet (such as Plone's SVN). However, when you need to restore from backup, you'll require the same versions of the products that are used in your websites on the backup. Backing up the products is fail-safe and does not depend on external archives.
- External methods in the Extensions directory of your Zope instance.
- Your Zope configuration file (usually zope.conf in the etc directory of your Zope instance).
- Your custom translation files (usually in the i18n directory of your Zope instance).
Most of these files can simply be copied to a backup server or medium (for example, by means of a daily rsync of your zope instance). The database file Data.fs is an exception to this rule, however.
How to backup your content in the database file Data.fs
You should take special care when copying Data.fs, since this file can be modified when Plone is up and running during the backup operation. Although Plone (Zope actually) can usually recover the database file in that situation, there are some exceptions to this rule (such as when an undo or pack operation is in progress during the backup). We strongly recommend, therefore, that you backup Data.fs in one of the following ways.
- Use Repozo
- The recommended way to backup the database is to use Zope's
repozo.pyscript. In this way you can perform a safe and automated backup while Plone is running, without side-effects on your data. It's generally considered the best practice for backing up Zope/Plone in a production environment.
Repozo can be used to create a full backup of the database. Since Plone stores its data in a single large binary file, creating a daily full backup may consume too much storage and network resources. In that case, you can also use Repozo to create an incremental hot backup of the database.
More information about Repozo can be found in Backing up FileStorage files on Zope's website. The
repozo.pyscript can be found in the bin directory of your Zope software installation. It contains an informative docstring about its command line options.
Collective.recipe.backup is a good way to configure and manage repozo directly from your buildout file. It includes options for backing up both your data.fs file and Plone 4 blob storage.
- Shutdown Zope and backup the database
- The easiest way to safely backup the database is to stop (shutdown) Zope, copy Data.fs and restart Zope. This is simple and safe, but has the disadvantage that your sites are down during the backup process.
- Pack the database and backup the pre-pack copy
- Another way to safely backup Data.fs without bringing down your sites is to pack the database in the Zope management interface (ZMI): Control panel > Database management > Main > Pack. This leaves a file Data.fs.old with the previous contents of the database. Since Plone does not write to that file anymore after packing, it's safe to backup this file after packing while Plone remains running. Be sure to backup Data.fs.old and not just Data.fs.
Packing the database means reducing its size by deleting archived versions of stored objects, older than a specified age. After packing, you'll no longer be able to revert to these old versions by undoing transactions.