diff --git a/README.markdown b/README.markdown index ff951f6..a294f4a 100644 --- a/README.markdown +++ b/README.markdown @@ -136,6 +136,12 @@ Example configuration end + svndump do + repo :my_repo do + repo_path "/home/svn/my_repo" + end + end + tar do archive "git-repositories", :files => "/home/git/repositories" archive "dot-configs", :files => "/home/*/.[^.]*" diff --git a/examples/unit/config_example.rb b/examples/unit/config_example.rb index f073466..991bb91 100644 --- a/examples/unit/config_example.rb +++ b/examples/unit/config_example.rb @@ -47,6 +47,11 @@ end + svndump do + repo :my_repo do + repo_path "/home/svn/my_repo" + end + end tar do archive "git-repositories" do @@ -105,6 +110,15 @@ }, }, }, + + "svndump" => { + "repos" => { + "my_repo"=> { + "repo_path" => "/home/svn/my_repo" + } + } + }, + "tar" => { "archives" => { "git-repositories" => {"files" => "/home/git/repositories"}, diff --git a/lib/astrails/safe.rb b/lib/astrails/safe.rb index d26dfb8..3479bae 100644 --- a/lib/astrails/safe.rb +++ b/lib/astrails/safe.rb @@ -18,6 +18,7 @@ require 'astrails/safe/source' require 'astrails/safe/mysqldump' require 'astrails/safe/archive' +require 'astrails/safe/svndump' require 'astrails/safe/pipe' require 'astrails/safe/gpg' @@ -48,8 +49,14 @@ def safe(&block) end end + if repos = config[:svndump, :repos] + repos.each do |name, config| + Astrails::Safe::Svndump.new(name, config).backup.run(config, :gpg, :gzip, :local, :s3) + end + end + Astrails::Safe::TmpFile.cleanup end module_function :safe end -end \ No newline at end of file +end diff --git a/lib/astrails/safe/config/builder.rb b/lib/astrails/safe/config/builder.rb index 3f3725f..8e5e9fb 100644 --- a/lib/astrails/safe/config/builder.rb +++ b/lib/astrails/safe/config/builder.rb @@ -2,9 +2,9 @@ module Astrails module Safe module Config class Builder - COLLECTIONS = %w/database archive/ + COLLECTIONS = %w/database archive repo/ ITEMS = %w/s3 key secret bucket path gpg password keep local mysqldump options - user host port socket skip_tables tar files exclude filename/ + user host port socket skip_tables tar files exclude filename svndump repo_path/ NAMES = COLLECTIONS + ITEMS def initialize(node) @node = node diff --git a/lib/astrails/safe/svndump.rb b/lib/astrails/safe/svndump.rb new file mode 100644 index 0000000..eabdebe --- /dev/null +++ b/lib/astrails/safe/svndump.rb @@ -0,0 +1,13 @@ +module Astrails + module Safe + class Svndump < Source + + def command + @command ||= "svnadmin dump #{@config[:repo_path]}" + end + + def extension; '.svn'; end + + end + end +end