Automating database backups
Of course, no one wants to perform manual backups on a regular basis.
On Mac OS X and Ubuntu Linux, we can use Buildout to configure a cron
entry for us. On Windows, since there is no cron
, we can use the Task manager (outside our Buildout) instead.
Using z3c.recipe.usercrontab on Mac OS X and Ubuntu Linux
To configure cron
entries with Buildout, you can use z3c.re.backup (http://pypi.python.org/pypi/collective.rec.recipe.usercrontab).
In 05-deployment-maintenance-cron.cfg
, we have:
[buildout] extends = 05-deployment-maintenance-backup.cfg parts += cron [cron] recipe = z3c.recipe.usercrontab command = ${buildout:directory}/bin/backup times = 0 0 * * *
We have added a cron
section, defined recipe
and command
we want to run, and the number of times
we want to run it. If you are not familiar with the cron
syntax, refer to the following:
Field |
Allowed values |
---|---|
Minute |
0-59 |
Hour |
0-23 |
Day of the month |
1-31 |
Month |
1-12 (or names, see below) |
Day of the week... |