diff options
Diffstat (limited to 'tools/backup/hot-backup.py.in')
-rwxr-xr-x | tools/backup/hot-backup.py.in | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/tools/backup/hot-backup.py.in b/tools/backup/hot-backup.py.in index 87b0bb1..bc661c5 100755 --- a/tools/backup/hot-backup.py.in +++ b/tools/backup/hot-backup.py.in @@ -28,10 +28,10 @@ # under the License. # ==================================================================== -# $HeadURL: http://svn.apache.org/repos/asf/subversion/branches/1.8.x/tools/backup/hot-backup.py.in $ -# $LastChangedDate: 2010-08-20 04:30:52 +0000 (Fri, 20 Aug 2010) $ -# $LastChangedBy: cmpilato $ -# $LastChangedRevision: 987379 $ +# $HeadURL: https://svn.apache.org/repos/asf/subversion/branches/1.9.x/tools/backup/hot-backup.py.in $ +# $LastChangedDate: 2016-03-15 04:00:40 +0000 (Tue, 15 Mar 2016) $ +# $LastChangedBy: svn-role $ +# $LastChangedRevision: 1735016 $ ###################################################################### @@ -137,6 +137,11 @@ for o, a in opts: usage() sys.exit() +if archive_type not in (None, 'bz2', 'gz', 'zip', 'zip64'): + sys.stderr.write("ERROR: Bad --archive-type\n") + usage(sys.stderr) + sys.exit(2) + if len(args) != 2: sys.stderr.write("ERROR: only two arguments allowed.\n\n") sys.stderr.flush() @@ -198,7 +203,7 @@ def get_youngest_revision(): """Examine the repository REPO_DIR using the svnlook binary specified by SVNLOOK, and return the youngest revision.""" - p = subprocess.Popen([svnlook, 'youngest', repo_dir], + p = subprocess.Popen([svnlook, 'youngest', '--', repo_dir], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -245,7 +250,7 @@ backup_subdir = os.path.join(backup_dir, repo + "-" + youngest) # rather than start from 1 and increment because the starting # increments may have already been removed due to num_backups. -regexp = re.compile("^" + repo + "-" + youngest + +regexp = re.compile("^" + re.escape(repo) + "-" + re.escape(youngest) + "(-(?P<increment>[0-9]+))?" + ext_re + "$") directory_list = os.listdir(backup_dir) young_list = [x for x in directory_list if regexp.search(x)] @@ -262,8 +267,8 @@ if young_list: ### copied last. print("Backing up repository to '" + backup_subdir + "'...") -err_code = subprocess.call([svnadmin, "hotcopy", repo_dir, - backup_subdir, "--clean-logs"]) +err_code = subprocess.call([svnadmin, "hotcopy", "--clean-logs", + '--', repo_dir, backup_subdir]) if err_code != 0: sys.stderr.write("Unable to backup the repository.\n") sys.stderr.flush() @@ -274,7 +279,7 @@ else: ### Step 4: Verify the hotcopy if verify_copy: print("Verifying backup...") - err_code = subprocess.call([svnadmin, "verify", "--quiet", backup_subdir]) + err_code = subprocess.call([svnadmin, "verify", "--quiet", '--', backup_subdir]) if err_code != 0: sys.stderr.write("Backup verification failed.\n") sys.stderr.flush() @@ -340,7 +345,7 @@ if archive_type: ### NUM_BACKUPS. if num_backups > 0: - regexp = re.compile("^" + repo + "-[0-9]+(-[0-9]+)?" + ext_re + "$") + regexp = re.compile("^" + re.escape(repo) + "-[0-9]+(-[0-9]+)?" + ext_re + "$") directory_list = os.listdir(backup_dir) old_list = [x for x in directory_list if regexp.search(x)] old_list.sort(comparator) |