My first programming expirience in Python, please be kind. :)
Log Message:
* tools/backup/hot-backup.py.in:
Use svnadmin lsdblogs and recover subcommands instead of Berkeley DB
db_archive and db_recover utilities.
Patch:
Index: hot-backup.py.in
===================================================================
--- hot-backup.py.in (revision 6781)
+++ hot-backup.py.in (working copy)
@@ -30,11 +30,11 @@
# 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_lsdblogs = "@SVN_BINDIR@/svnadmin lsdblogs"
-# Path to db_recover progrem
-db_recover = "/usr/local/BerkeleyDB.4.0/bin/db_recover"
+# Path to svnadmin program with recover subcommand
+svnadmin_recover = "@SVN_BINDIR@/svnadmin recover"
# Number of backups to keep around (0 for "keep them all")
num_backups = 64
@@ -132,8 +132,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_lsdblogs + " " + repo_dir)
stdout_lines = outfile.readlines()
stderr_lines = errfile.readlines()
outfile.close()
@@ -143,27 +142,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 +188,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_lsdblogs +
+ " --only-unused " + 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 Mon Aug 18 21:59:18 2003