snapshot_archive 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/snapshot_archive/archives.rb +6 -5
- data/lib/snapshot_archive/cfg.rb +6 -6
- data/lib/snapshot_archive/repositories.rb +1 -1
- data/lib/snapshot_archive/stores.rb +21 -16
- data/lib/snapshot_archive/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c8a429af95388506fe67325d85ec86e603b37f67fbc1cac4550da0e42a8e74d
|
4
|
+
data.tar.gz: 3bffd5d06b37296c811c6207fd88d751c55599083f238b56d9cc0b39b378549d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26befeebb1559a46e2cb5d6537b89ad2d23835ddd6add79c9a48b9049a0633630504ed1c15d3ca5e0da79b75ebed0aa481789bdf560f15dc970085bc5aedd40b
|
7
|
+
data.tar.gz: f037383fe511d4c17b82104792a4f3f9d2d8873b81edef58526cae776ddb8df6e0fda2ef77c204d5873f0c67f6b2a21d6196e423864e19178cc5e4ed79a9f623
|
data/README.md
CHANGED
@@ -130,14 +130,14 @@ SnapshotArchive.configure do |config|
|
|
130
130
|
# Using an object:
|
131
131
|
|
132
132
|
class MyCustomStore
|
133
|
-
def backup(dir
|
133
|
+
def backup(dir:, id:, args: [])
|
134
134
|
path = File.join(dir, "my_custom_store.txt")
|
135
135
|
File.write(path, "received args: #{args}")
|
136
136
|
|
137
137
|
{ "path" => path }
|
138
138
|
end
|
139
139
|
|
140
|
-
def restore(metadata)
|
140
|
+
def restore(metadata:)
|
141
141
|
puts(File.read(metadata.fetch("path")))
|
142
142
|
end
|
143
143
|
end
|
@@ -148,14 +148,14 @@ SnapshotArchive.configure do |config|
|
|
148
148
|
# Using the store builder:
|
149
149
|
|
150
150
|
config.register_store("my_custom_store") do |store|
|
151
|
-
store.backup do |dir
|
151
|
+
store.backup do |dir:, id:, args: []|
|
152
152
|
path = File.join(dir, "my_custom_store.txt")
|
153
153
|
File.write(path, "received args: #{args}")
|
154
154
|
|
155
155
|
{ "path" => path }
|
156
156
|
end
|
157
157
|
|
158
|
-
store.restore do |metadata
|
158
|
+
store.restore do |metadata:|
|
159
159
|
puts(File.read(metadata.fetch("path")))
|
160
160
|
end
|
161
161
|
end
|
@@ -1,14 +1,15 @@
|
|
1
1
|
module SnapshotArchive
|
2
2
|
module Archives
|
3
3
|
class Builder
|
4
|
-
def self.call(dir:, stores:)
|
5
|
-
new(dir, stores).call
|
4
|
+
def self.call(dir:, stores:, id:)
|
5
|
+
new(dir, stores, id).call
|
6
6
|
end
|
7
7
|
|
8
|
-
attr_reader :dir, :stores
|
9
|
-
def initialize(dir, stores)
|
8
|
+
attr_reader :dir, :stores, :id
|
9
|
+
def initialize(dir, stores, id)
|
10
10
|
@dir = dir
|
11
11
|
@stores = stores
|
12
|
+
@id = id
|
12
13
|
end
|
13
14
|
|
14
15
|
def call
|
@@ -18,7 +19,7 @@ module SnapshotArchive
|
|
18
19
|
File
|
19
20
|
.join(dir, name)
|
20
21
|
.tap { FileUtils.mkdir(_1) }
|
21
|
-
.then { store.backup(_1)&.merge(type: name) }
|
22
|
+
.then { store.backup(_1, id)&.merge(type: name) }
|
22
23
|
}
|
23
24
|
.compact
|
24
25
|
)
|
data/lib/snapshot_archive/cfg.rb
CHANGED
@@ -10,16 +10,16 @@ module SnapshotArchive
|
|
10
10
|
@delete = delete
|
11
11
|
end
|
12
12
|
|
13
|
-
def backup(
|
14
|
-
@backup&.call(
|
13
|
+
def backup(...)
|
14
|
+
@backup&.call(...)
|
15
15
|
end
|
16
16
|
|
17
|
-
def restore(
|
18
|
-
@restore&.call(
|
17
|
+
def restore(...)
|
18
|
+
@restore&.call(...)
|
19
19
|
end
|
20
20
|
|
21
|
-
def delete(
|
22
|
-
@delete&.call(
|
21
|
+
def delete(...)
|
22
|
+
@delete&.call(...)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -12,7 +12,7 @@ module SnapshotArchive
|
|
12
12
|
timestamp = Time.now
|
13
13
|
dir = mkdir(id)
|
14
14
|
|
15
|
-
archive_metadata = Archives::Builder.call(dir: dir, stores: stores)
|
15
|
+
archive_metadata = Archives::Builder.call(id: id, dir: dir, stores: stores)
|
16
16
|
|
17
17
|
Cfg.shell.debug("Using stores: #{stores.keys.join(", ")}")
|
18
18
|
|
@@ -9,35 +9,40 @@ module SnapshotArchive
|
|
9
9
|
@args = args
|
10
10
|
end
|
11
11
|
|
12
|
-
def backup(dir)
|
13
|
-
store.backup(dir, args)
|
12
|
+
def backup(dir:, id:)
|
13
|
+
store.backup(dir: dir, id: id, args: args)
|
14
14
|
end
|
15
15
|
|
16
|
-
def restore(
|
17
|
-
store.restore(
|
16
|
+
def restore(...)
|
17
|
+
store.restore(...)
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete(...)
|
21
|
+
store.delete(...)
|
18
22
|
end
|
19
23
|
end
|
20
24
|
|
21
25
|
module Mysql
|
22
26
|
class << self
|
23
|
-
def backup(
|
24
|
-
Backup.call(
|
27
|
+
def backup(...)
|
28
|
+
Backup.call(...)
|
25
29
|
end
|
26
30
|
|
27
|
-
def restore(
|
28
|
-
Restore.call(
|
31
|
+
def restore(...)
|
32
|
+
Restore.call(...)
|
29
33
|
end
|
30
34
|
end
|
31
35
|
|
32
36
|
class Backup
|
33
|
-
def self.call(
|
34
|
-
new(
|
37
|
+
def self.call(...)
|
38
|
+
new(...).call
|
35
39
|
end
|
36
40
|
|
37
|
-
attr_reader :dir, :names
|
38
|
-
def initialize(dir
|
41
|
+
attr_reader :dir, :names, :id
|
42
|
+
def initialize(dir:, id:, args:)
|
39
43
|
@dir = dir
|
40
|
-
@
|
44
|
+
@id = id
|
45
|
+
@names = args
|
41
46
|
end
|
42
47
|
|
43
48
|
def call
|
@@ -61,12 +66,12 @@ module SnapshotArchive
|
|
61
66
|
end
|
62
67
|
|
63
68
|
class Restore
|
64
|
-
def self.call(
|
65
|
-
new(
|
69
|
+
def self.call(...)
|
70
|
+
new(...).call
|
66
71
|
end
|
67
72
|
|
68
73
|
attr_reader :metadata
|
69
|
-
def initialize(metadata)
|
74
|
+
def initialize(metadata:)
|
70
75
|
@metadata = metadata
|
71
76
|
end
|
72
77
|
|