public
Description: Blanket is a flexible backup framework designed to get the drudgery out of the way and to make automated backups easy.
Homepage: http://jimvanfleet.com/projects/blanket
Clone URL: git://github.com/bigfleet/blanket.git
Moving Cap instructions into blanket itself, finalizing emitted format
bigfleet (author)
Sun Mar 02 13:24:09 -0800 2008
commit  ae366b91b6b983dc3c33d2e92149e2a0e2eebb41
tree    15ab6495f1852e21e1880d915f3aabdee32b16d4
parent  131ff970f0dcb041dda84161305c3d0790f4ca63
0
...
 
 
 
0
...
1
2
3
4
0
@@ -0,0 +1,3 @@
0
+Welcome to Blanket!
0
+
0
+https://github.com/bigfleet/blanket/wikis is the canonical online source for info on Blanket.
0
\ No newline at end of file
...
1
2
3
 
 
 
 
 
4
5
6
...
1
 
2
3
4
5
6
7
8
 
9
0
@@ -1,5 +1,8 @@
0
 #!/usr/bin/env ruby
0
-
0
 load File.dirname(__FILE__) + "/../lib/init.rb"
0
+require 'capistrano/cli'
0
+dir = ARGV.shift
0
+ARGV << "sink:export"
0
+FileUtils.cd(dir)
0
+Capistrano::CLI.execute
0
 
0
-puts $ARGV
0
\ No newline at end of file
...
1
2
 
 
3
...
 
1
2
3
4
0
@@ -1 +1,2 @@
0
-load 'home'
0
\ No newline at end of file
0
+Dir['../plugins/recipes/*.rb'].each { |plugin| load(plugin) }
0
+load '../lib/init.rb'
0
\ No newline at end of file
...
1
 
 
2
3
4
5
6
 
 
 
 
7
8
9
10
11
12
 
 
 
 
 
13
14
15
16
 
 
 
17
18
19
20
21
 
 
 
 
22
23
 
24
25
26
27
 
 
 
 
28
29
30
31
...
 
1
2
3
 
 
 
 
4
5
6
7
8
 
 
 
 
 
9
10
11
12
13
14
 
 
 
15
16
17
18
 
 
 
 
19
20
21
22
23
 
24
25
 
 
 
26
27
28
29
30
 
31
32
0
@@ -1,30 +1,31 @@
0
-class Reader
0
+module Blanket
0
+ class Reader
0
   
0
- def initialize(path)
0
- @path = path
0
- @attributes = YAML.load_file(@path)
0
- end
0
+ def initialize(path)
0
+ @path = path
0
+ @attributes = YAML.load_file(@path)
0
+ end
0
   
0
- def method_missing(symbol)
0
- @attributes[symbol.to_s]
0
- rescue
0
- nil
0
- end
0
+ def method_missing(symbol)
0
+ @attributes[symbol.to_s]
0
+ rescue
0
+ nil
0
+ end
0
   
0
- def keys
0
- blanket_type.attribute_symbols
0
- end
0
+ def keys
0
+ blanket_type.attribute_symbols
0
+ end
0
   
0
- def self.blanketize(path)
0
- reader = Reader.new(path)
0
- blanket_type.new(@attributes)
0
- end
0
+ def self.blanketize(path)
0
+ reader = Reader.new(path)
0
+ blanket_type.new(@attributes)
0
+ end
0
   
0
- private
0
+ private
0
   
0
- def blanket_type
0
- btype = @attributes["source_type"] || @attributes["sink_type"]
0
- Object.const_get(btype)
0
+ def blanket_type
0
+ btype = @attributes["source_type"] || @attributes["sink_type"]
0
+ Object.const_get(btype)
0
+ end
0
   end
0
-
0
 end
0
\ No newline at end of file
...
1
2
3
4
 
 
 
 
 
5
6
7
8
9
10
 
 
 
 
 
 
11
12
13
14
...
 
 
 
 
1
2
3
4
5
6
 
 
 
 
 
7
8
9
10
11
12
13
14
15
16
0
@@ -1,13 +1,15 @@
0
-class Writer
0
- def initialize(attributes)
0
- @attributes = attributes
0
- end
0
+module Blanket
0
+ class Writer
0
+ def initialize(attributes)
0
+ @attributes = attributes
0
+ end
0
   
