Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael van Rooijen committed Jun 3, 2011
2 parents b88ff66 + 30d4d5c commit 22b9e3a
Show file tree
Hide file tree
Showing 46 changed files with 637 additions and 106 deletions.
7 changes: 0 additions & 7 deletions .infinity_test

This file was deleted.

3 changes: 0 additions & 3 deletions .rspec

This file was deleted.

10 changes: 8 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ end
group :test do
gem 'rspec'
gem 'mocha'
gem 'infinity_test'
gem 'fuubar'
gem 'timecop'
gem 'fuubar'

gem 'guard'
gem 'guard-rspec'
gem 'rb-fsevent' # guard notifications for osx
gem 'growl' # $ brew install growlnotify
gem 'rb-inotify' # guard notifications for linux
gem 'libnotify' # $ apt-get install ???
end
31 changes: 21 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ GEM
rack (< 2, >= 1.1.0)
faraday_middleware (0.3.2)
faraday (~> 0.5.4)
ffi (1.0.9)
fog (0.7.0)
builder
excon (>= 0.5.5)
Expand All @@ -28,18 +29,21 @@ GEM
nokogiri (>= 1.4.4)
ruby-hmac
formatador (0.1.1)
fuubar (0.0.3)
fuubar (0.0.5)
rspec (~> 2.0)
rspec-instafail (~> 0.1.4)
ruby-progressbar (~> 0.0.9)
ruby-progressbar (~> 0.0.10)
growl (1.0.3)
guard (0.3.4)
thor (~> 0.14.6)
guard-rspec (0.3.1)
guard (>= 0.2.2)
hashie (1.0.0)
httparty (0.7.4)
crack (= 0.1.8)
i18n (0.5.0)
infinity_test (1.0.2)
notifiers (>= 1.1.0)
watchr (>= 0.7)
json (1.5.1)
libnotify (0.5.5)
mail (2.2.15)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
Expand All @@ -58,22 +62,25 @@ GEM
net-ssh (>= 2.0.9)
net-ssh (2.1.3)
nokogiri (1.4.4)
notifiers (1.1.0)
oauth (0.4.4)
polyglot (0.3.1)
rack (1.2.2)
rb-fsevent (0.4.0)
rb-inotify (0.8.5)
ffi (>= 0.5.0)
rspec (2.5.0)
rspec-core (~> 2.5.0)
rspec-expectations (~> 2.5.0)
rspec-mocks (~> 2.5.0)
rspec-core (2.5.1)
rspec-expectations (2.5.0)
diff-lcs (~> 1.1.2)
rspec-instafail (0.1.6)
rspec-instafail (0.1.7)
rspec-mocks (2.5.0)
ruby-hmac (0.4.0)
ruby-progressbar (0.0.9)
ruby-progressbar (0.0.10)
simple_oauth (0.1.4)
thor (0.14.6)
timecop (0.3.5)
treetop (1.4.9)
polyglot (>= 0.3.1)
Expand All @@ -84,7 +91,6 @@ GEM
multi_json (~> 0.0.5)
multi_xml (~> 0.2.0)
simple_oauth (~> 0.1.3)
watchr (0.7)

PLATFORMS
ruby
Expand All @@ -93,14 +99,19 @@ DEPENDENCIES
dropbox (~> 1.2.3)
fog (~> 0.7.0)
fuubar
growl
guard
guard-rspec
httparty (~> 0.7.4)
infinity_test
json (~> 1.5.1)
libnotify
mail (~> 2.2.15)
mocha
net-scp (~> 1.0.4)
net-sftp (~> 2.0.5)
net-ssh (~> 2.1.3)
rb-fsevent
rb-inotify
rspec
timecop
twitter (~> 1.1.2)
17 changes: 17 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
##
# To run the test suite against all 3 rubies: 1.9.2, 1.8.7 and REE, simply run the following command:
# $ guard start
#
# Be use you are using RVM and have Ruby 1.9.2, 1.8.7 and REE installed as well as all
# Backup's gem dependencies for each of these Ruby intepreters.

