Module: S3MetaSync
- Defined in:
- lib/s3_meta_sync.rb,
lib/s3_meta_sync/version.rb
Defined Under Namespace
Classes: Syncer
Constant Summary collapse
- RemoteWithoutMeta =
Class.new(Exception)
- META_FILE =
".s3-meta-sync"- VERSION =
"0.2.1"
Class Method Summary collapse
Class Method Details
.parse_options(argv) ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/s3_meta_sync.rb', line 169 def (argv) = { :key => ENV["AWS_ACCESS_KEY_ID"], :secret => ENV["AWS_SECRET_ACCESS_KEY"] } OptionParser.new do |opts| opts. = <<-BANNER.gsub(/^ {10}/, "") Sync folders with s3 using a metadata file with md5 sums. # upload local files and remove everything that is not local s3-meta-sync <local> <bucket:folder> --key <aws-access-key> --secret <aws-secret-key> # download files and remove everything that is not remote s3-meta-sync <bucket:folder> <local> # no credentials required Key and secret can also be supplied using AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY Options: BANNER opts.on("-k", "--key KEY", "AWS access key") { |c| [:key] = c } opts.on("-s", "--secret SECRET", "AWS secret key") { |c| [:secret] = c } opts.on("-r", "--region REGION", "AWS region if not us-standard") { |c| [:region] = c } opts.on("-p", "--parallel COUNT", Integer, "Use COUNT threads for download/upload default: 10") { |c| [:parallel] = c } opts.on("-V", "--verbose", "Verbose mode"){ [:verbose] = true } opts.on("-h", "--help", "Show this.") { puts opts; exit } opts.on("-v", "--version", "Show Version"){ puts VERSION; exit} end.parse!(argv) raise "need source and destination" unless argv.size == 2 raise "need 1 local and 1 remote" unless argv.select { |a| a.include?(":") }.size == 1 raise "need credentials --key + --secret" if argv.last.include?(":") and (not [:key] or not [:secret]) [*argv, ] end |