0
- def write(path)
0
- File.delete(path) if File.exist?(path)
0
- write_to = File.new(path, File::CREAT, 0644)
0
- File.open(path, "w") do |out|
0
- YAML.dump(@attributes, out)
0
+ def write(path)
0
+ File.delete(path) if File.exist?(path)
0
+ write_to = File.new(path, File::CREAT, 0644)
0
+ File.open(path, "w") do |out|
0
+ YAML.dump(@attributes, out)
0
+ end
0
     end
0
   end
0
 end
0
\ No newline at end of file
...
1
2
3
 
4
 
 
 
5
6
 
7
8
9
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
0
@@ -1,9 +1,14 @@
0
 require 'rubygems'
0
 require 'yaml'
0
 gem 'aws-s3'
0
+gem 'rake'
0
 gem 'capistrano'
0
+require 'rake'
0
+require 'capistrano'
0
+require 'capistrano/configuration'
0
 require 'aws/s3'
0
 require 'fileutils'
0
+require 'pathname'
0
 
0
 # God, this is laborious. I need to know how to do this better.
0
 
...
1
 
 
 
 
 
 
 
 
 
 
 
 
2
3
4
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
0
@@ -1,4 +1,16 @@
0
 module Utils
0
+
0
+ def method_missing(symbol)
0
+ @reader.send(symbol)
0
+ rescue
0
+ nil
0
+ end
0
+
0
+ # remote noop command
0
+ def noop
0
+ "echo"
0
+ end
0
+
0
   module ClassMethods; end
0
   def self.included(klass)
0
     klass.extend(ClassMethods)
...
1
2
3
 
 
 
 
4
5
 
6
7
8
...
21
22
23
24
25
 
 
 
 
 
 
26
27
28
 
 
29
30
31
32
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
35
...
1
2
3
4
5
6
7
8
 
9
10
11
12
...
25
26
27
 
 
28
29
30
31
32
33
34
35
 
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
0
@@ -1,8 +1,12 @@
0
 require 'date'
0
 class Confluence < Source
0
   
0
+ def initialize(reader)
0
+ @reader = reader
0
+ end
0
+
0
   def self.attribute_symbols
0
- [:source_type, :host, :user, :password, :directory ]
0
+ [:source_type, :host, :user, :password, :remote_directory, :local_directory ]
0
   end
0
   
0
   def self.default_source_type
0
@@ -21,14 +25,36 @@ class Confluence < Source
0
     "password"
0
   end
0
   
0
- def self.default_directory
0
- "/path/to/confluence/backups"
0
+ def self.default_remote_directory
0
+ "/path/to/remote/confluence/backups"
0
+ end
0
+
0
+ def self.default_local_directory
0
+ "/path/to/local/confluence/backups"
0
   end
0
   
0
- def self.backup_file
0
+
0
+ def self.filename
0
     #On my system, they're named daily-backup-2008_02_24.zip
0
     today = Date.today
0
     "daily-backup-#{today.strftime("%Y_%m_%d")}.zip"
0
   end
0
   
0
+ def remote_backup_path
0
+ [remote_directory, Confluence.filename].join('/')
0
+ end
0
+
0
+ def local_backup_path
0
+ [local_directory, Confluence.filename].join('/')
0
+ end
0
+
0
+ def prep_command
0
+ noop
0
+ end
0
+
0
+ def cleanup_command
0
+ noop
0
+ end
0
+
0
+
0
 end
0
\ No newline at end of file
...
2
3
4
 
 
 
 
 
 
 
5
6
7
8
9
 
 
 
 
 
 
 
 
 
 
 
 
 
10
11
...
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
0
@@ -2,9 +2,29 @@ require File.dirname(__FILE__) + "/spec_helper.rb"
0
 
0
 describe "The Confluence source" do
0
   
0
+ before(:each) do
0
+ @file = File.dirname(__FILE__) + "/fixtures/confluence.yml"
0
+ @reader = Reader.new(@file)
0
+ @instance = Confluence.new(@reader)
0
+ @date_string = Date.today.strftime("%Y_%m_%d")
0
+ end
0
+
0
   it "should give back an accurate set of default attributes" do