guard 'rspec',
:version => 2,
:rvm => ['1.9.2', '1.8.7', 'ree'],
:bundler => true,
:cli => '--color --format Fuubar --fail-fast' do

watch(%r{^spec/.+_spec\.rb})
watch(%r{^lib/(.+)\.rb}) { 'spec' }
watch('spec/spec_helper.rb') { 'spec' }
end
129 changes: 87 additions & 42 deletions README.md

Large diffs are not rendered by default.

10 changes: 1 addition & 9 deletions backup.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,7 @@ Gem::Specification.new do |gem|
gem.authors = 'Michael van Rooijen'
gem.email = 'meskyanichi@gmail.com'
gem.homepage = 'http://rubygems.org/gems/backup'
gem.summary = 'Backup is a RubyGem (for UNIX-like operating systems: Linux, Mac OSX)
that allows you to configure and perform backups in a simple manner using
an elegant Ruby DSL. It supports various databases (MySQL, PostgreSQL, MongoDB and Redis),
it supports various storage locations (Amazon S3, Rackspace Cloud Files, Dropbox, any remote
server through FTP, SFTP, SCP and RSync), it provide Syncers (RSync, S3) for efficient backups,
it can archive files and directories, it can cycle backups, it can do incremental backups, it
can compress backups, it can encrypt backups (OpenSSL or GPG), it can notify you about
successful and/or failed backups (Email, Twitter and Campfire). It is very extensible and easy to add new
functionality to. It\'s easy to use.'
gem.summary = 'Backup is a RubyGem, written for Linux and Mac OSX, that allows you to easily perform backup operations on both your remote, as well as your local environment. It provides you with an elegant DSL in Ruby for modeling (configuring) your backups. Backup has built-in support for various databases, storage protocols/services, syncers, compressors, encryptors and notifiers which you can mix and match. It was built with modularity, extensibility and simplicity in mind.'

##
# Files and folder that need to be compiled in to the Ruby Gem
Expand Down
8 changes: 6 additions & 2 deletions lib/backup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ module Backup
# database MySQL do |mysql|
DATABASES = ['MySQL', 'PostgreSQL', 'MongoDB', 'Redis']
STORAGES = ['S3', 'CloudFiles', 'Dropbox', 'FTP', 'SFTP', 'SCP', 'RSync']
COMPRESSORS = ['Gzip']
COMPRESSORS = ['Gzip', 'Bzip2']
ENCRYPTORS = ['OpenSSL', 'GPG']
SYNCERS = ['RSync', 'S3']
NOTIFIERS = ['Mail', 'Twitter', 'Campfire']
NOTIFIERS = ['Mail', 'Twitter', 'Campfire', 'Presently']

##
# Backup's internal paths
Expand Down Expand Up @@ -64,6 +64,7 @@ module Notifier
autoload :Mail, File.join(CONFIGURATION_PATH, 'notifier', 'mail')
autoload :Twitter, File.join(CONFIGURATION_PATH, 'notifier', 'twitter')
autoload :Campfire, File.join(CONFIGURATION_PATH, 'notifier', 'campfire')
autoload :Presently, File.join(CONFIGURATION_PATH, 'notifier', 'presently')
end

module Encryptor
Expand All @@ -75,6 +76,7 @@ module Encryptor
module Compressor
autoload :Base, File.join(CONFIGURATION_PATH, 'compressor', 'base')
autoload :Gzip, File.join(CONFIGURATION_PATH, 'compressor', 'gzip')
autoload :Bzip2, File.join(CONFIGURATION_PATH, 'compressor', 'bzip2')
end

