Class: Mys3ql::S3
Instance Method Summary collapse
- #delete_bin_logs ⇒ Object
- #each_bin_log(&block) ⇒ Object
-
#initialize(config) ⇒ S3
constructor
A new instance of S3.
- #retrieve(s3_file, local_file) ⇒ Object
- #store(file, dump = true) ⇒ Object
Methods included from Shell
Constructor Details
#initialize(config) ⇒ S3
Returns a new instance of S3.
8 9 10 11 |
# File 'lib/mys3ql/s3.rb', line 8 def initialize(config) @config = config Fog::Logger[:warning] = nil end |
Instance Method Details
#delete_bin_logs ⇒ Object
23 24 25 26 27 28 |
# File 'lib/mys3ql/s3.rb', line 23 def delete_bin_logs each_bin_log do |file| file.destroy log "s3: deleted #{file.key}" end end |
#each_bin_log(&block) ⇒ Object
30 31 32 33 34 |
# File 'lib/mys3ql/s3.rb', line 30 def each_bin_log(&block) bucket.files.all(:prefix => "#{bin_logs_prefix}").sort_by { |file| file.key[/\d+/].to_i }.each do |file| yield file end end |
#retrieve(s3_file, local_file) ⇒ Object
36 37 38 39 |
# File 'lib/mys3ql/s3.rb', line 36 def retrieve(s3_file, local_file) key = (s3_file == :latest) ? key_for(:latest) : s3_file.key get key, local_file end |
#store(file, dump = true) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/mys3ql/s3.rb', line 13 def store(file, dump = true) key = key_for(dump ? :dump : :bin_log, file) s3_file = save file, key if dump && s3_file copy_key = key_for :latest s3_file.copy @config.bucket, copy_key log "s3: copied #{key} to #{copy_key}" end end |