Sha256: 9a998e60b274f692d65297f858255fdebed08af23af9a2fb2170cfdc832bd7db
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
class PgExport class DumpStorage include Logging TIMESTAMP = '_%Y%m%d_%H%M%S'.freeze TIMESTAMP_REGEX = '[0-9]{8}_[0-9]{6}'.freeze def initialize(ftp_adapter, name, keep) @ftp_adapter, @name, @keep = ftp_adapter, name, keep end def upload(dump) dump_name = timestamped_name(dump) ftp_adapter.upload_file(dump.path, dump_name) logger.info "Upload #{dump} #{dump_name} to #{ftp_adapter}" end def download(name) dump = Dump.new('Encrypted Dump') ftp_adapter.download_file(dump.path, name) logger.info "Download #{dump} #{name} from #{ftp_adapter}" dump end def remove_old find_by_name(name).drop(keep.to_i).each do |filename| ftp_adapter.delete(filename) logger.info "Remove #{filename} from #{ftp_adapter}" end end def find_by_name(s) ftp_adapter.list(s + '_*') end def all ftp_adapter.list('*') end private attr_reader :ftp_adapter, :name, :keep def timestamped_name(dump) name + Time.now.strftime(TIMESTAMP) + dump.ext end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pg_export-0.5.1 | lib/pg_export/services/dump_storage.rb |