Module: Astrails::Safe

Defined in:
lib/astrails/safe.rb,
lib/astrails/safe/s3.rb,
lib/astrails/safe/gpg.rb,
lib/astrails/safe/gzip.rb,
lib/astrails/safe/pipe.rb,
lib/astrails/safe/sftp.rb,
lib/astrails/safe/sink.rb,
lib/astrails/safe/local.rb,
lib/astrails/safe/backup.rb,
lib/astrails/safe/pgdump.rb,
lib/astrails/safe/source.rb,
lib/astrails/safe/stream.rb,
lib/astrails/safe/archive.rb,
lib/astrails/safe/svndump.rb,
lib/astrails/safe/version.rb,
lib/astrails/safe/tmp_file.rb,
lib/astrails/safe/mongodump.rb,
lib/astrails/safe/mysqldump.rb,
lib/astrails/safe/cloudfiles.rb,
lib/astrails/safe/config/node.rb,
lib/astrails/safe/config/builder.rb

Defined Under Namespace

Modules: Config, TmpFile Classes: Archive, Backup, Cloudfiles, Gpg, Gzip, Local, Mongodump, Mysqldump, Pgdump, Pipe, S3, Sftp, Sink, Source, Stream, Svndump

Constant Summary collapse

ROOT =
File.join(File.dirname(__FILE__), "..", "..")
VERSION =
'0.2.11'

Class Method Summary collapse

Class Method Details

.safe(&block) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/astrails/safe.rb', line 43

def safe(&block)
  config = Config::Node.new(&block)

  begin
    [[Mysqldump, [:mysqldump, :databases]],
     [Pgdump,    [:pgdump,    :databases]],
     [Mongodump, [:mongodump, :databases]],
     [Archive,   [:tar,       :archives]],
     [Svndump,   [:svndump,   :repos]]
    ].each do |klass, path|
      if collection = config[*path]
        collection.each do |name, config|
          klass.new(name, config).backup.run(config, :gpg, :gzip, :local, :s3, :cloudfiles, :sftp)
        end
      end
    end
  rescue => e
    begin
      if config["airbrake"]
        toad = Toadhopper.new(config["airbrake"]["api_key"])
        toad.post!(e)
      end
    rescue
    end
  ensure
    Astrails::Safe::TmpFile.cleanup
  end
end