#!/usr/bin/ruby # Program Name: Restore the restore # Purpose: Take all the parts of a svnbackup.sh file and # try loading the svnadmin # Usage: 1. Create the new repo path with svnadmin create # 2. Set repo_name to the repo backup file names # 3. Set restore_path to the new path to restore to # 4. Run it ./svnbackup-restore.rb # Assumptions: svnrestore-backup.rb is in the same dir as the svn dump files # CHANGE PARAMETERS HERE repo_name = 'myrepo' restore_path = '/path/to/myrepo' # Print out debugging? DEBUG = true # DON'T CHANGE BELOW # Filename format is 'dumpfile---.bzip2' svn_dumpfiles = Dir["dumpfile-#{repo_name}*.bzip2"] sorted_files = svn_dumpfiles.sort do |a, b| left_rev = a.split('-')[2].to_i right_rev = b.split('-')[2].to_i left_rev <=> right_rev end sorted_files.each do |dump_part| results = `bzcat #{dump_part} | svnadmin load #{restore_path}; echo $?` puts results if DEBUG res = results.split.last.to_i if res != 0 puts "Error on trying to load up #{dump_part}!" exit 1 end end