Sha256: 5abed06a9a3bc1d723965c681b750edd91b40c95be5f7002978a719248bb1da7

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

#! /usr/bin/env ruby

require 'uri'

if ARGV.size != 2
  puts <<EOF
Usage: #{$0} src_db|dirname dst_db|dirname

dirname contains a set of wyrm files, or will soon.

sample db strings:
  postgres://localhost/lotsa_datsa
  mysql://root:pwned@localhost/lotsa_datsa
  mysql2://root:pwned@localhost/lotsa_fastsa_datsa
EOF
  exit(1)
end

module FsPath
  def fs_path?
    scheme == 'file' || scheme.nil?
  end
end

src, dst = ARGV.map{|arg| URI.parse(arg).extend(FsPath)}

require 'wyrm/cli'
Wyrm.sanity_check_pbzip2

include Wyrm

case
when src.fs_path? && dst.fs_path?
  puts "No point copying one directory to another. Just use filesystem tools. It's faster."
  exit(1)

when !src.fs_path? && dst.fs_path?
  # src is a url, and dst is a path, so dump to file system
  require 'wyrm/dump'
  Dump.new( src.to_s, dst.path ).call

when src.fs_path? && !dst.fs_path?
  # src is a path and dst is a url, so restore to db
  require 'wyrm/restore'
  Restore.new(src.path, dst.to_s, drop_tables: true).call

else
  # both db urls, so transfer
  require 'wyrm/hole.rb'
  Hole.new( src.to_s, dst.to_s ).call

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wyrm-0.4.0 bin/wyrm
wyrm-0.3.3 bin/wyrm
wyrm-0.3.2 bin/wyrm
wyrm-0.3.1 bin/wyrm
wyrm-0.3.0 bin/wyrm