What is the suggested way to cron-automate ZODB packs for a production Plone instance?
Asked Answered
P

7

17

Looking at plone.org to find a way to periodically pack my instance's ZODB I could only find http://plone.org/documentation/faq/how-do-i-pack-the-zodb that doesn't talk about automated packs, but just manually initiated ones.

I know I can simulate the manual pack with wget or curl, but I'd like to know if that is the best practice in use for production sites.

Passus answered 14/3, 2011 at 15:41 Comment(0)
G
23

If you are using ZEO you can add the following to your Crontab to do this:

0 1 * * 6 <path-to-buildout>/bin/zeopack

If you don't want to do it manually, add this to your buildout.cfg and the crontab entry above will be added automatically when you run bin/buildout:

parts += crontab_zeopack

# pack your ZODB each Sunday morning and hence make it smaller and faster
[crontab_zeopack]
recipe = z3c.recipe.usercrontab
times = 0 1 * * 6
command = ${buildout:directory}/bin/zeopack
Guanabara answered 14/3, 2011 at 16:5 Comment(1)
I really think zeo should be the default: it has too many advantages over non-zeo setups. Thanks for the hint about z3c.recipe.usercrontab.Passus
W
6

If you do not use ZEO:

curl -X POST -d 'days:float=0' http://admin:admin@localhost:8080/Control_Panel/Database/main/manage_pack
Willette answered 15/3, 2011 at 9:21 Comment(0)
H
5

I do it like this (from https://raw.github.com/plock/pins/master/zeo):

[backup]
recipe = collective.recipe.backup

# Backup daily
[backups]
recipe = z3c.recipe.usercrontab
times = 0 0 * * * 
command = ${buildout:bin-directory}/bin/backup

# Pack once a month
[packups]
recipe = z3c.recipe.usercrontab
times = 0 0 1 * * 
command = ${buildout:bin-directory}/bin/zeopack
Hotspur answered 7/4, 2011 at 0:32 Comment(0)
T
2

You may want to check out collective.migrator. It has a pack_db recipe among others.

Trifacial answered 5/4, 2011 at 17:51 Comment(0)
D
2

Use zeopack for ZEO (see other answers), and zodbpack for RelStorage (included, see RelStorage docs). Both are easy to set up.

Dyaus answered 14/4, 2012 at 20:59 Comment(0)
M
1

For a python/urllib solution, see: http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/MaintainingZope.stx

#!/usr/bin/python
import sys, urllib
host = sys.argv[1]
days = sys.argv[2]
url = "%s/Control_Panel/Database/manage_pack?days:float=%s" % \
      (host, days)
try: 
    f = urllib.urlopen(url).read()
except IOError:
    print "Cannot open URL %s, aborting" % url
print "Successfully packed ZODB on host %s" % host
Merras answered 15/3, 2011 at 17:53 Comment(1)
The URL is wrong for modern Zope installations, it should be at least .../Database/main/manage_pack?... or have other database name as per your instance configuration.Buddleia
B
0

wget -O/dev/null -q --post-data='days:float=10' --user=adminuser --password=password http://localhost:PORT//Control_Panel/Database/main/manage_pack

If you prefer wget.

Bulletin answered 14/4, 2012 at 19:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.