snapshot_archive 0.12.0 → 0.14.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: 980e40563a31fda449526df407ff72c4a6e5ffdbd6f0e0cff9b69eab414fa195
|
4
|
+
data.tar.gz: e7582633c0c5e9d9d5811da112dc49ee66d5556eb1773c633434a8872e96deb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 265c065142b8d3db6048623456394dda63fd03172e5a53dd22551c389296228a56c762d66612a67b4edfcdb9606a263f41a32fe1722c515f9fc37fe5ba169da9
|
7
|
+
data.tar.gz: 9192e94cb6a62bda59a0b21c393cd080e8ce829bb2244a71fbdd21daea4299d5c6392974bd9078f3d4a7ab2b811cccb7fdbf9e8a54be485087ec13f906773ea0
|
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(dir: _1, id: 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
|
|