wyrm 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.txt +5 -0
- data/README.md +36 -11
- data/bin/wyrm +7 -1
- data/bin/wyrm-view +4 -3
- data/lib/wyrm/cli.rb +6 -3
- data/lib/wyrm/dump.rb +1 -1
- data/lib/wyrm/module.rb +4 -1
- data/lib/wyrm/restore.rb +1 -1
- data/lib/wyrm/version.rb +1 -1
- data/spec/wyrm_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da207f92151b080d31039a364c1a2c50022f01ff
|
4
|
+
data.tar.gz: ddf38f48b42597ed08671cb67fadd8457e425e07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03e699a00d14fa7baacc286b886cf35074766b7b6b3b8e6e10fde08779ded7fda4930f9666bad95274bf773f8fe33f1916f3836414e98c188c81963b3a01459c
|
7
|
+
data.tar.gz: 0052a0b096e62662223f9e4a9da2cfd79e2908f033f83a7a9201463aac3ec9f56407299b68e461b9b850f39ea8c3da5e53c48ad7510561d680b601a38ce739ca
|
data/History.txt
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
== 0.4.1
|
2
|
+
* Improve docs and examples
|
3
|
+
* make pbzip2 somewhat configurable.
|
4
|
+
|
1
5
|
== 0.4.0
|
2
6
|
* Update for released ruby-2.3 Queue#close
|
3
7
|
* use &. instead of andand
|
@@ -9,5 +13,6 @@
|
|
9
13
|
|
10
14
|
== 0.3.3
|
11
15
|
* minor fix when src/dst directory not found
|
16
|
+
|
12
17
|
== 0.3.2
|
13
18
|
* update for >=sequel-4.10.0 internal syntax (Dataset#clause_sql removed)
|
data/README.md
CHANGED
@@ -4,15 +4,15 @@
|
|
4
4
|
[](https://travis-ci.org/djellemah/wyrm)
|
5
5
|
-->
|
6
6
|
|
7
|
-
Transfer a database from one rdbms to another (eg mysql to
|
8
|
-
a set of files, or direct from one db server to another.
|
7
|
+
Transfer a database (or single tables) from one rdbms to another (eg mysql to
|
8
|
+
postgres). Either via a set of files, or direct from one db server to another.
|
9
9
|
|
10
10
|
Has been used to dump > 100M dbs, and one 850G db.
|
11
11
|
Should theoretically work for any rdbms supported by [Sequel](http://sequel.jeremyevans.net/).
|
12
12
|
|
13
|
-
Dumps are compressed with bz2, using pbzip2. Fast *and* small :-D
|
14
|
-
mysqldump | bzip2 for a certain 850G db comes to 127G. With wyrm
|
15
|
-
comes to 134G.
|
13
|
+
Dumps are (usually) compressed with bz2, using pbzip2. Fast *and* small :-D
|
14
|
+
For example: mysqldump | bzip2 for a certain 850G db comes to 127G. With wyrm
|
15
|
+
it comes to 134G.
|
16
16
|
|
17
17
|
Transfers tables and views only. Does not attempt to transfer
|
18
18
|
stored procs, permissions, triggers etc.
|
@@ -26,13 +26,14 @@ Will use result set streaming if available.
|
|
26
26
|
Wyrm because:
|
27
27
|
|
28
28
|
- I like dragons
|
29
|
-
- I can have a Wyrm::Hole to transfer data
|
29
|
+
- I can have a Wyrm::Hole to transfer data O-;-)
|
30
30
|
|
31
31
|
## Dependencies
|
32
32
|
|
33
33
|
You must have a working
|
34
34
|
[pbzip2](http://compression.ca/pbzip2/ "Will use all your cores")
|
35
|
-
on your path.
|
35
|
+
on your path. If you really have to use something else,
|
36
|
+
reassign ```Wyrm::STREAM_DCMP``` and ```Wyrm::STREAM_COMP``` .
|
36
37
|
|
37
38
|
## Installation
|
38
39
|
|
@@ -75,25 +76,49 @@ On the destination host
|
|
75
76
|
|
76
77
|
$ wyrm /tmp/lots_fs_space postgres://localhost/betta_dee_bee
|
77
78
|
|
79
|
+
#### View contents of a dump file as yaml
|
80
|
+
|
81
|
+
$ wyrm-view /tmp/lots_fs_space/some_table.dbp.bz2
|
82
|
+
|
78
83
|
### irb / pry
|
79
84
|
|
80
85
|
For restoring. dump will be similar.
|
81
86
|
|
82
87
|
``` ruby
|
83
88
|
require 'wyrm/restore_schema'
|
89
|
+
|
84
90
|
rs = Restore.new 'postgres://postgres@localhost/your_db', '/mnt/disk/wyrm'
|
85
91
|
rs.call
|
86
92
|
```
|
87
93
|
|
88
|
-
|
94
|
+
Directly transferring one table:
|
89
95
|
|
90
96
|
``` ruby
|
91
97
|
require 'sequel'
|
98
|
+
require 'wyrm/hole'
|
99
|
+
|
100
|
+
hole = Wyrm::Hole.new 'mysql2://localhost/beeg_data_bays', 'postgres://localhost/betta_dee_bee'
|
101
|
+
|
102
|
+
# transfer schema (no indexes), using Sequel::SchemaDumper extension, see
|
103
|
+
# Sequel::SchemaDumper#dump_schema_migration for options
|
104
|
+
table_schema = hole.src_db.dump_table_schema :the_stuff_you_want
|
105
|
+
Sequel.migration{ change{ eval table_schema } }.apply hole.dst_db, :up
|
106
|
+
|
107
|
+
hole.transfer_table :the_stuff_you_want
|
108
|
+
|
109
|
+
# it's just Sequel...
|
110
|
+
hold.dst_db[:the_stuff_you_want].where( some_thing: /a pattern/ ).limit(10).all
|
111
|
+
```
|
112
|
+
|
113
|
+
Get to the dumped rows:
|
114
|
+
|
115
|
+
``` ruby
|
116
|
+
require 'sequel' # for some demarshaling
|
92
117
|
require 'wyrm/pump'
|
93
118
|
|
94
|
-
|
95
|
-
|
96
|
-
|
119
|
+
dbp = Wyrm::Pump.new io: IO.popen('pbzip2 -d -c /mnt/disk/wyrm/things.dbp.bz2')
|
120
|
+
# each_row also returns an Enumerator if no block is given, similar to much
|
121
|
+
# ruby core stuff. Although it's not rewindable.
|
97
122
|
dbp.each_row do |row|
|
98
123
|
puts row.inspect
|
99
124
|
end
|
data/bin/wyrm
CHANGED
@@ -3,7 +3,12 @@
|
|
3
3
|
require 'uri'
|
4
4
|
|
5
5
|
if ARGV.size != 2
|
6
|
+
require 'wyrm/version'
|
7
|
+
|
6
8
|
puts <<EOF
|
9
|
+
|
10
|
+
wyrm-#{Wyrm::VERSION}
|
11
|
+
|
7
12
|
Usage: #{$0} src_db|dirname dst_db|dirname
|
8
13
|
|
9
14
|
dirname contains a set of wyrm files, or will soon.
|
@@ -12,6 +17,7 @@ sample db strings:
|
|
12
17
|
postgres://localhost/lotsa_datsa
|
13
18
|
mysql://root:pwned@localhost/lotsa_datsa
|
14
19
|
mysql2://root:pwned@localhost/lotsa_fastsa_datsa
|
20
|
+
|
15
21
|
EOF
|
16
22
|
exit(1)
|
17
23
|
end
|
@@ -25,7 +31,7 @@ end
|
|
25
31
|
src, dst = ARGV.map{|arg| URI.parse(arg).extend(FsPath)}
|
26
32
|
|
27
33
|
require 'wyrm/cli'
|
28
|
-
Wyrm.
|
34
|
+
Wyrm.sanity_check_dcmp
|
29
35
|
|
30
36
|
include Wyrm
|
31
37
|
|
data/bin/wyrm-view
CHANGED
@@ -4,16 +4,17 @@ if ARGV.empty? || ARGV.first =~ /^-+(\?|h(elp)?)$/
|
|
4
4
|
puts <<EOF
|
5
5
|
Usage: #{$0} dbp_file.dbp[.bz2]
|
6
6
|
|
7
|
-
Display contents of dbp file, optionally compressed with bz2.
|
7
|
+
Display contents of dbp file in yaml, optionally compressed with bz2.
|
8
8
|
EOF
|
9
9
|
exit(0)
|
10
10
|
end
|
11
11
|
|
12
12
|
require 'wyrm/cli'
|
13
|
-
Wyrm.
|
13
|
+
Wyrm.sanity_check_dcmp
|
14
14
|
|
15
15
|
require 'pathname'
|
16
16
|
require 'yaml'
|
17
|
+
require 'sequel' # needed for demarshalling some types
|
17
18
|
|
18
19
|
out_block = lambda do |io|
|
19
20
|
record_count = 1
|
@@ -27,7 +28,7 @@ end
|
|
27
28
|
ARGV.map{|a| Pathname(a)}.each do |path|
|
28
29
|
puts "# source: #{path}"
|
29
30
|
if path.extname == '.bz2'
|
30
|
-
IO.popen "
|
31
|
+
IO.popen "#{Wyrm::STREAM_DCMP} #{path}", &out_block
|
31
32
|
else
|
32
33
|
path.open &out_block
|
33
34
|
end
|
data/lib/wyrm/cli.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
+
require 'wyrm/module'
|
2
|
+
|
1
3
|
module Wyrm
|
2
|
-
def self.
|
3
|
-
|
4
|
+
def self.sanity_check_dcmp
|
5
|
+
bzip_cmd = Wyrm::STREAM_DCMP.split(' ').first
|
6
|
+
rv = `which #{bzip_cmd}`
|
4
7
|
unless $?.exitstatus == 0
|
5
|
-
puts "\
|
8
|
+
puts "\n#{cmd} not installed or not in PATH"
|
6
9
|
exit(1)
|
7
10
|
end
|
8
11
|
end
|
data/lib/wyrm/dump.rb
CHANGED
@@ -52,7 +52,7 @@ class Wyrm::Dump
|
|
52
52
|
def write_through_bz2( pathname )
|
53
53
|
fio = pathname.open('w')
|
54
54
|
# open subprocess in read-write mode
|
55
|
-
zio = IO.popen(
|
55
|
+
zio = IO.popen( STREAM_COMP, 'r+' )
|
56
56
|
copier = Thread.new do
|
57
57
|
begin
|
58
58
|
IO.copy_stream zio, fio
|
data/lib/wyrm/module.rb
CHANGED
data/lib/wyrm/restore.rb
CHANGED
data/lib/wyrm/version.rb
CHANGED
data/spec/wyrm_spec.rb
CHANGED
@@ -8,6 +8,6 @@ include Wyrm
|
|
8
8
|
|
9
9
|
describe Wyrm do
|
10
10
|
it 'has the right constants' do
|
11
|
-
Wyrm.constants.sort.should == [:Dump, :Hole, :Logger, :Pump, :PumpMaker, :Restore, :SchemaTools, :VERSION].sort
|
11
|
+
Wyrm.constants.sort.should == [:Dump, :Hole, :Logger, :Pump, :PumpMaker, :Restore, :SchemaTools, :VERSION, :STREAM_COMP, :STREAM_DCMP].sort
|
12
12
|
end
|
13
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wyrm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Anderson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|