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

[PATCH] tools/backup/hot-backup.py

From: Sander Striker <striker_at_apache.org>
Date: 2002-06-28 00:19:12 CEST

Hi,

Comments on this patch? I'm no python expert, so I'm looking for
feedback prior to commiting.

Sander

Log:
* tools/backup/hot-backup.py

  Require repos-path and backup-path to be passed as arguments instead
  of hardcoding them. This makes it possible to call the same script
  from post-commit for different repositories.
  Use the basename of the repos-path as the basis for a backup directory.

Index: ./tools/backup/hot-backup.py
===================================================================
--- ./tools/backup/hot-backup.py
+++ ./tools/backup/hot-backup.py Fri Jun 28 00:02:22 2002
@@ -22,19 +22,11 @@

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

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

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

-# Path to repository
-repo_dir = "/usr/www/repositories/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"
-
 # Path to svnadmin utility
 svnadmin = "/usr/local/bin/svnadmin"

@@ -45,6 +37,24 @@
 num_backups = 64

 ######################################################################
+# Command line arguments
+
+
+if len(sys.argv) != 3:
+ print "Usage: <repos_path> <backup_path>"
+ sys.exit(0)
+
+# Path to repository
+repo_dir = sys.argv[1]
+
+repo = os.path.basename(repo_dir)
+
+# Where to store the repository backup. The backup will be placed in
+# a *subdirectory* of this location, named after the youngest
+# revision.
+backup_dir = sys.argv[2]
+
+######################################################################

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

@@ -64,7 +74,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."
@@ -132,7 +142,7 @@
 # than the one we just created.

 kill_rev = int(youngest) - num_backups
-old_backup_subdir = os.path.join(backup_dir, "repo-bkp-" + `kill_rev`)
+old_backup_subdir = os.path.join(backup_dir, repo + "-" + `kill_rev`)
 if os.path.exists(old_backup_subdir):
   print "Removing old backup: " + old_backup_subdir
   shutil.rmtree(old_backup_subdir)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Jun 28 00:10:09 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.