"""Subversion plugin for backup.py. Hotcopy's are performed via the svnadmin command: svnadmin hotcopy /repos/path /path/to/dest """ import plugins config = False location = '' nlocations = [] def init(cfg, *args, **kwargs): global location, nlocations, config config = cfg if len(args) != 1: if kwargs.has_key('location'): location = kwargs['location'] else: raise plugins.PluginError else: location = args[0] nlocations = plugins.normalize_path(args[0], cwd=False) def pre(): """Prepare a copy of the trac install using the hotcopy command.""" mkdir = "mkdir -p /tmp%s" cmd = "svnadmin hotcopy %s /tmp%s" if nlocations: for loc in nlocations: c = cmd % (loc, loc) print '>>>', mkdir % loc plugins.print_exec(mkdir % loc) print '>>>', c plugins.print_exec(c) else: print '>>>', mkdir % loc plugins.print_exec(mkdir % loc) c = cmd % (location, location) print '>>>', c plugins.print_exec(c) def run(): """Backup all of the svn copies in /tmp. Read the rsync manpage in the 'relative' section to see why, but we want to run rsync with the source /tmp/./path/to/svn""" rsync = config.rsync() dest = config.destination() # we want rsync + source + dest def source(loc): return '/tmp/.%s ' % loc if nlocations: for loc in nlocations: c = rsync + source(loc) + dest print '>r>', c plugins.print_exec(c) else: c = rsync + source(location) + dest print '>r>', c plugins.print_exec(c) def post(): global config, location, nlocations cmd = "rm -r /tmp%s" if nlocations: for loc in nlocations: c = cmd % loc print '<<<', c plugins.print_exec(c) else: c = cmd % location print '<<<', c plugins.print_exec(c) config = False location = '' nlocations = []