redis-dump 0.4.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGES.txt +18 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +76 -0
- data/LICENSE.txt +7 -5
- data/README.md +82 -0
- data/Rakefile +5 -56
- data/{bin → exe}/redis-dump +3 -0
- data/lib/redis/dump/version.rb +7 -0
- data/lib/redis/dump.rb +15 -22
- data/redis-dump.gemspec +23 -0
- data/sig/redis/dump.rbs +6 -0
- metadata +24 -106
- checksums.yaml.gz.sig +0 -1
- data/README.rdoc +0 -107
- data/VERSION +0 -1
- data/try/10_redis_dump_try.rb +0 -62
- data/try/20_dump_specific_keys_try.rb +0 -44
- data/try/30_dump_base64_try.rb +0 -58
- data/try/db0.json +0 -5
- data/try/redis.conf +0 -35
- data.tar.gz.sig +0 -3
- metadata.gz.sig +0 -0
- /data/{bin → exe}/redis-load +0 -0
- /data/{bin → exe}/redis-report +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5ae875f0b9d36b8e678c2bca1e61cab964b4e569082c3d2bcf9a011946fae691
|
4
|
+
data.tar.gz: ecd31cd6af2db2b240acd04feac2ac999f5b128feaa4ed590016aca9fa57cf5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 138c2807ba899096b173b6fb2fd5a82fde3cd90d0bcd5cd3f32d950ebffa39a6f56df8fafaba3c390862b6513f36bdc10c1259c14cbc5237dc2ffa688198e704
|
7
|
+
data.tar.gz: 76a7e3f910c9a5bc8af9ac7486952735db4aa8cb3b57934a98d5caf6ab362cad3b574b97ed59a639a0530872d1f1b96eff7435a854ec9a4b58caadeba1405ac9
|
data/CHANGES.txt
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
REDIS-DUMP, CHANGES
|
2
2
|
|
3
|
+
#### 0.6.1 (2024-06-17) ###############################
|
4
|
+
|
5
|
+
* FIXED: Gem path for redis-dump, redis-load, redis-report executables
|
6
|
+
|
7
|
+
#### 0.6.0 (2024-06-17) ###############################
|
8
|
+
|
9
|
+
* ADDED: Supports redis-rb 5.0
|
10
|
+
* ADDED: Supports SSL via rediss://
|
11
|
+
* CHANGED: Updated dependencies (see https://github.com/delano/redis-dump/pull/37)
|
12
|
+
* FIXED: Resolved `sadd` warnings in redis 4.0 #35
|
13
|
+
|
14
|
+
|
15
|
+
#### 0.5.0 (2023-01-17) ###############################
|
16
|
+
|
17
|
+
* ADDED: Timeout support for redis connections
|
18
|
+
* CHANGED: uri-redis dependency to 1.0.0
|
19
|
+
|
20
|
+
|
3
21
|
#### 0.4.0 (2017-11-23) ###############################
|
4
22
|
|
5
23
|
* ADDED: support for redis >= 4.0
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "drydock", ">= 0.6.9"
|
6
|
+
gem "oj", ">= 3.16.4"
|
7
|
+
gem "redis", ">= 4.0", "< 6.0"
|
8
|
+
gem "uri-redis", ">= 1.3.0"
|
9
|
+
gem "yajl-ruby", ">= 1.4.3"
|
10
|
+
|
11
|
+
gem "pry-byebug", "~> 3.10.1", require: false, group: :development
|
12
|
+
gem "rake", "~> 13.0", require: false, group: :development
|
13
|
+
gem "rubocop", "~> 1.64.1", require: false, group: :development
|
14
|
+
gem "tryouts", "~> 2.2.0", require: false, group: :development
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
ast (2.4.2)
|
5
|
+
bigdecimal (3.1.8)
|
6
|
+
byebug (11.1.3)
|
7
|
+
coderay (1.1.3)
|
8
|
+
connection_pool (2.4.1)
|
9
|
+
drydock (0.6.9)
|
10
|
+
json (2.7.2)
|
11
|
+
language_server-protocol (3.17.0.3)
|
12
|
+
method_source (1.1.0)
|
13
|
+
oj (3.16.4)
|
14
|
+
bigdecimal (>= 3.0)
|
15
|
+
parallel (1.25.1)
|
16
|
+
parser (3.3.3.0)
|
17
|
+
ast (~> 2.4.1)
|
18
|
+
racc
|
19
|
+
pry (0.14.2)
|
20
|
+
coderay (~> 1.1)
|
21
|
+
method_source (~> 1.0)
|
22
|
+
pry-byebug (3.10.1)
|
23
|
+
byebug (~> 11.0)
|
24
|
+
pry (>= 0.13, < 0.15)
|
25
|
+
racc (1.8.0)
|
26
|
+
rainbow (3.1.1)
|
27
|
+
rake (13.2.1)
|
28
|
+
redis (5.2.0)
|
29
|
+
redis-client (>= 0.22.0)
|
30
|
+
redis-client (0.22.2)
|
31
|
+
connection_pool
|
32
|
+
regexp_parser (2.9.2)
|
33
|
+
rexml (3.3.0)
|
34
|
+
strscan
|
35
|
+
rubocop (1.64.1)
|
36
|
+
json (~> 2.3)
|
37
|
+
language_server-protocol (>= 3.17.0)
|
38
|
+
parallel (~> 1.10)
|
39
|
+
parser (>= 3.3.0.2)
|
40
|
+
rainbow (>= 2.2.2, < 4.0)
|
41
|
+
regexp_parser (>= 1.8, < 3.0)
|
42
|
+
rexml (>= 3.2.5, < 4.0)
|
43
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
44
|
+
ruby-progressbar (~> 1.7)
|
45
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
46
|
+
rubocop-ast (1.31.3)
|
47
|
+
parser (>= 3.3.1.0)
|
48
|
+
ruby-progressbar (1.13.0)
|
49
|
+
storable (0.10.0)
|
50
|
+
strscan (3.1.0)
|
51
|
+
sysinfo (0.10.0)
|
52
|
+
drydock (< 1.0)
|
53
|
+
storable (~> 0.10)
|
54
|
+
tryouts (2.2.0)
|
55
|
+
sysinfo (~> 0.10)
|
56
|
+
unicode-display_width (2.5.0)
|
57
|
+
uri-redis (1.3.0)
|
58
|
+
yajl-ruby (1.4.3)
|
59
|
+
|
60
|
+
PLATFORMS
|
61
|
+
arm64-darwin-22
|
62
|
+
ruby
|
63
|
+
|
64
|
+
DEPENDENCIES
|
65
|
+
drydock (>= 0.6.9)
|
66
|
+
oj (>= 3.16.4)
|
67
|
+
pry-byebug (~> 3.10.1)
|
68
|
+
rake (~> 13.0)
|
69
|
+
redis (>= 4.0, < 6.0)
|
70
|
+
rubocop (~> 1.64.1)
|
71
|
+
tryouts (~> 2.2.0)
|
72
|
+
uri-redis (>= 1.3.0)
|
73
|
+
yajl-ruby (>= 1.4.3)
|
74
|
+
|
75
|
+
BUNDLED WITH
|
76
|
+
2.5.13
|
data/LICENSE.txt
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2010-2024 Delano Mandelbaum
|
2
4
|
|
3
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
6
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -7,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
9
|
copies of the Software, and to permit persons to whom the Software is
|
8
10
|
furnished to do so, subject to the following conditions:
|
9
11
|
|
10
|
-
The above copyright notice and this permission notice shall be included in
|
11
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
12
14
|
|
13
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# Redis::Dump - v0.6.0
|
2
|
+
|
3
|
+
*Redis to JSON and back again. Dump and load Redis databases to/from JSON files.*
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
One of:
|
9
|
+
1. Gemfile: `gem 'redis-dump', '~> 0.4.0'`
|
10
|
+
2. Install manually: `gem install redis-dump`
|
11
|
+
3. Clone with git: `git clone git@github.com:delano/redis-dump.git`
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
There are two executables: `redis-dump` and `redis-load`.
|
18
|
+
|
19
|
+
```bash
|
20
|
+
$ redis-dump
|
21
|
+
$ redis-dump -u 127.0.0.1:6379 > db_full.json
|
22
|
+
$ redis-dump -u 127.0.0.1:6379 -d 15 > db_db15.json
|
23
|
+
|
24
|
+
$ < db_full.json redis-load
|
25
|
+
$ < db_db15.json redis-load -d 15
|
26
|
+
# OR
|
27
|
+
$ cat db_full | redis-load
|
28
|
+
$ cat db_db15.json | redis-load -d 15
|
29
|
+
|
30
|
+
# You can specify the redis URI via an environment variable
|
31
|
+
$ export REDIS_URI=127.0.0.1:6379
|
32
|
+
$ redis-dump
|
33
|
+
|
34
|
+
# If your instance uses a password (such as on RedisToGo), you
|
35
|
+
# can specify the Redis URL as such:
|
36
|
+
# :<password>@<domain>:<port>
|
37
|
+
# Note the leading colon is important for specifying no username.
|
38
|
+
$ redis-dump -u :234288a830f009980e08@example.redistogo.com:9055
|
39
|
+
```
|
40
|
+
|
41
|
+
### Output format
|
42
|
+
|
43
|
+
All redis datatypes are output to a simple JSON object. All objects have the following 5 fields:
|
44
|
+
|
45
|
+
* db (Integer)
|
46
|
+
* key (String)
|
47
|
+
* ttl (Integer): The amount of time in seconds that the key will live. If no expire is set, it's -1.
|
48
|
+
* type (String), one of: string, list, set, zset, hash, none.
|
49
|
+
* value (String): A JSON-encoded string. For keys of type list, set, zset, and hash, the data is given a specific structure (see below).
|
50
|
+
|
51
|
+
Here are examples of each datatype:
|
52
|
+
|
53
|
+
```json
|
54
|
+
{"db":0,"key":"hashkey","ttl":-1,"type":"hash","value":{"field_a":"value_a","field_b":"value_b","field_c":"value_c"},"size":42}
|
55
|
+
{"db":0,"key":"listkey","ttl":-1,"type":"list","value":["value_0","value_1","value_2","value_0","value_1","value_2"],"size":42}
|
56
|
+
{"db":0,"key":"setkey","ttl":-1,"type":"set","value":["value_2","value_0","value_1","value_3"],"size":28}
|
57
|
+
{"db":0,"key":"zsetkey","ttl":-1,"type":"zset","value":[["value_0","100"],["value_1","100"],["value_2","200"],["value_3","300"],["value_4","400"]],"size":50}
|
58
|
+
{"db":0,"key":"stringkey","ttl":79,"type":"string","value":"stringvalue","size":11}
|
59
|
+
```
|
60
|
+
|
61
|
+
## Important notes
|
62
|
+
|
63
|
+
### About TTLs
|
64
|
+
|
65
|
+
One of the purposes of redis-dump is the ability to restore the database to a known state. When you restore a redis database from a redis-dump file, *the expires are reset to their values at the time the dump was created*. This is different from restoring from Redis' native .rdb or .aof files (expires are stored relative to the actual time they were set).
|
66
|
+
|
67
|
+
### Output directly to an encrypted file
|
68
|
+
|
69
|
+
For most sensitive data, you should consider encrypting the data directly without writing first to a temp file. You can do this using the power of [gpg](http://www.gnupg.org/) and file descriptors. Here are a couple examples:
|
70
|
+
|
71
|
+
```bash
|
72
|
+
# Encrypt the data (interactive)
|
73
|
+
$ redis-dump -u 127.0.0.1:6379 -d 15 | gpg --force-mdc -v -c > path/2/backup-db1
|
74
|
+
```
|
75
|
+
|
76
|
+
## Contributing
|
77
|
+
|
78
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/delano/redis-dump.
|
79
|
+
|
80
|
+
## License
|
81
|
+
|
82
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -1,59 +1,8 @@
|
|
1
|
-
|
2
|
-
require "rake"
|
3
|
-
require "rake/clean"
|
4
|
-
require "rdoc/task"
|
1
|
+
# frozen_string_literal: true
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
name = "redis-dump"
|
9
|
-
|
10
|
-
$:.unshift File.join(File.dirname(__FILE__), 'lib')
|
11
|
-
require "redis/dump"
|
12
|
-
version = Redis::Dump::VERSION.to_s
|
13
|
-
|
14
|
-
begin
|
15
|
-
require "jeweler"
|
16
|
-
Jeweler::Tasks.new do |s|
|
17
|
-
s.version = version
|
18
|
-
s.name = name
|
19
|
-
s.summary = "Backup and restore your Redis data to and from JSON."
|
20
|
-
s.description = s.summary
|
21
|
-
s.email = "delano@solutious.com"
|
22
|
-
s.homepage = "http://github.com/delano/redis-dump"
|
23
|
-
s.authors = ["Delano Mandelbaum"]
|
24
|
-
|
25
|
-
s.add_dependency("yajl-ruby", ">= 0.1")
|
26
|
-
s.add_dependency("redis", ">= 4.0")
|
27
|
-
s.add_dependency("uri-redis", ">= 0.4.0")
|
28
|
-
s.add_dependency("drydock", ">= 0.6.9")
|
29
|
-
|
30
|
-
s.license = "MIT"
|
31
|
-
|
32
|
-
s.signing_key = File.join('/mnt/gem/', 'gem-private_key.pem')
|
33
|
-
s.cert_chain = ['gem-public_cert.pem']
|
34
|
-
end
|
35
|
-
Jeweler::GemcutterTasks.new
|
36
|
-
rescue LoadError
|
37
|
-
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
38
|
-
end
|
39
|
-
|
40
|
-
require 'rake/testtask'
|
41
|
-
Rake::TestTask.new do |t|
|
42
|
-
t.libs = ["lib", "test"]
|
43
|
-
end
|
44
|
-
|
45
|
-
extra_files = %w[LICENSE.txt THANKS.txt CHANGES.txt ]
|
46
|
-
RDoc::Task.new do |rdoc|
|
47
|
-
rdoc.rdoc_dir = "rdoc"
|
48
|
-
rdoc.title = "#{name} #{version}"
|
49
|
-
rdoc.generator = 'hanna' # gem install hanna-nouveau
|
50
|
-
rdoc.main = 'README.rdoc'
|
51
|
-
rdoc.rdoc_files.include("README*")
|
52
|
-
rdoc.rdoc_files.include("bin/*.rb")
|
53
|
-
rdoc.rdoc_files.include("lib/**/*.rb")
|
54
|
-
extra_files.each { |file|
|
55
|
-
rdoc.rdoc_files.include(file) if File.exists?(file)
|
56
|
-
}
|
57
|
-
end
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rubocop/rake_task"
|
58
5
|
|
6
|
+
RuboCop::RakeTask.new
|
59
7
|
|
8
|
+
task default: :rubocop
|
data/{bin → exe}/redis-dump
RENAMED
@@ -30,6 +30,9 @@ class Redis::Dump::CLI
|
|
30
30
|
global :a, :password, String, "Redis password (e.g. -a 'my@pass/word')" do |v|
|
31
31
|
Redis::Dump.password = v
|
32
32
|
end
|
33
|
+
global :t, :timeout, Integer, "Configure connect, read, and write timeouts (ruby redis client)" do |t|
|
34
|
+
Redis::Dump.timeout = t
|
35
|
+
end
|
33
36
|
global :s, :sleep, Integer, "Sleep for S seconds after dumping (for debugging)"
|
34
37
|
global :c, :count, Integer, "Chunk size (default: #{Redis::Dump.chunk_size})"
|
35
38
|
global :f, :filter, String, "Filter selected keys (passed directly to redis' KEYS command)"
|
data/lib/redis/dump.rb
CHANGED
@@ -1,12 +1,17 @@
|
|
1
|
+
|
2
|
+
|
1
3
|
unless defined?(RD_HOME)
|
2
4
|
RD_HOME = File.expand_path(File.join(File.dirname(__FILE__), '..', '..') )
|
3
5
|
end
|
4
6
|
|
5
7
|
require 'redis'
|
6
|
-
require 'uri/redis'
|
7
8
|
require 'yajl'
|
8
9
|
require 'base64'
|
9
10
|
|
11
|
+
require 'uri/redis'
|
12
|
+
|
13
|
+
require_relative "dump/version"
|
14
|
+
|
10
15
|
class Redis
|
11
16
|
class Dump
|
12
17
|
unless defined?(Redis::Dump::VALID_TYPES)
|
@@ -21,7 +26,7 @@ class Redis
|
|
21
26
|
@with_optimizations = true
|
22
27
|
@with_base64 = false
|
23
28
|
class << self
|
24
|
-
attr_accessor :debug, :encoder, :parser, :safe, :host, :port, :password, :chunk_size, :with_optimizations, :with_base64
|
29
|
+
attr_accessor :debug, :encoder, :parser, :safe, :host, :port, :password, :timeout, :chunk_size, :with_optimizations, :with_base64
|
25
30
|
def le(msg)
|
26
31
|
STDERR.puts "#%.4f: %s" % [Time.now.utc.to_f, msg]
|
27
32
|
end
|
@@ -57,6 +62,7 @@ class Redis
|
|
57
62
|
:url => this_uri
|
58
63
|
}
|
59
64
|
opts[:password] = Redis::Dump.password if Redis::Dump.password
|
65
|
+
opts[:timeout] = Redis::Dump.timeout if Redis::Dump.timeout
|
60
66
|
Redis.new **opts
|
61
67
|
end
|
62
68
|
|
@@ -71,9 +77,10 @@ class Redis
|
|
71
77
|
entries = []
|
72
78
|
each_database do |redis|
|
73
79
|
chunk_entries = []
|
80
|
+
Redis::Dump.ld "[db#{redis.connection[:db]}] Memory before: #{Redis::Dump.memory_usage}kb"
|
74
81
|
dump_keys = redis.keys(filter)
|
75
82
|
dump_keys_size = dump_keys.size
|
76
|
-
Redis::Dump.ld "
|
83
|
+
Redis::Dump.ld "[db#{redis.connection[:db]}] Dumping #{dump_keys_size} keys: #{dump_keys.join(', ')}"
|
77
84
|
dump_keys.each_with_index do |key,idx|
|
78
85
|
entry, idxplus = key, idx+1
|
79
86
|
if block_given?
|
@@ -103,6 +110,8 @@ class Redis
|
|
103
110
|
entries << self.class.encoder.encode(Redis::Dump.dump(redis, entry))
|
104
111
|
end
|
105
112
|
end
|
113
|
+
|
114
|
+
Redis::Dump.ld "[db#{redis.connection[:db]}] Memory after: #{Redis::Dump.memory_usage}kb"
|
106
115
|
end
|
107
116
|
entries
|
108
117
|
end
|
@@ -157,7 +166,9 @@ class Redis
|
|
157
166
|
end
|
158
167
|
begin
|
159
168
|
val, type = obj['value'], obj['type']
|
169
|
+
Redis::Dump.ld " > load `#{val}`"
|
160
170
|
if Redis::Dump.with_base64 && type === 'string'
|
171
|
+
Redis::Dump.ld " > load+decode64 for `#{val}`"
|
161
172
|
val = Base64.decode64 val
|
162
173
|
end
|
163
174
|
ret = Redis::Dump.set_value this_redis, obj['key'], type, val, obj['ttl']
|
@@ -233,7 +244,7 @@ class Redis
|
|
233
244
|
list.each { |value| this_redis.rpush key, value }
|
234
245
|
end
|
235
246
|
def set_value_set(this_redis, key, set)
|
236
|
-
set.each { |value| this_redis.sadd key, value }
|
247
|
+
set.each { |value| this_redis.sadd? key, value }
|
237
248
|
end
|
238
249
|
def set_value_zset(this_redis, key, zset)
|
239
250
|
zset.each { |pair| this_redis.zadd key, pair[1].to_f, pair[0] }
|
@@ -260,24 +271,6 @@ class Redis
|
|
260
271
|
end
|
261
272
|
extend Redis::Dump::ClassMethods
|
262
273
|
|
263
|
-
module VERSION
|
264
|
-
@path = File.join(RD_HOME, 'VERSION')
|
265
|
-
class << self
|
266
|
-
attr_reader :version, :path
|
267
|
-
def version
|
268
|
-
@version || read_version
|
269
|
-
end
|
270
|
-
def read_version
|
271
|
-
return if @version
|
272
|
-
@version = File.read(path).strip!
|
273
|
-
end
|
274
|
-
def prerelease?() false end
|
275
|
-
def to_a() version.split('.') end
|
276
|
-
def to_s() version end
|
277
|
-
def inspect() version end
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
274
|
class Problem < RuntimeError
|
282
275
|
def initialize(*args)
|
283
276
|
@args = args.flatten.compact
|
data/redis-dump.gemspec
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/redis/dump/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "redis-dump"
|
7
|
+
spec.version = Redis::Dump::VERSION
|
8
|
+
spec.authors = ["delano"]
|
9
|
+
spec.email = "gems@solutious.com"
|
10
|
+
|
11
|
+
spec.summary = "Backup and restore your Redis data to and from JSON."
|
12
|
+
spec.description = "Backup and restore your Redis data to and from JSON by database, key, or key pattern."
|
13
|
+
spec.homepage = "https://rubygems.org/gems/redis-dump"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.8")
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{\A(?:bin|test|spec|features|try)/|\.(?:git|circleci)|appveyor|pre|rub})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
end
|
data/sig/redis/dump.rbs
ADDED
metadata
CHANGED
@@ -1,125 +1,44 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-dump
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
10
|
-
cert_chain:
|
11
|
-
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
ZXRzc2gxGTAXBgoJkiaJk/IsZAEZFglzb2x1dGlvdXMxEzARBgoJkiaJk/IsZAEZ
|
17
|
-
FgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDGJ4TbZ9H+qZ08
|
18
|
-
pQfJhPJTHaDCyQvCsKTFrL5O9z3tllQ7B/zksMMM+qFBpNYu9HCcg4yBATacE/PB
|
19
|
-
qVVyUrpr6lbH/XwoN5ljXm+bdCfmnjZvTCL2FTE6o+bcnaF0IsJyC0Q2B1fbWdXN
|
20
|
-
6Off1ZWoUk6We2BIM1bn6QJLxBpGyYhvOPXsYoqSuzDf2SJDDsWFZ8kV5ON13Ohm
|
21
|
-
JbBzn0oD8HF8FuYOewwsC0C1q4w7E5GtvHcQ5juweS7+RKsyDcVcVrLuNzoGRttS
|
22
|
-
KP4yMn+TzaXijyjRg7gECfJr3TGASaA4bQsILFGG5dAWcwO4OMrZedR7SHj/o0Kf
|
23
|
-
3gL7P0axAgMBAAGjezB5MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
|
24
|
-
BBQF8qLA7Z4zg0SJGtUbv3eoQ8tjIzAfBgNVHREEGDAWgRRuZXRzc2hAc29sdXRp
|
25
|
-
b3VzLmNvbTAfBgNVHRIEGDAWgRRuZXRzc2hAc29sdXRpb3VzLmNvbTANBgkqhkiG
|
26
|
-
9w0BAQUFAAOCAQEATd8If+Ytmhf5lELy24j76ahGv64m518WTCdV2nIViGXB2BnV
|
27
|
-
uLQylGRb1rcgUS3Eh9TE28hqrfhotKS6a96qF9kN0mY2H6UwPWswJ+tj3gA1vLW8
|
28
|
-
wlZNlYGJ91Ig9zULPSbATyOOprUZyggy5p1260BaaI3LQYDeGJOSqpHCVu+TuMcy
|
29
|
-
k00ofiLT1crDSUl2WE/OIFK8AXpmd798AMsef8okHeoo+Dj7zCXn0VSimN+MO1mE
|
30
|
-
L4d54WIy4HkZCqQXoTSiK5HZMIdXkPk3F1bZdJ8Dy1sMRru0rUkkM5mW7TQ75mfW
|
31
|
-
Zp0QrZyNZhtitrXFbZneGRrIA/8G2Krft5Ly/A==
|
32
|
-
-----END CERTIFICATE-----
|
33
|
-
date: 2017-11-24 00:00:00.000000000 Z
|
34
|
-
dependencies:
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: yajl-ruby
|
37
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '0.1'
|
42
|
-
type: :runtime
|
43
|
-
prerelease: false
|
44
|
-
version_requirements: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - ">="
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: '0.1'
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: redis
|
51
|
-
requirement: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - ">="
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: '4.0'
|
56
|
-
type: :runtime
|
57
|
-
prerelease: false
|
58
|
-
version_requirements: !ruby/object:Gem::Requirement
|
59
|
-
requirements:
|
60
|
-
- - ">="
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '4.0'
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
|
-
name: uri-redis
|
65
|
-
requirement: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 0.4.0
|
70
|
-
type: :runtime
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
74
|
-
- - ">="
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: 0.4.0
|
77
|
-
- !ruby/object:Gem::Dependency
|
78
|
-
name: drydock
|
79
|
-
requirement: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - ">="
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: 0.6.9
|
84
|
-
type: :runtime
|
85
|
-
prerelease: false
|
86
|
-
version_requirements: !ruby/object:Gem::Requirement
|
87
|
-
requirements:
|
88
|
-
- - ">="
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version: 0.6.9
|
91
|
-
description: Backup and restore your Redis data to and from JSON.
|
92
|
-
email: delano@solutious.com
|
7
|
+
- delano
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-06-18 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Backup and restore your Redis data to and from JSON by database, key,
|
14
|
+
or key pattern.
|
15
|
+
email: gems@solutious.com
|
93
16
|
executables:
|
94
17
|
- redis-dump
|
95
18
|
- redis-load
|
96
19
|
- redis-report
|
97
20
|
extensions: []
|
98
|
-
extra_rdoc_files:
|
99
|
-
- LICENSE.txt
|
100
|
-
- README.rdoc
|
21
|
+
extra_rdoc_files: []
|
101
22
|
files:
|
102
23
|
- CHANGES.txt
|
24
|
+
- Gemfile
|
25
|
+
- Gemfile.lock
|
103
26
|
- LICENSE.txt
|
104
|
-
- README.
|
27
|
+
- README.md
|
105
28
|
- Rakefile
|
106
|
-
-
|
107
|
-
-
|
108
|
-
-
|
109
|
-
- bin/redis-report
|
29
|
+
- exe/redis-dump
|
30
|
+
- exe/redis-load
|
31
|
+
- exe/redis-report
|
110
32
|
- gem-public_cert.pem
|
111
33
|
- lib/redis/dump.rb
|
34
|
+
- lib/redis/dump/version.rb
|
112
35
|
- redis-dump.gemspec
|
113
|
-
-
|
114
|
-
|
115
|
-
- try/30_dump_base64_try.rb
|
116
|
-
- try/db0.json
|
117
|
-
- try/redis.conf
|
118
|
-
homepage: http://github.com/delano/redis-dump
|
36
|
+
- sig/redis/dump.rbs
|
37
|
+
homepage: https://rubygems.org/gems/redis-dump
|
119
38
|
licenses:
|
120
39
|
- MIT
|
121
40
|
metadata: {}
|
122
|
-
post_install_message:
|
41
|
+
post_install_message:
|
123
42
|
rdoc_options: []
|
124
43
|
require_paths:
|
125
44
|
- lib
|
@@ -127,16 +46,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
46
|
requirements:
|
128
47
|
- - ">="
|
129
48
|
- !ruby/object:Gem::Version
|
130
|
-
version:
|
49
|
+
version: 2.7.8
|
131
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
51
|
requirements:
|
133
52
|
- - ">="
|
134
53
|
- !ruby/object:Gem::Version
|
135
54
|
version: '0'
|
136
55
|
requirements: []
|
137
|
-
|
138
|
-
|
139
|
-
signing_key:
|
56
|
+
rubygems_version: 3.5.7
|
57
|
+
signing_key:
|
140
58
|
specification_version: 4
|
141
59
|
summary: Backup and restore your Redis data to and from JSON.
|
142
60
|
test_files: []
|
checksums.yaml.gz.sig
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
�hY��Y��Ů]t�ۯ�x�r��%&&��y���U�4���ѵ���"��0 ���Y����#��y�~ab��{���I�v%~^�m/�E��Zyz�y&y���� �R�N�x��R"`�K@z�{%M3�c(sh�I��TD����'´Nv}k�s>�=C�A��9�kf�^pD�_�l���$�1�C�:�l��K|��ꛥ�1� ��u��܍�ˆ���8�:�����5�y`-c^�},~P�T��T�.�G�A��
|
data/README.rdoc
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
= Redis-Dump v0.4 BETA
|
2
|
-
|
3
|
-
<i>Backup and restore your Redis data to and from JSON.</i>
|
4
|
-
|
5
|
-
<b>NOTE: This is beta software. TEST IT BEFORE RELYING ON IT.</b>
|
6
|
-
|
7
|
-
|
8
|
-
== Usage
|
9
|
-
|
10
|
-
There are two executables: <tt>redis-dump</tt> and <tt>redis-load</tt>.
|
11
|
-
|
12
|
-
$ redis-dump
|
13
|
-
$ redis-dump -u 127.0.0.1:6371 > db_full.json
|
14
|
-
$ redis-dump -u 127.0.0.1:6371 -d 15 > db_db15.json
|
15
|
-
|
16
|
-
$ < db_full.json redis-load
|
17
|
-
$ < db_db15.json redis-load -d 15
|
18
|
-
# OR
|
19
|
-
$ cat db_full | redis-load
|
20
|
-
$ cat db_db15.json | redis-load -d 15
|
21
|
-
|
22
|
-
# You can specify the redis URI via an environment variable
|
23
|
-
$ export REDIS_URI=127.0.0.1:6371
|
24
|
-
$ redis-dump
|
25
|
-
|
26
|
-
# If your instance uses a password (such as on RedisToGo), you
|
27
|
-
# can specify the Redis URL as such:
|
28
|
-
# :<password>@<domain>:<port>
|
29
|
-
# Note the leading colon is important for specifying no username.
|
30
|
-
$ redis-dump -u :234288a830f009980e08@example.redistogo.com:9055
|
31
|
-
|
32
|
-
== Output format
|
33
|
-
|
34
|
-
All redis datatypes are output to a simple JSON object. All objects have the following 5 fields:
|
35
|
-
|
36
|
-
* db (Integer)
|
37
|
-
* key (String)
|
38
|
-
* ttl (Integer): The amount of time in seconds that the key will live. If no expire is set, it's -1.
|
39
|
-
* type (String), one of: string, list, set, zset, hash, none.
|
40
|
-
* value (String): A JSON-encoded string. For keys of type list, set, zset, and hash, the data is given a specific structure (see below).
|
41
|
-
|
42
|
-
Here are examples of each datatype:
|
43
|
-
|
44
|
-
{"db":0,"key":"hashkey","ttl":-1,"type":"hash","value":{"field_a":"value_a","field_b":"value_b","field_c":"value_c"},"size":42}
|
45
|
-
{"db":0,"key":"listkey","ttl":-1,"type":"list","value":["value_0","value_1","value_2","value_0","value_1","value_2"],"size":42}
|
46
|
-
{"db":0,"key":"setkey","ttl":-1,"type":"set","value":["value_2","value_0","value_1","value_3"],"size":28}
|
47
|
-
{"db":0,"key":"zsetkey","ttl":-1,"type":"zset","value":[["value_0","100"],["value_1","100"],["value_2","200"],["value_3","300"],["value_4","400"]],"size":50}
|
48
|
-
{"db":0,"key":"stringkey","ttl":79,"type":"string","value":"stringvalue","size":11}
|
49
|
-
|
50
|
-
=== Important note about TTLs
|
51
|
-
|
52
|
-
One of the purposes of redis-dump is the ability to restore the database to a known state. When you restore a redis database from a redis-dump file, <em>the expires are reset to their values at the time the dump was created</em>. This is different from restoring from Redis' native .rdb or .aof files (expires are stored relative to the actual time they were set).
|
53
|
-
|
54
|
-
|
55
|
-
== Output directly to an encrypted file
|
56
|
-
|
57
|
-
For most sensitive data, you should consider encrypting the data directly without writing first to a temp file. You can do this using the power of [gpg](http://www.gnupg.org/) and file descriptors. Here are a couple examples:
|
58
|
-
|
59
|
-
# Encrypt the data (interactive)
|
60
|
-
$ redis-dump -u 127.0.0.1:6371 -d 15 | gpg --force-mdc -v -c > path/2/backup-db15.json.gpg
|
61
|
-
|
62
|
-
# Encrypt the data (automated)
|
63
|
-
$ redis-dump -u 127.0.0.1:6371 -d 15 | 3</path/2/passphrase.txt gpg --force-mdc -v -c --passphrase-fd 3 > path/2/backup-db15.json.gpg
|
64
|
-
|
65
|
-
# Decrypt the file (interactive)
|
66
|
-
$ gpg path/2/backup-db15.json.gpg
|
67
|
-
Enter passphrase: *******
|
68
|
-
|
69
|
-
# Decrypt the file (automated)
|
70
|
-
$ 3</path/2/passphrase.txt gpg --passphrase-fd 3 path/2/backup-db15.json.gpg
|
71
|
-
|
72
|
-
|
73
|
-
== Loading data with binary strings
|
74
|
-
|
75
|
-
If you have binary or serialized data in your Redis database, the YAJL parser may not load your dump file because it sees some of the binary data as 'invalid bytes in UTF8 string'. If you are certain that your data is binary and not malformed UTF8, you can use the -n flag to redis-load to tell YAJL to not check the input for UTF8 validity. Use with caution!
|
76
|
-
|
77
|
-
== Installation
|
78
|
-
|
79
|
-
$ gem install redis-dump
|
80
|
-
|
81
|
-
Or of you want to run it directly:
|
82
|
-
|
83
|
-
$ git clone https://github.com/delano/redis-dump.git
|
84
|
-
$ cd redis-dump
|
85
|
-
$ gem install redis
|
86
|
-
$ gem install uri-redis
|
87
|
-
$ gem install yajl-ruby
|
88
|
-
$ gem install drydock
|
89
|
-
$ ruby -rubygems bin/redis-dump
|
90
|
-
|
91
|
-
|
92
|
-
== More Info
|
93
|
-
|
94
|
-
* Codes[http://github.com/delano/redis-dump]
|
95
|
-
* Docs[http://goldensword.ca/redis-dump/]
|
96
|
-
|
97
|
-
|
98
|
-
== Credits
|
99
|
-
|
100
|
-
* delano[http://github.com/delano]
|
101
|
-
|
102
|
-
|
103
|
-
== Thanks
|
104
|
-
|
105
|
-
* antirez and the funky redis bunch!
|
106
|
-
|
107
|
-
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.4.0
|
data/try/10_redis_dump_try.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'redis/dump'
|
2
|
-
|
3
|
-
# The test instance of redis must be running:
|
4
|
-
# $ redis-server try/redis.conf
|
5
|
-
|
6
|
-
@uri_base = "redis://127.0.0.1:6371"
|
7
|
-
|
8
|
-
Redis::Dump.debug = false
|
9
|
-
Redis::Dump.safe = true
|
10
|
-
|
11
|
-
|
12
|
-
## Connect to DB
|
13
|
-
@rdump = Redis::Dump.new 0, @uri_base
|
14
|
-
@rdump.redis_connections.size
|
15
|
-
#=> 1
|
16
|
-
|
17
|
-
## Populate
|
18
|
-
@rdump.redis(0).set 'stringkey', 'stringvalue'
|
19
|
-
@rdump.redis(0).expire 'stringkey', 100
|
20
|
-
@rdump.redis(0).hset 'hashkey', 'field_a', 'value_a'
|
21
|
-
@rdump.redis(0).hset 'hashkey', 'field_b', 'value_b'
|
22
|
-
@rdump.redis(0).hset 'hashkey', 'field_c', 'value_c'
|
23
|
-
3.times { |idx| @rdump.redis(0).rpush 'listkey', "value_#{idx}" }
|
24
|
-
4.times { |idx| @rdump.redis(0).sadd 'setkey', "value_#{idx}" }
|
25
|
-
5.times { |idx| @rdump.redis(0).zadd 'zsetkey', idx.zero? ? 100 : 100*idx, "value_#{idx}" }
|
26
|
-
@rdump.redis(0).keys.size
|
27
|
-
#=> 5
|
28
|
-
|
29
|
-
## Can dump
|
30
|
-
@values = @rdump.dump
|
31
|
-
@values.size
|
32
|
-
#=> 5
|
33
|
-
|
34
|
-
# Clear DB 0
|
35
|
-
db0 = Redis::Dump.new 0, @uri_base
|
36
|
-
db0.redis(0).flushdb
|
37
|
-
db0.redis(0).keys.size
|
38
|
-
#=> 0
|
39
|
-
|
40
|
-
## Can load data
|
41
|
-
@rdump.load @values.join
|
42
|
-
@rdump.redis(0).keys.size
|
43
|
-
#=> 5
|
44
|
-
|
45
|
-
## DB 0 content matches previous dump content
|
46
|
-
values = @rdump.dump
|
47
|
-
[values[0], values.size]
|
48
|
-
#=> [@values[0], @values.size]
|
49
|
-
|
50
|
-
## Won't load data in safe mode if records exist
|
51
|
-
@rdump.load @values.join
|
52
|
-
#=> 0
|
53
|
-
|
54
|
-
## Will load data if records exist and safe mode is disabled
|
55
|
-
Redis::Dump.safe = false
|
56
|
-
@rdump.load @values.join
|
57
|
-
#=> 5
|
58
|
-
|
59
|
-
Redis::Dump.safe = true
|
60
|
-
db0 = Redis::Dump.new 0, @uri_base
|
61
|
-
db0.redis(0).flushdb
|
62
|
-
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'redis/dump'
|
2
|
-
|
3
|
-
# The test instance of redis must be running:
|
4
|
-
# $ redis-server try/redis.conf
|
5
|
-
|
6
|
-
@uri_base = "redis://127.0.0.1:6371"
|
7
|
-
|
8
|
-
Redis::Dump.debug = false
|
9
|
-
Redis::Dump.safe = true
|
10
|
-
|
11
|
-
|
12
|
-
## Connect to DB
|
13
|
-
@rdump = Redis::Dump.new 0..1, @uri_base
|
14
|
-
@rdump.redis_connections.size
|
15
|
-
#=> 2
|
16
|
-
|
17
|
-
## Populate
|
18
|
-
3.times { |idx| @rdump.redis(0).set "gloria:#{idx}", "gloria_value[#{idx}]" } # yp.ca
|
19
|
-
4.times { |idx| @rdump.redis(0).set "pamela:#{idx}", "pamela_value[#{idx}]" } # soap web service
|
20
|
-
2.times { |idx| @rdump.redis(1).set "nikola:#{idx}", "nikola_value[#{idx}]" } # m.yp.ca log analyzer
|
21
|
-
[@rdump.redis(0).keys.size, @rdump.redis(1).keys.size]
|
22
|
-
#=> [7, 2]
|
23
|
-
|
24
|
-
## Generate a list of keys
|
25
|
-
@keys = @rdump.redis(0).keys('*gloria*').collect { |key| URI.parse "#{@uri_base}/0/#{key}" }
|
26
|
-
@keys.push *@rdump.redis(1).keys('*nikola*').collect { |key| URI.parse "#{@uri_base}/1/#{key}" }
|
27
|
-
@keys.size
|
28
|
-
#=> 5
|
29
|
-
|
30
|
-
## Dump these specific keys
|
31
|
-
@rdump.dump('*gloria*').sort
|
32
|
-
#=> ['{"db":0,"key":"gloria:0","ttl":-1,"type":"string","value":"gloria_value[0]","size":15}','{"db":0,"key":"gloria:1","ttl":-1,"type":"string","value":"gloria_value[1]","size":15}','{"db":0,"key":"gloria:2","ttl":-1,"type":"string","value":"gloria_value[2]","size":15}']
|
33
|
-
|
34
|
-
|
35
|
-
## Dump none existent keys (NOT SUPPORTED AS OF 0.3.0)
|
36
|
-
unknown_keys = [URI.parse("#{@uri_base}/0/unknownkey1"), URI.parse("#{@uri_base}/1/unknownkey2")]
|
37
|
-
@rdump.dump(unknown_keys).sort
|
38
|
-
##=> ['{"db":0,"key":"unknownkey1","ttl":-1,"type":"none","value":"","size":0}', '{"db":1,"key":"unknownkey2","ttl":-1,"type":"none","value":"","size":0}']
|
39
|
-
|
40
|
-
|
41
|
-
Redis::Dump.safe = true
|
42
|
-
db0 = Redis::Dump.new 0..1, @uri_base
|
43
|
-
db0.redis(0).flushdb
|
44
|
-
db0.redis(1).flushdb
|
data/try/30_dump_base64_try.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'redis/dump'
|
2
|
-
require 'pry'
|
3
|
-
|
4
|
-
# The test instance of redis must be running:
|
5
|
-
# $ redis-server try/redis.conf
|
6
|
-
|
7
|
-
@uri_base = "redis://127.0.0.1:6371"
|
8
|
-
|
9
|
-
Redis::Dump.debug = false
|
10
|
-
Redis::Dump.safe = true
|
11
|
-
Redis::Dump.with_base64 = true
|
12
|
-
|
13
|
-
## Connect to DB
|
14
|
-
@rdump = Redis::Dump.new 0..1, @uri_base
|
15
|
-
@rdump.redis_connections.size
|
16
|
-
#=> 2
|
17
|
-
|
18
|
-
## Populate
|
19
|
-
@rdump.redis(0).set 'stringkey1', 'stringvalue1'
|
20
|
-
@rdump.redis(0).set 'stringkey2', 'stringvalue2'
|
21
|
-
@rdump.redis(0).keys.size
|
22
|
-
#=> 2
|
23
|
-
|
24
|
-
## Is base64 encoded
|
25
|
-
@values = @rdump.dump
|
26
|
-
@values[0]
|
27
|
-
#=> "{\"db\":0,\"key\":\"stringkey1\",\"ttl\":-1,\"type\":\"string\",\"value\":\"c3RyaW5ndmFsdWUx\\n\",\"size\":12}"
|
28
|
-
|
29
|
-
## Can dump
|
30
|
-
@values = @rdump.dump
|
31
|
-
@values.size
|
32
|
-
#=> 2
|
33
|
-
|
34
|
-
# Clear DB 0
|
35
|
-
db0 = Redis::Dump.new 0, @uri_base
|
36
|
-
db0.redis(0).flushdb
|
37
|
-
db0.redis(0).keys.size
|
38
|
-
#=> 0
|
39
|
-
|
40
|
-
## Can load data
|
41
|
-
@rdump.load @values.join
|
42
|
-
@rdump.redis(0).keys.size
|
43
|
-
#=> 2
|
44
|
-
|
45
|
-
## Is base64 decoded
|
46
|
-
stringkey = @rdump.redis(0).get('stringkey1')
|
47
|
-
#=> 'stringvalue1'
|
48
|
-
|
49
|
-
# Clear DB 0
|
50
|
-
db0 = Redis::Dump.new 0, @uri_base
|
51
|
-
db0.redis(0).flushdb
|
52
|
-
db0.redis(0).keys.size
|
53
|
-
#=> 0
|
54
|
-
|
55
|
-
Redis::Dump.safe = true
|
56
|
-
db0 = Redis::Dump.new 0, @uri_base
|
57
|
-
db0.redis(0).flushdb
|
58
|
-
|
data/try/db0.json
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
{"db":0,"key":"hashkey","ttl":-1,"type":"hash","value":{"field_a":"value_a","field_b":"value_b","field_c":"value_c"},"size":42}
|
2
|
-
{"db":0,"key":"listkey","ttl":-1,"type":"list","value":["value_0","value_1","value_2","value_0","value_1","value_2"],"size":42}
|
3
|
-
{"db":0,"key":"setkey","ttl":-1,"type":"set","value":["value_2","value_0","value_1","value_3"],"size":28}
|
4
|
-
{"db":0,"key":"zsetkey","ttl":-1,"type":"zset","value":[["value_0","100"],["value_1","100"],["value_2","200"],["value_3","300"],["value_4","400"]],"size":50}
|
5
|
-
{"db":0,"key":"stringkey","ttl":79,"type":"string","value":"stringvalue","size":11}
|
data/try/redis.conf
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# redis-dump redis config
|
2
|
-
# 2017-11-09
|
3
|
-
|
4
|
-
dir /tmp
|
5
|
-
pidfile redisdump-test.pid
|
6
|
-
logfile redisdump-test.log
|
7
|
-
dbfilename redisdump-test.rdb
|
8
|
-
|
9
|
-
# requirepass @/
|
10
|
-
|
11
|
-
bind 127.0.0.1
|
12
|
-
port 6371
|
13
|
-
databases 16
|
14
|
-
|
15
|
-
timeout 30
|
16
|
-
daemonize yes
|
17
|
-
loglevel notice
|
18
|
-
|
19
|
-
# FOR LIGHT TRAFFIC:
|
20
|
-
#save 300 10
|
21
|
-
#save 120 100
|
22
|
-
#save 60 1000
|
23
|
-
|
24
|
-
# NOTE: we need something here to force redis to save
|
25
|
-
# when it receives a SHUTDOWN command. 157680000 is 5 yrs.
|
26
|
-
# REMOVE IT ONLY IF YOU PLAN TO ALWAYS MOVE
|
27
|
-
# AN RDB FILE INTO PLACE EVERY RESTART!
|
28
|
-
save 157680000 1
|
29
|
-
|
30
|
-
rdbcompression yes
|
31
|
-
|
32
|
-
appendonly no
|
33
|
-
|
34
|
-
# appendfsync is one of always, everysec, no
|
35
|
-
appendfsync everysec
|
data.tar.gz.sig
DELETED
metadata.gz.sig
DELETED
Binary file
|
/data/{bin → exe}/redis-load
RENAMED
File without changes
|
/data/{bin → exe}/redis-report
RENAMED
File without changes
|