How to limit the size of a subversion repository

Subversion allows you to run a script before a commit is made (pre-commit). If this script exits with a non-zero exit status then the commit is not allowed.

If our repository was located here:


Then we need to create a pre-commit hook file here:


This file needs to be executable and readable by the subversion (or apache user if using webDAV).

Any message that the script prints to STDERR will sent to the client committing.

The first argument passed to the script is the location of the repository.

The second is the revision number.

Here is an example script that will limit a repository size to 100 Megs:

#commit hook to limit the size of a repos

#max size for repos

MEGS=`du -sm $REPOS | sed -r "s/^([0-9\\.]+).+/\\1/"`

if [ "$MEGS" -gt "$QUOTA" ]; then
        #send error message to stderr
        echo "Repository is over ${QUOTA}M in size" 1>&2
        exit 1;
exit 0;

Last updated: 25/09/2006