sysadmin-bin r80 - trunk



Author: ovitters
Date: Mon Oct 27 22:35:35 2008
New Revision: 80
URL: http://svn.gnome.org/viewvc/sysadmin-bin?rev=80&view=rev

Log:
	* svn-migrate-repos (added): Does a dump + restore of an repository.
	Still in testing. Intention is to allow upgrade of SVN repository
	format with minimal downtime.



Added:
   trunk/svn-migrate-repos   (contents, props changed)
Modified:
   trunk/ChangeLog

Added: trunk/svn-migrate-repos
==============================================================================
--- (empty file)
+++ trunk/svn-migrate-repos	Mon Oct 27 22:35:35 2008
@@ -0,0 +1,69 @@
+#!/usr/bin/python
+#
+#  hot-backup.py: perform a "hot" backup of a Berkeley DB repository.
+#                 (and clean old logfiles after backup completes.)
+#
+#  Subversion is a tool for revision control. 
+#  See http://subversion.tigris.org for more information.
+#    
+# ====================================================================
+# Copyright (c) 2000-2006 CollabNet.  All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution.  The terms
+# are also available at http://subversion.tigris.org/license-1.html.
+# If newer versions of this license are posted there, you may use a
+# newer version instead, at your option.
+#
+# This software consists of voluntary contributions made by many
+# individuals.  For exact contribution history, see the revision
+# history and logs, available at http://subversion.tigris.org/.
+# ====================================================================
+
+######################################################################
+
+import sys, os, getopt, shutil, string, re, subprocess, glob
+import os.path
+
+######################################################################
+# Global Settings
+
+# Path to svnlook utility
+svnlook = "/usr/bin/svnlook"
+
+# Path to svnadmin utility
+svnadmin = "/usr/bin/svnadmin"
+
+if __name__ == '__main__':
+    orig, backup, tmp = sys.argv[1:]
+    
+    for origsvn in glob.glob('%s/*' % orig):
+        if not os.path.isdir(os.path.join(origsvn, 'hooks')):
+            continue
+
+        latestrev = subprocess.Popen(["svnlook", "youngest", origsvn], stdout=subprocess.PIPE).communicate()[0].strip()
+        svnname = os.path.basename(origsvn)
+
+        tmpsvn = os.path.join(tmp, svnname)
+        backupsvn = os.path.join(backup, svnname)
+        if os.path.isdir(tmpsvn) or os.path.isdir(backupsvn):
+            print 'ERROR: Path already exists: %s' % svnname
+            continue
+
+        # Setup new repository
+        subprocess.check_call(['svnadmin', 'create', tmpsvn])
+        subprocess.check_call(['chown', '-R', '--reference', origsvn, '--', tmpsvn])
+        subprocess.check_call(['chmod', '-R', '--reference', origsvn, '--', tmpsvn])
+        subprocess.check_call(['find', tmpsvn, '-type', 'f', '-exec', 'chmod', '-x', '{}', ';'])
+        subprocess.check_call(['find', '%s/hooks' % tmpsvn, '-type', 'f', '(', '-name', '*.tmpl', '-prune', '-o', '-exec', 'chmod', '+x', '{}', ';', ')'])
+
+        # Dump old repository into new one
+        p_dump = subprocess.Popen(['svnadmin', 'dump', '-q', '--incremental', '--deltas', origsvn], stdout=subprocess.PIPE)
+        p_load = subprocess.Popen(['svnadmin', 'load', '-q', '--force-uuid', tmpsvn], stdin=p_dump.stdout)
+        p_dump.wait()
+        p_load.wait()
+        
+        latestrev2 = subprocess.Popen(["svnlook", "youngest", origsvn], stdout=subprocess.PIPE).communicate()[0].strip()
+        
+        print svnname, latestrev, latestrev2
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]