Permalink
Browse files

Merge branch 'develop'

  • Loading branch information...
2 parents b88ff66 + 30d4d5c commit 22b9e3aa71aeabc619bf702875ecc15ec93bc0b8 Michael van Rooijen committed Jun 3, 2011
Showing with 637 additions and 106 deletions.
  1. +0 −7 .infinity_test
  2. +0 −3 .rspec
  3. +8 −2 Gemfile
  4. +21 −10 Gemfile.lock
  5. +17 −0 Guardfile
  6. +87 −42 README.md
  7. +1 −9 backup.gemspec
  8. +6 −2 lib/backup.rb
  9. +1 −1 lib/backup/archive.rb
  10. +1 −1 lib/backup/cli.rb
  11. +64 −0 lib/backup/compressor/bzip2.rb
  12. +23 −0 lib/backup/configuration/compressor/bzip2.rb
  13. +25 −0 lib/backup/configuration/notifier/presently.rb
  14. +1 −1 lib/backup/encryptor/gpg.rb
  15. +105 −0 lib/backup/notifier/presently.rb
  16. +2 −6 lib/backup/storage/s3.rb
  17. +6 −4 lib/backup/syncer/s3.rb
  18. +1 −1 lib/backup/version.rb
  19. +3 −0 lib/templates/archive
  20. +7 −0 lib/templates/compressor/bzip2
  21. +3 −0 lib/templates/compressor/gzip
  22. +3 −0 lib/templates/database/mongodb
  23. +3 −0 lib/templates/database/mysql
  24. +4 −1 lib/templates/database/postgresql
  25. +3 −0 lib/templates/database/redis
  26. +3 −0 lib/templates/encryptor/gpg
  27. +3 −0 lib/templates/encryptor/openssl
  28. +3 −0 lib/templates/notifier/campfire
  29. +3 −0 lib/templates/notifier/mail
  30. +12 −0 lib/templates/notifier/presently
  31. +3 −0 lib/templates/notifier/twitter
  32. +1 −1 lib/templates/readme
  33. +3 −0 lib/templates/storage/cloudfiles
  34. +3 −0 lib/templates/storage/dropbox
  35. +3 −0 lib/templates/storage/ftp
  36. +3 −0 lib/templates/storage/rsync
  37. +14 −1 lib/templates/storage/s3
  38. +3 −0 lib/templates/storage/scp
  39. +3 −0 lib/templates/storage/sftp
  40. +3 −0 lib/templates/syncer/rsync
  41. +3 −0 lib/templates/syncer/s3
  42. +4 −4 spec/archive_spec.rb
  43. +59 −0 spec/compressor/bzip2_spec.rb
  44. +10 −10 spec/encryptor/gpg_spec.rb
  45. +99 −0 spec/notifier/presently_spec.rb
  46. +4 −0 spec/spec_helper.rb
View
@@ -1,7 +0,0 @@
-infinity_test do
- heuristics do
- add('lib/') do |file|
- run :all => :tests
- end
- end
-end
View
3 .rspec
@@ -1,3 +0,0 @@
---format Fuubar
---color
---tty
View
10 Gemfile
@@ -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
View
@@ -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)
@@ -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)
@@ -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)
@@ -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
@@ -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)
View
@@ -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
View
129 README.md

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -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
View
@@ -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
@@ -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
@@ -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
@@ -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
##
@@ -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
##
View
@@ -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
View
@@ -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
##
@@ -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
@@ -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
@@ -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
@@ -30,7 +30,7 @@ def initialize(&block)
instance_eval(&block) if block_given?
- @key = key.gsub(/^(\s|\t)+/, '')
+ @key = key.gsub(/^[[:blank:]]+/, '')
end
##
Oops, something went wrong.

0 comments on commit 22b9e3a

Please sign in to comment.