module Storage
Expand Down Expand Up @@ -139,6 +141,7 @@ module Database
module Compressor
autoload :Base, File.join(COMPRESSOR_PATH, 'base')
autoload :Gzip, File.join(COMPRESSOR_PATH, 'gzip')
autoload :Bzip2, File.join(COMPRESSOR_PATH, 'bzip2')
end

##
Expand All @@ -157,6 +160,7 @@ module Notifier
autoload :Mail, File.join(NOTIFIER_PATH, 'mail')
autoload :Twitter, File.join(NOTIFIER_PATH, 'twitter')
autoload :Campfire, File.join(NOTIFIER_PATH, 'campfire')
autoload :Presently, File.join(NOTIFIER_PATH, 'presently')
end

##
Expand Down
2 changes: 1 addition & 1 deletion lib/backup/archive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def paths_to_package
# Returns a "tar-ready" string of all the specified excludes combined
def paths_to_exclude
if excludes.any?
"--exclude={" + excludes.map{ |e| "'#{e}'" }.join(",") + "}"
excludes.map{ |e| "--exclude='#{e}'" }.join(" ")
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/backup/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ module CLI
# and pass that in to the Backup::CLI#raise_if_command_not_found
def run(command)
command.gsub!(/^\s+/, '')
%x[#{command}]
raise_if_command_not_found!(
command.slice(0, command.index(/\s/)).split('/')[-1]
)
%x[#{command}]
end

##
Expand Down
64 changes: 64 additions & 0 deletions lib/backup/compressor/bzip2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# encoding: utf-8

module Backup
module Compressor
class Bzip2 < Base

##
# Tells Backup::Compressor::Bzip2 to compress
# better (-9) rather than faster when set to true
attr_writer :best

##
# Tells Backup::Compressor::Bzip2 to compress
# faster (-1) rather than better when set to true
attr_writer :fast

##
# Creates a new instance of Backup::Compressor::Bzip2 and
# configures it to either compress faster or better
# bzip2 compresses by default with -9 (best compression)
# and lower block sizes don't make things significantly faster
# (according to official bzip2 docs)
def initialize(&block)
load_defaults!

@best ||= false
@fast ||= false

instance_eval(&block) if block_given?
end

##
# Performs the compression of the packages backup file
def perform!
log!
run("#{ utility(:bzip2) } #{ options } '#{ Backup::Model.file }'")
Backup::Model.extension += '.bz2'
end

private

##
# Combines the provided options and returns a bzip2 options string
def options
(best + fast).join("\s")
end

##
# Returns the bzip2 option syntax for compressing
# setting @best to true is redundant, as bzip2 compresses best by default
def best
return ['--best'] if @best; []
end

##
# Returns the bzip2 option syntax for compressing
# (not significantly) faster when @fast is set to true
def fast
return ['--fast'] if @fast; []
end

end
end
end
23 changes: 23 additions & 0 deletions lib/backup/configuration/compressor/bzip2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# encoding: utf-8

module Backup
module Configuration
module Compressor
class Bzip2 < Base
class << self

##
# Tells Backup::Compressor::Bzip2 to compress
# better (-9) which is bzip2 default anyway
attr_accessor :best

##
# Tells Backup::Compressor::Bzip2 to compress
# faster (-1) (but not significantly faster)
attr_accessor :fast

end
end
end
end
end
25 changes: 25 additions & 0 deletions lib/backup/configuration/notifier/presently.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# encoding: utf-8

module Backup
module Configuration
module Notifier
class Presently < Base
class << self

##
# Presently subdomain
attr_accessor :subdomain

##
# Presently credentials
attr_accessor :user_name, :password

##
# Group id
attr_accessor :group_id

end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/backup/encryptor/gpg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def initialize(&block)

instance_eval(&block) if block_given?

@key = key.gsub(/^(\s|\t)+/, '')
@key = key.gsub(/^[[:blank:]]+/, '')
end

##
Expand Down
Loading

0 comments on commit 22b9e3a

Please sign in to comment.