0
     atts = Confluence.default_attributes
0
     atts["host"].should == "yourhost.com"
0
   end
0
   
0
+ it "should delegate methods to its configuration" do
0
+ @instance.source_type.should == "Confluence"
0
+ @instance.remote_directory.should == "/path/to/remote/backups"
0
+ end
0
+
0
+ it "should assemble the remote backup path properly" do
0
+ @instance.remote_backup_path.should == "/path/to/remote/backups/daily-backup-#{@date_string}.zip"
0
+ end
0
+
0
+ it "should assemble the local backup path properly" do
0
+ @instance.local_backup_path.should == "/path/to/local/backups/daily-backup-#{@date_string}.zip"
0
+ end
0
+
0
 end
0
\ No newline at end of file
...
1
2
3
4
5
6
7
 
 
 
 
 
 
 
...
 
 
 
 
 
 
 
1
2
3
4
5
6
7
0
@@ -1,7 +1,7 @@
0
-blanket_type: Confluence
0
-host: foobar.com
0
-user: foo
0
-password: topsecret
0
-directory: /var/confluence/backups
0
-bucket: com.foobar.confluence
0
-
0
+---
0
+user: username
0
+remote_directory: /path/to/remote/confluence/backups
0
+local_directory: /path/to/local/confluence/backups
0
+host: yourhost.com
0
+source_type: Confluence
0
+password: password
...
1
2
3
4
 
 
 
 
 
...
 
 
 
1
2
3
4
5
6
0
@@ -1,3 +1,5 @@
0
-blanket_type: S3
0
-access_key_id: some_key
0
-secret_access_key: some_secret
0
\ No newline at end of file
0
+---
0
+access_key_id: your-id
0
+secret_access_key: your-secret-ket
0
+bucket: s3-bucket
0
+sink_type: S3
...
12
13
14
 
 
 
 
 
15
16
17
...
34
35
36
37
 
38
39
40
...
12
13
14
15
16
17
18
19
20
21
22
...
39
40
41
 
42
43
44
45
0
@@ -12,6 +12,11 @@ describe "The YAML config file" do
0
       @reader.should_not be_nil
0
     end
0
     
0
+ it "should define the sink type as S3" do
0
+ @reader.sink_type.should == "S3"
0
+ end
0
+
0
+
0
     it "should define the access key id" do
0
       @reader.access_key_id.should == "some_key"
0
     end
0
@@ -34,7 +39,7 @@ describe "The YAML config file" do
0
     end
0
     
0
     it "should define the blanket type as Confluence" do
0
- @reader.blanket_type.should == "Confluence"
0
+ @reader.source_type.should == "Confluence"
0
     end
0
     
0
     it "should define the host" do
...
1
2
3
4
5
6
 
7
...
1
2
 
3
4
5
6
7
0
@@ -1,7 +1,7 @@
0
 ---
0
 user: foo
0
-blanket_type: Confluence
0
 directory: /var/confluence/backups
0
 bucket: com.foobar.confluence
0
 host: foobar.com
0
+source_type: Confluence
0
 password: topsecret
...
12
13
14
15
 
16
17
18
19
20
21
22
 
23
24
25
...
12
13
14
 
15
16
17
18
19
20
21
 
22
23
24
25
0
@@ -12,14 +12,14 @@ describe "The Blanket config writer" do
0
   it "should write a config file that the reader can read" do
0
     @writer.write(@tempfile)
0
     reader = Reader.new(@tempfile)
0
- Reader.new(@tempfile).blanket_type.should == "Confluence"
0
+ Reader.new(@tempfile).source_type.should == "Confluence"
0
   end
0
   
0
   it "should write a config file that matches the incoming parameters" do
0
     @writer.write(@tempfile)
0
     @reader = Reader.new(@confluence_file)
0
     @write_reader = Reader.new(@tempfile)
0
- [:blanket_type, :host, :user, :password, :directory, :bucket].each do |sym|
0
+ [:sink_type, :host, :user, :password, :directory, :bucket].each do |sym|
0
       @write_reader.send(sym).should == @reader.send(sym)
0
     end
0
   end

Comments

    No one has commented yet.