{"id":685,"date":"2008-07-03T22:48:21","date_gmt":"2008-07-04T03:48:21","guid":{"rendered":"http:\/\/blogs.law.harvard.edu\/hoanga\/2008\/07\/03\/svnbackup-restorerb-svnbackups-handy-companion-tool\/"},"modified":"2008-07-03T22:48:21","modified_gmt":"2008-07-04T03:48:21","slug":"svnbackup-restorerb-svnbackups-handy-companion-tool","status":"publish","type":"post","link":"https:\/\/archive.blogs.harvard.edu\/hoanga\/2008\/07\/03\/svnbackup-restorerb-svnbackups-handy-companion-tool\/","title":{"rendered":"svnbackup-restore.rb, svnbackup&#8217;s handy companion tool"},"content":{"rendered":"<p><a href=\"http:\/\/www.doughellmann.com\/projects\/svnbackup\/\">Doug Hellman&#8217;s svnbackup script<\/a> tool is a really handy tool for setting up automated backups for a subversion repository.  <\/p>\n<p>However, the non-fun time comes when one wants to restore a subversion repository that has way too many dumpfiles parts.  The instructions for restoration are basically <a href=\"http:\/\/code.google.com\/p\/svnautobackup\/wiki\/RestoringFromTheBackup\">&#8216;roll your own&#8217;<\/a> if you want to try to automate the restore procedure.  What would be nicer is if there was the converse tool that made it easier to not have to figure out how to re-order the backup files in the proper manner in order to perform the restore.<\/p>\n<p>I spent a few minutes thinking about it and wrote a small Ruby script to help with this that I call svnbackup-restore.rb.   Here is the (hastily written) source code.  (<a href=\"http:\/\/samsara.bebear.net\/~al\/scripts\/svnbackup-restore.rb\">Download here<\/a>)<\/p>\n<pre>\r\n#!\/usr\/bin\/ruby\r\n# Program Name: Restore the restore\r\n# Purpose:      Take all the svn dumpfiles generated from svnbackup\r\n#               sort them and try loading them via svnadmin\r\n# Usage:        1. Create the new repo path with svnadmin create\r\n#               2. Set repo_name to the repo backup file names\r\n#               3. Set restore_path to the new path to restore to\r\n#               4. Run it .\/svnbackup-restore.rb \r\n# Assumptions:  svnrestore-backup.rb is in the same dir as the svn dump files\r\n\r\n# CHANGE PARAMETERS HERE\r\nrepo_name = 'myrepo'\r\nrestore_path = '\/path\/to\/myrepo'\r\n\r\n# Print out debugging?\r\nDEBUG = true\r\n\r\n# DON'T CHANGE BELOW\r\n\r\n# Filename format is 'dumpfile---.bzip2'\r\nsvn_dumpfiles = Dir[\"dumpfile-#{repo_name}*.bzip2\"]\r\nsorted_files = svn_dumpfiles.sort do |a, b|\r\n  left_rev = a.split('-')[2].to_i\r\n  right_rev = b.split('-')[2].to_i\r\n  left_rev  right_rev\r\nend\r\nsorted_files.each do |dump_part| \r\n  results = `bzcat #{dump_part} | svnadmin load #{restore_path}; echo $?`\r\n  puts results if DEBUG\r\n  res = results.split.last.to_i\r\n  if res != 0\r\n    puts \"Error on trying to load up #{dump_part}!\"\r\n    exit 1\r\n  end\r\nend\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Doug Hellman&#8217;s svnbackup script tool is a really handy tool for setting up automated backups for a subversion repository. However, the non-fun time comes when one wants to restore a subversion repository that has way too many dumpfiles parts. The instructions for restoration are basically &#8216;roll your own&#8217; if you want to try to automate [&hellip;]<\/p>\n","protected":false},"author":703,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1216,1029,615,260,1099],"tags":[],"class_list":["post-685","post","type-post","status-publish","format-standard","hentry","category-fixes","category-open-source","category-ruby","category-tech","category-unix"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/posts\/685","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/users\/703"}],"replies":[{"embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/comments?post=685"}],"version-history":[{"count":0,"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/posts\/685\/revisions"}],"wp:attachment":[{"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/media?parent=685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/categories?post=685"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/tags?post=685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}