[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Patch to hot-backup.py

From: Tim Moloney <moloney_at_mrsl.com>
Date: 2002-05-02 14:01:12 CEST

I don't know Python but I was able to modify hot-backup.py to accept
the name of the repository to backup. Hopefully, others will find it
useful.

--- hot-backup.py.orig Thu Apr 11 13:56:18 2002
+++ hot-backup.py Thu May 2 07:51:31 2002
@@ -1,8 +1,12 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
  #
  # hot-backup.py: perform a "hot" backup of a Berkeley DB repository.
  # (and clean old logfiles after backup completes.)
  #
+# Modifications from version distributed with Subversion:
+# - accept a command line argument to specify which repository
+# to backup
+#
  # Subversion is a tool for revision control.
  # See http://subversion.tigris.org for more information.
  #
@@ -22,18 +26,18 @@

  ######################################################################

-import os, shutil, string
+import sys, os, shutil, string

  ######################################################################
  # Global Settings

  # Path to repository
-repo_dir = "/usr/www/repositories/svn"
+base_repo_dir = "/var/svn"

  # Where to store the repository backup. The backup will be placed in
  # a *subdirectory* of this location, named after the youngest
  # revision.
-backup_dir = "/usr/backup"
+backup_dir = "/var/backup/svn"

  # Path to svnadmin utility
  svnadmin = "/usr/local/bin/svnadmin"
@@ -46,8 +50,18 @@

  ######################################################################

-print "Beginning hot backup of '"+ repo_dir + "'."
+if len(sys.argv) < 2:
+ print "usage: svn-backup <repo>"
+ sys.exit(0)
+
+repo = sys.argv[1]
+
+repo_dir = os.path.join(base_repo_dir, repo)
+if not os.path.exists(repo_dir):
+ print "repository does not exist:", repo_dir
+ sys.exit(0)

+print "Beginning hot backup of '"+ repo_dir + "'."

  # Step 1: get the youngest revision.

@@ -64,7 +78,7 @@

  # Step 2: copy the whole repository structure.

-backup_subdir = os.path.join(backup_dir, "repo-bkp-" + youngest)
+backup_subdir = os.path.join(backup_dir, repo + "-" + youngest)
  print "Backing up repository to '" + backup_subdir + "'..."
  shutil.copytree(repo_dir, backup_subdir)
  print "Done."

-- 
Tim Moloney
ManTech Real-time Systems Laboratory
2015 Cattlemen Road                             \     /
Sarasota, FL  34232                     .________\(O)/________.
(941) 377-6775 x208                        '  '  O(.)O  '  '
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu May 2 14:02:36 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.