Sha256: b00fe9574699e5e19bfd0752dbae4cb98ec64f95e2cd37f1d699f791ba787a39

Contents?: true

Size: 1.73 KB

Versions: 3

Compression:

Stored size: 1.73 KB

Contents

require "aws-sdk"
require "cloudfiles"
require 'net/sftp'
require 'fileutils'
require 'benchmark'
require 'toadhopper'

require 'tempfile'
require 'extensions/mktmpdir'

require 'astrails/safe/tmp_file'

require 'astrails/safe/config/node'
require 'astrails/safe/config/builder'

require 'astrails/safe/stream'

require 'astrails/safe/backup'

require 'astrails/safe/source'
require 'astrails/safe/mysqldump'
require 'astrails/safe/pgdump'
require 'astrails/safe/archive'
require 'astrails/safe/svndump'
require 'astrails/safe/mongodump'

require 'astrails/safe/pipe'
require 'astrails/safe/gpg'
require 'astrails/safe/gzip'

require 'astrails/safe/sink'
require 'astrails/safe/local'
require 'astrails/safe/s3'
require 'astrails/safe/cloudfiles'
require 'astrails/safe/sftp'

require 'astrails/safe/version'

module Astrails
  module Safe
    ROOT = File.join(File.dirname(__FILE__), "..", "..")

    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
    module_function :safe
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
netguru-safe-0.2.11 lib/astrails/safe.rb
netguru-safe-0.2.10 lib/astrails/safe.rb
netguru-safe-0.2.9 lib/astrails/safe.rb