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)
- RemoteCorrupt =
Class.new(Exception)
- META_FILE =
".s3-meta-sync"- CORRUPT_FILES_LOG =
"s3-meta-sync-corrupted.log"- VERSION =
"0.3.3"
Class Method Summary collapse
Class Method Details
.parse_options(argv) ⇒ Object
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/s3_meta_sync.rb', line 230 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("--ssl-none", "Do not verify ssl certs") { |c| [:ssl_none] = true } 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 |