Permalink
Browse files

Merge branch 'develop' into builds

  • Loading branch information...
2 parents 21410de + 1b791de commit 5ad918836bb2e2b13fa2f9a14c4bd9d884be3d15 Michael van Rooijen committed Mar 11, 2011
Showing with 19 additions and 6 deletions.
  1. +1 −1 Gemfile.lock
  2. +1 −1 README.md
  3. +13 −0 bin/backup
  4. +1 −1 lib/backup/model.rb
  5. +1 −1 lib/backup/version.rb
  6. +1 −1 spec/storage/cloudfiles_spec.rb
  7. +1 −1 spec/storage/s3_spec.rb
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- backup (3.0.0.build.0)
+ backup (3.0.2.build.0)
dropbox (~> 1.2.3)
fog (~> 0.5.3)
mail (~> 2.2.15)
View
@@ -173,7 +173,7 @@ Below you see a sample configuration file you could create for Backup 3. Just re
### Explanation for the above example
-First it dumps all the tables inside the MySQL database "my_sample_mysql_db", except for the "logs" table. It also dumps the MongoDB database "my_sample_mongo_db", but only the collections "users", "events" and "posts". After that it'll create a "user_avatars.tar" archive with all the uploaded avatars of the users. After that it'll create a "logs.tar" archive with the "production.log", "newrelic_agent.log" and "other.log" logs. After that it'll encrypt the whole backup file (everything included: databases, archives) using "OpenSSL". Now the Backup can only be extracted when you know the password to decrypt it ("my_secret_password" in this case). After that it'll compress the backup file using Gzip (with the mode set to "best", rather than "fast" for best compression). Then it'll store the backup file to Amazon S3 in to 'my_bucket/backups'. Next it'll also transfer a copy of the backup file to a remote server using the RSync protocol, and it'll be stored in to the "$HOME/backups/" path on this server. Finally, it'll notify me by email if the backup raises an error/exception during the process indicating that something went wrong. (When setting `mail.on_success = true` it'll also notify you of every successful backup)
+First it dumps all the tables inside the MySQL database "my_sample_mysql_db", except for the "logs" table. It also dumps the MongoDB database "my_sample_mongo_db", but only the collections "users", "events" and "posts". After that it'll create a "user_avatars.tar" archive with all the uploaded avatars of the users. After that it'll create a "logs.tar" archive with the "production.log", "newrelic_agent.log" and "other.log" logs. After that it'll compress the backup file using Gzip (with the mode set to "best", rather than "fast" for best compression). After that it'll encrypt the whole backup file (everything included: databases, archives) using "OpenSSL". Now the Backup can only be extracted when you know the password to decrypt it ("my_secret_password" in this case). Then it'll store the backup file to Amazon S3 in to 'my_bucket/backups'. Next it'll also transfer a copy of the backup file to a remote server using the RSync protocol, and it'll be stored in to the "$HOME/backups/" path on this server. Finally, it'll notify me by email if the backup raises an error/exception during the process indicating that something went wrong. (When setting `mail.on_success = true` it'll also notify you of every successful backup)
### Things to note
View
@@ -22,6 +22,7 @@ require File.expand_path("../../lib/backup", __FILE__)
##
# Build the Backup Command Line Interface using Thor
class BackupCLI < Thor
+ include Thor::Actions
TEMPLATE_DIR = File.expand_path("../../lib/templates", __FILE__)
@@ -128,12 +129,14 @@ class BackupCLI < Thor
temp_file.close
if options[:path]
FileUtils.mkdir_p(options[:path])
+ overwrite?(File.join(Backup::PATH, 'config.rb'))
File.open(File.join(options[:path], 'config.rb'), 'w') do |file|
file.write( File.read(temp_file.path) )
puts "Generated configuration file in '#{File.join(options[:path], 'config.rb')}'"
end
else
FileUtils.mkdir_p(Backup::PATH)
+ overwrite?(File.join(Backup::PATH, 'config.rb'))
File.open(File.join(Backup::PATH, 'config.rb'), 'w') do |file|
file.write( File.read(temp_file.path) )
puts "Generated configuration file in '#{File.join(Backup::PATH, 'config.rb')}'"
@@ -172,6 +175,16 @@ class BackupCLI < Thor
puts "Backup #{Backup::Version.current}"
end
+private
+
+ ##
+ # Helper method for asking the user if he/she wants to overwrite the file
+ def overwrite?(path)
+ if File.exist?(path)
+ exit if no? "A configuration file already exists in #{ path }. Do you want to overwrite? [y/n]"
+ end
+ end
+
end
##
View
@@ -197,8 +197,8 @@ def perform!
databases.each { |d| d.perform! }
archives.each { |a| a.perform! }
package!
- encryptors.each { |e| e.perform! }
compressors.each { |c| c.perform! }
+ encryptors.each { |e| e.perform! }
storages.each { |s| s.perform! }
notifiers.each { |n| n.perform!(self) }
clean!
View
@@ -22,7 +22,7 @@ class Version
# Defines the patch version
# BUILD:
# Defines the build version ( use 'false' if no build )
- MAJOR, MINOR, PATCH, BUILD = 3, 0, 1, 0
+ MAJOR, MINOR, PATCH, BUILD = 3, 0, 2, 0
# ========================================================= #
# ADJUST THE CONSTANTS ABOVE TO CHANGE THE BACKUP VERSION #
@@ -71,7 +71,7 @@
it 'should transfer the provided file to the container' do
Backup::Model.new('blah', 'blah') {}
file = mock("Backup::Storage::CloudFiles::File")
- File.expects(:read).with("#{File.join(Backup::TMP_PATH, "#{ Backup::TIME }.#{ Backup::TRIGGER}")}.tar").returns(file)
+ File.expects(:open).with("#{File.join(Backup::TMP_PATH, "#{ Backup::TIME }.#{ Backup::TRIGGER}")}.tar").returns(file)
cf.expects(:remote_file).returns("#{ Backup::TIME }.#{ Backup::TRIGGER }.tar").twice
connection.expects(:put_object).with('my_container', "backups/myapp/#{ Backup::TIME }.#{ Backup::TRIGGER }.tar", file)
cf.send(:transfer!)
View
@@ -77,7 +77,7 @@
it 'should transfer the provided file to the bucket' do
Backup::Model.new('blah', 'blah') {}
file = mock("Backup::Storage::S3::File")
- File.expects(:read).with("#{File.join(Backup::TMP_PATH, "#{ Backup::TIME }.#{ Backup::TRIGGER}")}.tar").returns(file)
+ File.expects(:open).with("#{File.join(Backup::TMP_PATH, "#{ Backup::TIME }.#{ Backup::TRIGGER}")}.tar").returns(file)
s3.expects(:remote_file).returns("#{ Backup::TIME }.#{ Backup::TRIGGER }.tar").twice
connection.expects(:sync_clock)
connection.expects(:put_object).with('my-bucket', "backups/myapp/#{ Backup::TIME }.#{ Backup::TRIGGER }.tar", file)

0 comments on commit 5ad9188

Please sign in to comment.