Permalink
Browse files

Merge branch 'develop'

  • Loading branch information...
2 parents db86fec + e23c1ea commit e9ee30cfc1714b9d1eeb78a2b17753f411bce82f Michael van Rooijen committed Feb 7, 2012
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- backup (3.0.22)
+ backup (3.0.23)
POpen4 (~> 0.1.4)
thor (~> 0.14.6)
@@ -54,7 +54,7 @@ GEM
i18n (0.6.0)
json (1.5.4)
libnotify (0.7.1)
- mail (2.3.0)
+ mail (2.4.1)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
@@ -116,7 +116,7 @@ DEPENDENCIES
httparty (~> 0.7.4)
json (~> 1.5.1)
libnotify
- mail (>= 2.2.15)
+ mail (>= 2.4.0)
mocha
net-scp (~> 1.0.4)
net-sftp (~> 2.0.5)
View
@@ -1,22 +1,20 @@
-Backup 3
-========
+Backup
+======
Backup is a RubyGem, written for Linux and Mac OSX, that allows you to easily perform backup operations on both your remote and local environments. It provides you with an elegant DSL in Ruby for modeling 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.
[![Build Status](https://secure.travis-ci.org/meskyanichi/backup.png)](http://travis-ci.org/meskyanichi/backup)
[![Still Maintained](http://stillmaintained.com/meskyanichi/backup.png)](http://stillmaintained.com/meskyanichi/backup)
-Author
-------
+### Author
**[Michael van Rooijen](http://michaelvanrooijen.com/) ( [@meskyanichi](http://twitter.com/#!/meskyanichi) )**
Drop me a message for any questions, suggestions, requests, bugs or submit them to the [issue log](https://github.com/meskyanichi/backup/issues).
-Installation
-------------
+### Installation
To get the latest stable version
@@ -25,18 +23,16 @@ To get the latest stable version
You can view the list of released versions over at [RubyGems.org (Backup)](https://rubygems.org/gems/backup/versions)
-Getting Started
----------------
+### Getting Started
I recommend you read this README first, and refer to the [wiki pages](https://github.com/meskyanichi/backup/wiki) afterwards. There's also a [Getting Started wiki page](https://github.com/meskyanichi/backup/wiki/Getting-Started).
What Backup 3 currently supports
-================================
+--------------------------------
Below you find a list of components that Backup currently supports. If you'd like support for components other than the ones listed here, feel free to request them or to fork Backup and add them yourself. Backup is modular and easy to extend.
-Database Support
-----------------
+### Database Support
- MySQL
- PostgreSQL
@@ -46,16 +42,14 @@ Database Support
[Database Wiki Page](https://github.com/meskyanichi/backup/wiki/Databases)
-Filesystem Support
-------------------
+### Filesystem Support
- Files
- Directories
[Archive Wiki Page](https://github.com/meskyanichi/backup/wiki/Archives)
-Storage Locations and Services
-------------------------------
+### Storage Locations and Services
- Amazon Simple Storage Service (S3)
- Rackspace Cloud Files (Mosso)
@@ -66,8 +60,7 @@ Storage Locations and Services
[Storage Wiki Page](https://github.com/meskyanichi/backup/wiki/Storages)
-Storage Features
-----------------
+### Storage Features
- **Backup Cycling, applies to:**
- Amazon Simple Storage Service (S3)
@@ -90,17 +83,15 @@ Storage Features
[Splitter Wiki Page](https://github.com/meskyanichi/backup/wiki/Splitter)
-Syncers
--------
+### Syncers
- RSync (Push, Pull and Local)
- Amazon S3
- Rackspce Cloud Files
[Syncer Wiki Page](https://github.com/meskyanichi/backup/wiki/Syncers)
-Compressors
------------
+### Compressors
- Gzip
- Bzip2
@@ -109,16 +100,14 @@ Compressors
[Compressors Wiki Page](https://github.com/meskyanichi/backup/wiki/Compressors)
-Encryptors
-----------
+### Encryptors
- OpenSSL
- GPG
[Encryptors Wiki Page](https://github.com/meskyanichi/backup/wiki/Encryptors)
-Notifiers
----------
+### Notifiers
- Mail
- Twitter
@@ -129,16 +118,15 @@ Notifiers
[Notifiers Wiki Page](https://github.com/meskyanichi/backup/wiki/Notifiers)
-Supported Ruby versions (Tested with RSpec)
--------------------------------------------
+### Supported Ruby versions (Tested with RSpec)
- Ruby 1.9.3
- Ruby 1.9.2
- Ruby 1.8.7
A sample Backup configuration file
-==================================
+----------------------------------
This is a Backup configuration file. Check it out and read the explanation below. Backup has a [great wiki](https://github.com/meskyanichi/backup/wiki) which explains each component of Backup in detail.
@@ -302,19 +290,16 @@ With this in place, run `whenever --update-crontab backup` to write the equivale
crontab in cron-syntax. Cron will now invoke `backup perform --trigger sample_backup` every 6 hours. Check out the
Whenever project page for more information.
-Documentation
--------------
+### Documentation
See the [Wiki Pages](https://github.com/meskyanichi/backup/wiki).
-Suggestions, Bugs, Requests, Questions
---------------------------------------
+### Suggestions, Bugs, Requests, Questions
View the [issue log](https://github.com/meskyanichi/backup/issues) and post them there.
-Contributors
-------------
+### Contributors
<table>
<tr>
@@ -444,8 +429,7 @@ Contributors
</table>
-Want to contribute?
--------------------
+### Want to contribute?
- Fork/Clone the **develop** branch
- Write RSpec tests, and test against:
@@ -456,8 +440,8 @@ Want to contribute?
I can't guarantee I'll pull every pull request. Also, I may accept your pull request and drastically change parts to improve readability/maintainability. Feel free to discuss about improvements, new functionality/features in the [issue log](https://github.com/meskyanichi/backup/issues) before contributing if you need/want more information.
-Easily run tests against all three Ruby versions
-------------------------------------------------
+
+### Easily run tests against all three Ruby versions
Install [RVM](https://rvm.beginrescueend.com/) and use it to install Ruby 1.9.3, 1.9.2 and 1.8.7.
@@ -478,9 +462,9 @@ The Backup gem uses [Guard](https://github.com/guard/guard) along with [Guard::R
from Backup's root and that's it. It'll now test against all Ruby versions each time you adjust a file in the `lib` or `spec` directories.
-Or contribute by writing blogs/tutorials/use cases
---------------------------------------------------
+### Or contribute by writing blogs/tutorials/use cases
+- http://freelancing-gods.com/posts/backing_up_with_backup
- http://erik.debill.org/2011/03/26/csing-backup-with-rails
- http://blog.noizeramp.com/2011/03/31/backing-up-backup-ruby-gem/
- http://www.sebaugereau.com/using-ruby-to-backup-with-beauty
@@ -7,7 +7,8 @@ class MySQL < Base
class << self
##
- # Name of the database that needs to get dumped
+ # Name of the database that needs to get dumped.
+ # To dump all databases, set this to `:all` or leave blank.
attr_accessor :name
##
@@ -19,6 +19,10 @@ class << self
# : Settings used only by this method:
# : `sendmail`, `sendmail_args`
#
+ # `:exim` [::Mail::Exim]
+ # : Settings used only by this method:
+ # : `exim`, `exim_args`
+ #
# `:file` [::Mail::FileDelivery]
# : Settings used only by this method:
# : `mail_folder`
@@ -83,6 +87,19 @@ class << self
attr_accessor :sendmail_args
##
+ # When using the `:exim` `delivery_method` option,
+ # this may be used to specify the absolute path to `exim` (if needed)
+ # Example: '/usr/sbin/exim'
+ attr_accessor :exim
+
+ ##
+ # Optional arguments to pass to `exim`
+ # Note that this will override the defaults set by the Mail gem (currently: '-i -t')
+ # So, if set here, be sure to set all the arguments you require.
+ # Example: '-i -t -X/tmp/traffic.log'
+ attr_accessor :exim_args
+
+ ##
# Folder where mail will be kept when using the `:file` `delivery_method` option.
# Default location is '$HOME/backup-mails'
# Example: '/tmp/test-mails'
@@ -6,6 +6,7 @@ class MySQL < Base
##
# Name of the database that needs to get dumped
+ # To dump all databases, set this to `:all` or leave blank.
attr_accessor :name
##
@@ -43,6 +44,8 @@ def initialize(model, &block)
instance_eval(&block) if block_given?
+ @name ||= :all
+
if @utility_path
Logger.warn "[DEPRECATED] " +
"Database::MySQL#utility_path has been deprecated.\n" +
@@ -68,7 +71,7 @@ def perform!
end
end
- dump_cmd << " > '#{ File.join(@dump_path, name) }.#{ dump_ext }'"
+ dump_cmd << " > '#{ File.join(@dump_path, dump_filename) }.#{ dump_ext }'"
run(dump_cmd)
end
@@ -78,7 +81,13 @@ def perform!
# Builds the full mysqldump string based on all attributes
def mysqldump
"#{ mysqldump_utility } #{ credential_options } #{ connectivity_options } " +
- "#{ user_options } #{ name } #{ tables_to_dump } #{ tables_to_skip }"
+ "#{ user_options } #{ db_name } #{ tables_to_dump } #{ tables_to_skip }"
+ end
+
+ ##
+ # Returns the filename to use for dumping the database(s)
+ def dump_filename
+ dump_all? ? 'all-databases' : name
end
##
@@ -109,10 +118,18 @@ def user_options
end
##
+ # Returns the database name to use in the mysqldump command.
+ # When dumping all databases, the database name is replaced
+ # with the command option to dump all databases.
+ def db_name
+ dump_all? ? '--all-databases' : name
+ end
+
+ ##
# Builds the MySQL syntax for specifying which tables to dump
# during the dumping of the database
def tables_to_dump
- only_tables.join(' ')
+ only_tables.join(' ') unless dump_all?
end
##
@@ -121,7 +138,15 @@ def tables_to_dump
def tables_to_skip
skip_tables.map do |table|
"--ignore-table='#{name}.#{table}'"
- end.join(' ')
+ end.join(' ') unless dump_all?
+ end
+
+ ##
+ # Return true if we're dumping all databases.
+ # `name` will be set to :all if it is not set,
+ # so this will be true by default
+ def dump_all?
+ name == :all
end
end
@@ -47,7 +47,7 @@ def self.all
'mail' => {
:require => 'mail',
- :version => '>= 2.2.15',
+ :version => '>= 2.4.0',
:for => 'Sending Emails (Mail Notifier)'
},
@@ -62,6 +62,8 @@ def clear!
def truncate!(max_bytes = 500_000)
log_file = File.join(Config.log_path, 'backup.log')
+ return unless File.exist?(log_file)
+
if File.stat(log_file).size > max_bytes
FileUtils.mv(log_file, log_file + '~')
File.open(log_file + '~', 'r') do |io_in|
Oops, something went wrong.

0 comments on commit e9ee30c

Please sign in to comment.