You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by cm...@apache.org on 2010/08/20 06:30:52 UTC

svn commit: r987379 - /subversion/trunk/tools/backup/hot-backup.py.in

Author: cmpilato
Date: Fri Aug 20 04:30:52 2010
New Revision: 987379

URL: http://svn.apache.org/viewvc?rev=987379&view=rev
Log:
Add new --verify option to hot-backup.py.

* tools/backup/hot-backup.py.in
  Added command line option "--verify".  If flag is present, the
  backup will be verified using 'svnadmin verify' in a new step
  between step 3 (hotcopy) and 4 (compress).

Patch by: Leo Davis <ld...@fonix.com>
          (Tweaked by me.)

Modified:
    subversion/trunk/tools/backup/hot-backup.py.in

Modified: subversion/trunk/tools/backup/hot-backup.py.in
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/backup/hot-backup.py.in?rev=987379&r1=987378&r2=987379&view=diff
==============================================================================
--- subversion/trunk/tools/backup/hot-backup.py.in (original)
+++ subversion/trunk/tools/backup/hot-backup.py.in Fri Aug 20 04:30:52 2010
@@ -106,6 +106,7 @@ Options:
                        zip  : Creates a compressed zip file.
                        zip64: Creates a zip64 file (can be > 2GB).
   --num-backups=N    Number of prior backups to keep around (0 to keep all).
+  --verify           Verify the backup.
   --help      -h     Print this help message and exit.
 
 """ % (scriptname,))
@@ -114,6 +115,7 @@ Options:
 try:
   opts, args = getopt.gnu_getopt(sys.argv[1:], "h?", ["archive-type=",
                                                       "num-backups=",
+                                                      "verify",
                                                       "help"])
 except getopt.GetoptError, e:
   sys.stderr.write("ERROR: %s\n\n" % e)
@@ -122,12 +124,15 @@ except getopt.GetoptError, e:
   sys.exit(2)
 
 archive_type = None
+verify_copy = False
 
 for o, a in opts:
   if o == "--archive-type":
     archive_type = a
   elif o == "--num-backups":
     num_backups = int(a)
+  elif o == "--verify":
+    verify_copy = True
   elif o in ("-h", "--help", "-?"):
     usage()
     sys.exit()
@@ -266,8 +271,18 @@ if err_code != 0:
 else:
   print("Done.")
 
+### Step 4: Verify the hotcopy
+if verify_copy:
+  print("Verifying backup...")
+  err_code = subprocess.call([svnadmin, "verify", "--quiet", backup_subdir])
+  if err_code != 0:
+    sys.stderr.write("Backup verification failed.\n")
+    sys.stderr.flush()
+    sys.exit(err_code)
+  else:
+    print("Done.")
 
-### Step 4: Make an archive of the backup if required.
+### Step 5: Make an archive of the backup if required.
 if archive_type:
   archive_path = backup_subdir + archive_map[archive_type]
   err_msg = ""
@@ -321,7 +336,7 @@ if archive_type:
     print("Archive created, removing backup '" + backup_subdir + "'...")
     safe_rmtree(backup_subdir, 1)
 
-### Step 5: finally, remove all repository backups other than the last
+### Step 6: finally, remove all repository backups other than the last
 ###         NUM_BACKUPS.
 
 if num_backups > 0: