Skip to content

Commit

Permalink
Merge branch 'master' of github.com:wr0ngway/rubber
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Conway committed Mar 22, 2011
2 parents 21a41d5 + add1ef6 commit ea26d35
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/rubber/tasks/rubber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,16 @@ def init_s3()
dir = get_env('BACKUP_DIR', true)
age = (get_env('BACKUP_AGE') || 3).to_i
time_stamp = Time.now.strftime("%Y-%m-%d_%H-%M")
backup_file = "#{dir}/#{RUBBER_ENV}_dump_#{time_stamp}.sql.gz"
FileUtils.mkdir_p(File.dirname(backup_file))

user = get_env('DBUSER', true)
pass = get_env('DBPASS')
pass = nil if (pass.nil? || pass.strip.size == 0)
host = get_env('DBHOST', true)
name = get_env('DBNAME', true)

backup_file = "#{dir}/#{RUBBER_ENV}_#{name}_dump_#{time_stamp}.sql.gz"
FileUtils.mkdir_p(File.dirname(backup_file))

raise "No db_backup_cmd defined in rubber.yml, cannot backup!" unless rubber_env.db_backup_cmd
db_backup_cmd = rubber_env.db_backup_cmd.gsub(/%([^%]+)%/, '#{\1}')
db_backup_cmd = eval('%Q{' + db_backup_cmd + '}')
Expand Down Expand Up @@ -256,7 +257,8 @@ def init_s3()
data = s3objects.detect { |o| file == o.key }
else
puts "trying to fetch last modified s3 backup"
data = s3objects.max {|a,b| a.about["last-modified"] <=> b.about["last-modified"] }
filtered = s3objects.select { |f| f.path =~ /#{RUBBER_ENV}_#{name}/ }
data = filtered.max {|a,b| a.about["last-modified"] <=> b.about["last-modified"] }
end
end
raise "could not access backup file via s3" unless data
Expand Down

0 comments on commit ea26d35

Please sign in to comment.