Created
March 17, 2011 04:01
-
-
Save kusakari/873816 to your computer and use it in GitHub Desktop.
export beanstalk svn repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
require 'rubygems' | |
require 'mechanize' | |
require 'kconv' | |
# settings | |
domain_name = 'YOUR_DOMAIN' | |
repo_name = 'YOUR_REPO' | |
username = 'USERNAME' | |
password = 'PASSWORD' | |
# | |
agent = Mechanize.new | |
agent.read_timeout = 300 | |
agent.get("https://#{domain_name}.beanstalkapp.com/repositories/#{repo_name}/administrate") | |
agent.page.form_with(:action => '/session') {|form| | |
form.field_with(:name => 'login').value = username | |
form.field_with(:name => 'password').value = password | |
form.click_button | |
} | |
agent.page.link_with(:text => "Export Repository".toutf8).click | |
legend = agent.page.at('legend') | |
if legend.inner_text == "Confirmation" | |
puts "dump start" | |
agent.page.form_with(:action => "/#{repo_name}/repository_export") {|form| | |
form.click_button | |
} | |
elsif legend.inner_text == "Download Export" | |
puts "dump finished" | |
# TODO: create lock file. | |
agent.page.link_with(:href => "/#{repo_name}/repository_export.svndump".toutf8).click | |
File.open("./#{repo_name}.svndump",'wb') do |f| | |
f.write agent.page.body.toutf8 | |
end | |
else | |
puts "dump processing..." | |
end | |
puts agent.page.uri | |
puts agent.page |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment