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

[PATCH] Convert hot-backup.py.in to use new svnadmin list-dblogs and list-unused-dblogs commands

From: Vladimir Berezniker <vmpn_at_tigris.org>
Date: 2003-08-27 18:24:38 CEST

Teaching the hot-backup.py to use svnadmin commands instead of Berkeley DB
utilities, in the hope for less chance of BDB version mismatches.

Log Message:
* tools/backup/hot-backup.py.in:
         Use svnadmin list-dblogs, list-unused-dblogs and recover subcommands
instead of Berkeley DB db_archive and db_recover utilities.

Patch:

Index: hot-backup.py.in
===================================================================
--- hot-backup.py.in (revision 6892)
+++ hot-backup.py.in (working copy)
@@ -30,12 +30,9 @@
  # Path to svnlook utility
  svnlook = "@SVN_BINDIR@/svnlook"

-# Path to db_archive program
-db_archive = "/usr/local/BerkeleyDB.4.0/bin/db_archive"
+# Path to svnadmin program with lsbdlogs subcommand
+svnadmin = "@SVN_BINDIR@/svnadmin"

-# Path to db_recover progrem
-db_recover = "/usr/local/BerkeleyDB.4.0/bin/db_recover"
-
  # Number of backups to keep around (0 for "keep them all")
  num_backups = 64

@@ -132,8 +129,7 @@
  ### Step 3: re-copy the Berkeley logfiles. They must *always* be
  ### copied last.

-infile, outfile, errfile = os.popen3(db_archive + " -l -h "
- + os.path.join(repo_dir, "db"))
+infile, outfile, errfile = os.popen3(svnadmin + " list-dblogs " + repo_dir)
  stdout_lines = outfile.readlines()
  stderr_lines = errfile.readlines()
  outfile.close()
@@ -143,27 +139,33 @@
  print "Re-copying logfiles:"

  for item in stdout_lines:
- logfile = string.strip(item)
- src = os.path.join(repo_dir, "db", logfile)
- dst = os.path.join(backup_subdir, "db", logfile)
- print " Re-copying logfile '" + logfile + "'..."
- shutil.copy(src, dst)
+ log_file = string.strip(item)

+ repo_dir_abs = os.path.abspath(repo_dir)
+
+ log_file_abs = os.path.abspath(log_file)
+
+ common_path = os.path.commonprefix([repo_dir_abs, log_file_abs])
+
+ log_file_rel = log_file_abs[len(common_path) + 1:]
+
+ dst = os.path.join(backup_subdir, log_file_rel)
+ print " Re-copying logfile '" + log_file + "'..."
+ shutil.copy(log_file, dst)
+
  print "Backup completed."

  ### Step 4: put the archived database in a consistent state and remove
  ### the shared-memory environment files.
-
-infile, outfile, errfile = os.popen3(db_recover + " -h "
- + os.path.join(backup_subdir, "db"))
+infile, outfile, errfile = os.popen3(svnadmin + " recover " + backup_subdir)
  stdout_lines = outfile.readlines()
  stderr_lines = errfile.readlines()
  outfile.close()
  infile.close()
  errfile.close()

-print "Running db_recover on the archived database:"
+print "Running svnadmin recover on the archived database:"
  map(sys.stdout.write, stdout_lines)
  map(sys.stdout.write, stderr_lines)

@@ -183,11 +185,11 @@
  fp.close()

-### Step 6: ask db_archive which of the live logfiles can be
+### Step 6: ask svnadmin lsdblogs which of the live logfiles can be
  ### expunged, and remove them.

-infile, outfile, errfile = os.popen3(db_archive + " -a -h "
- + os.path.join(repo_dir, "db"))
+infile, outfile, errfile = os.popen3(svnadmin + " list-unused-dblogs "
+ + repo_dir)
  stdout_lines = outfile.readlines()
  stderr_lines = errfile.readlines()
  outfile.close()

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Aug 27 18:51:52 2003

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.