Sha256: 73473b8afbdbafdd1f8785507b1250abfe680b68550301a28e0b473ec46ac742
Contents?: true
Size: 826 Bytes
Versions: 3
Compression:
Stored size: 826 Bytes
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_service, name) @ftp_service, @name = ftp_service, name end def upload(dump) dump_name = timestamped_name(dump) ftp_service.upload_file(dump.path, dump_name) logger.info "Export #{dump} #{dump_name} to #{ftp_service}" end def remove_old(keep:) ftp_service.list(ftp_regex).drop(keep.to_i).each do |filename| ftp_service.delete(filename) logger.info "Remove #{filename} from FTP" end end private attr_reader :ftp_service, :name def timestamped_name(dump) name + Time.now.strftime(TIMESTAMP) + dump.ext end def ftp_regex name + '_*' end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pg_export-0.3.2 | lib/pg_export/services/dump_storage.rb |
pg_export-0.3.1 | lib/pg_export/services/dump_storage.rb |
pg_export-0.3.0 | lib/pg_export/services/dump_storage.rb |