synco 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +3 -0
- data/bin/synco +2 -1
- data/lib/synco/command/disk.rb +6 -21
- data/lib/synco/command/prune.rb +9 -24
- data/lib/synco/command/rotate.rb +46 -61
- data/lib/synco/command/spawn.rb +10 -25
- data/lib/synco/command.rb +19 -32
- data/lib/synco/controller.rb +4 -19
- data/lib/synco/directory.rb +8 -23
- data/lib/synco/disk.rb +4 -19
- data/lib/synco/method.rb +11 -26
- data/lib/synco/methods/rsync.rb +14 -29
- data/lib/synco/methods/scp.rb +8 -23
- data/lib/synco/methods/zfs.rb +7 -22
- data/lib/synco/scope.rb +32 -58
- data/lib/synco/script.rb +15 -30
- data/lib/synco/server.rb +9 -24
- data/lib/synco/shell.rb +5 -20
- data/lib/synco/shells/ssh.rb +10 -25
- data/lib/synco/version.rb +5 -20
- data/lib/synco.rb +13 -29
- data/license.md +21 -0
- data/{README.md → readme.md} +32 -48
- data.tar.gz.sig +0 -0
- metadata +63 -118
- metadata.gz.sig +0 -0
- data/.github/workflows/development.yml +0 -40
- data/.gitignore +0 -22
- data/.rspec +0 -4
- data/Gemfile +0 -8
- data/Rakefile +0 -6
- data/spec/spec_helper.rb +0 -34
- data/spec/synco/backup_script.rb +0 -63
- data/spec/synco/directory_spec.rb +0 -33
- data/spec/synco/local_backup.rb +0 -56
- data/spec/synco/local_sync.rb +0 -91
- data/spec/synco/method_spec.rb +0 -62
- data/spec/synco/rsync_spec.rb +0 -89
- data/spec/synco/scp_spec.rb +0 -58
- data/spec/synco/script_spec.rb +0 -51
- data/spec/synco/shell_spec.rb +0 -40
- data/spec/synco/usb_spec.rb +0 -76
- data/spec/synco/zfs_spec.rb +0 -50
- data/synco.gemspec +0 -31
data/lib/synco/methods/scp.rb
CHANGED
@@ -1,30 +1,15 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# 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
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
20
2
|
|
21
|
-
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2016-2024, by Samuel Williams.
|
5
|
+
|
6
|
+
require_relative "../method"
|
22
7
|
|
23
8
|
module Synco
|
24
9
|
module Methods
|
25
10
|
class SCP < Method
|
26
11
|
def default_command
|
27
|
-
[
|
12
|
+
["scp", "-pr"]
|
28
13
|
end
|
29
14
|
|
30
15
|
def call(scope)
|
@@ -35,10 +20,10 @@ module Synco
|
|
35
20
|
*@command,
|
36
21
|
*arguments,
|
37
22
|
# If the destination directory already exists, scp will create the source directory inside the destinatio directory. This behaviour means that running scp multiple times gives different results, i.e. the first time it will copy source/* to destination/*, but the second time you will end up with destination/source/*. Putting a dot after the first path alleviates this issue for some reason.
|
38
|
-
scope.master_server.connection_string(directory, on: server) +
|
23
|
+
scope.master_server.connection_string(directory, on: server) + ".",
|
39
24
|
scope.target_server.connection_string(directory, on: server)
|
40
25
|
)
|
41
26
|
end
|
42
27
|
end
|
43
28
|
end
|
44
|
-
end
|
29
|
+
end
|
data/lib/synco/methods/zfs.rb
CHANGED
@@ -1,30 +1,15 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# 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
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
20
2
|
|
21
|
-
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2016-2024, by Samuel Williams.
|
5
|
+
|
6
|
+
require_relative "../method"
|
22
7
|
|
23
8
|
module Synco
|
24
9
|
module Methods
|
25
10
|
class ZFS < Method
|
26
11
|
def default_command
|
27
|
-
[
|
12
|
+
["zfs", "-rnv"]
|
28
13
|
end
|
29
14
|
|
30
15
|
def call(scope, arguments: [])
|
@@ -57,4 +42,4 @@ module Synco
|
|
57
42
|
end
|
58
43
|
end
|
59
44
|
end
|
60
|
-
end
|
45
|
+
end
|
data/lib/synco/scope.rb
CHANGED
@@ -1,29 +1,14 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# 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
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
20
2
|
|
21
|
-
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2016-2024, by Samuel Williams.
|
22
5
|
|
23
|
-
|
6
|
+
require_relative "script"
|
24
7
|
|
25
|
-
require
|
26
|
-
|
8
|
+
require "process/group"
|
9
|
+
|
10
|
+
require "console"
|
11
|
+
require "delegate"
|
27
12
|
|
28
13
|
module Synco
|
29
14
|
class CommandFailure < RuntimeError
|
@@ -39,8 +24,6 @@ module Synco
|
|
39
24
|
end
|
40
25
|
|
41
26
|
class Runner
|
42
|
-
include Console
|
43
|
-
|
44
27
|
def initialize(*scripts)
|
45
28
|
@scripts = scripts
|
46
29
|
end
|
@@ -48,28 +31,26 @@ module Synco
|
|
48
31
|
attr :scripts
|
49
32
|
|
50
33
|
def call
|
51
|
-
|
52
|
-
|
53
|
-
logger.info "===== Starting at #{start_time} ====="
|
34
|
+
Console.info(self, "Running scripts...")
|
54
35
|
|
55
36
|
Process::Group.wait do |group|
|
56
37
|
@scripts.each do |script|
|
57
38
|
Fiber.new do
|
58
|
-
ScriptScope.new(script,
|
39
|
+
ScriptScope.new(script, group).call
|
59
40
|
end.resume
|
60
41
|
end
|
61
42
|
end
|
43
|
+
rescue => error
|
44
|
+
Console::Event::Failure.for(error).emit(self)
|
45
|
+
raise
|
62
46
|
ensure
|
63
|
-
|
64
|
-
logger.info "[Time]: (#{end_time - start_time}s)."
|
65
|
-
logger.info "===== Finished backup at #{end_time} ====="
|
47
|
+
Console.info(self, "Finished running scripts.")
|
66
48
|
end
|
67
49
|
end
|
68
50
|
|
69
51
|
class ScriptScope
|
70
|
-
def initialize(script,
|
52
|
+
def initialize(script, group)
|
71
53
|
@script = script
|
72
|
-
@logger = logger
|
73
54
|
@group = group
|
74
55
|
|
75
56
|
@current_server = ServerScope.new(@script.current_server, self)
|
@@ -77,7 +58,6 @@ module Synco
|
|
77
58
|
end
|
78
59
|
|
79
60
|
attr :script
|
80
|
-
attr :logger
|
81
61
|
attr :group
|
82
62
|
attr :master_server
|
83
63
|
attr :current_server
|
@@ -88,18 +68,17 @@ module Synco
|
|
88
68
|
|
89
69
|
def call
|
90
70
|
if @script.running_on_master?
|
91
|
-
|
71
|
+
Console.info(self, "We are the master server...")
|
92
72
|
else
|
93
|
-
|
94
|
-
logger.info "Master server is #{@master}..."
|
73
|
+
Console.info(self, "We are not the master server...", master: @master)
|
95
74
|
end
|
96
|
-
|
75
|
+
|
97
76
|
@script.try(self) do
|
98
77
|
# This allows events to run on the master server if specified, before running any backups.
|
99
78
|
|
100
79
|
@master_server.try(master_target_server) do
|
101
80
|
method.try(self) do
|
102
|
-
|
81
|
+
Console.info(self, "Running backups...", server: @current_server)
|
103
82
|
|
104
83
|
run_servers(group)
|
105
84
|
end
|
@@ -126,16 +105,15 @@ module Synco
|
|
126
105
|
def run_servers(group)
|
127
106
|
target_servers do |server|
|
128
107
|
sync_scope = TargetScope.new(self, server)
|
129
|
-
|
130
|
-
|
131
|
-
logger.info "[Master]: #{master_server}"
|
132
|
-
logger.info "[Target]: #{server}"
|
108
|
+
|
109
|
+
Console.info(self, "Running script...", master: @master_server, target: server)
|
133
110
|
|
134
111
|
server.try(sync_scope) do
|
135
112
|
@script.directories.each do |directory|
|
136
113
|
directory_scope = DirectoryScope.new(sync_scope, directory)
|
137
|
-
|
138
|
-
|
114
|
+
|
115
|
+
Console.info(self, "Processing directory...", directory: directory)
|
116
|
+
|
139
117
|
directory.try(directory_scope) do
|
140
118
|
method.call(directory_scope)
|
141
119
|
end
|
@@ -146,9 +124,8 @@ module Synco
|
|
146
124
|
end
|
147
125
|
|
148
126
|
class LogPipe < DelegateClass(IO)
|
149
|
-
def initialize(logger, level
|
127
|
+
def initialize(logger: Console, level: :info)
|
150
128
|
@input, @output = IO.pipe
|
151
|
-
@logger = logger
|
152
129
|
|
153
130
|
super(@output)
|
154
131
|
|
@@ -177,10 +154,6 @@ module Synco
|
|
177
154
|
@from = from
|
178
155
|
end
|
179
156
|
|
180
|
-
def logger
|
181
|
-
@logger ||= @script_scope.logger
|
182
|
-
end
|
183
|
-
|
184
157
|
def group
|
185
158
|
@group ||= @script_scope.group
|
186
159
|
end
|
@@ -195,13 +168,14 @@ module Synco
|
|
195
168
|
command = self.connection_command + ["--"] + command
|
196
169
|
end
|
197
170
|
|
198
|
-
|
171
|
+
Console::Event::Spawn.for(*command, **options).emit(self)
|
199
172
|
|
200
|
-
options[:out] ||= LogPipe.new
|
201
|
-
options[:err] ||= LogPipe.new(
|
173
|
+
options[:out] ||= LogPipe.new
|
174
|
+
options[:err] ||= LogPipe.new(level: :error)
|
202
175
|
|
203
176
|
status = self.group.spawn(*command, **options)
|
204
|
-
|
177
|
+
|
178
|
+
Console.info(self, "Command completed.", status: status)
|
205
179
|
|
206
180
|
options[:out].close
|
207
181
|
options[:err].close
|
@@ -219,8 +193,8 @@ module Synco
|
|
219
193
|
@target_server = ServerScope.new(target, script_scope, script_scope.current_server)
|
220
194
|
end
|
221
195
|
|
222
|
-
def run(
|
223
|
-
@target_server.run(
|
196
|
+
def run(...)
|
197
|
+
@target_server.run(...)
|
224
198
|
end
|
225
199
|
|
226
200
|
attr :target_server
|
data/lib/synco/script.rb
CHANGED
@@ -1,36 +1,21 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# 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
|
-
# THE SOFTWARE.
|
20
|
-
|
21
|
-
require_relative 'method'
|
22
|
-
require_relative 'server'
|
23
|
-
require_relative 'directory'
|
24
|
-
require_relative 'controller'
|
25
|
-
|
26
|
-
require 'socket'
|
27
|
-
|
28
|
-
require 'process/group'
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2008-2024, by Samuel Williams.
|
5
|
+
|
6
|
+
require_relative "method"
|
7
|
+
require_relative "server"
|
8
|
+
require_relative "directory"
|
9
|
+
require_relative "controller"
|
10
|
+
|
11
|
+
require "socket"
|
12
|
+
|
13
|
+
require "process/group"
|
29
14
|
|
30
15
|
module Synco
|
31
16
|
# The main backup/synchronisation mechanism is the backup script. It specifies all servers and directories, and these are then combined specifically to produce the desired data replication behaviour.
|
32
17
|
class Script < Controller
|
33
|
-
def initialize(method: nil, servers: {}, directories: [], master: :master
|
18
|
+
def initialize(method: nil, servers: {}, directories: [], master: :master)
|
34
19
|
super()
|
35
20
|
|
36
21
|
@method = method
|
@@ -87,7 +72,7 @@ module Synco
|
|
87
72
|
else
|
88
73
|
# Find a server config that specifies the local host
|
89
74
|
@servers.values.find{|server| localhost?(server.host)}
|
90
|
-
end || Server.new(
|
75
|
+
end || Server.new("localhost")
|
91
76
|
end
|
92
77
|
|
93
78
|
def current_server
|
data/lib/synco/server.rb
CHANGED
@@ -1,32 +1,17 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# 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
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
20
2
|
|
21
|
-
|
22
|
-
|
23
|
-
require_relative 'shells/ssh'
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2009-2024, by Samuel Williams.
|
24
5
|
|
25
|
-
|
6
|
+
require_relative "controller"
|
7
|
+
require_relative "directory"
|
8
|
+
require_relative "shells/ssh"
|
9
|
+
|
10
|
+
require "shellwords"
|
26
11
|
|
27
12
|
module Synco
|
28
13
|
class Server < Controller
|
29
|
-
def initialize(name, root:
|
14
|
+
def initialize(name, root: "/", shell: nil, **options)
|
30
15
|
super()
|
31
16
|
|
32
17
|
@name = name
|
data/lib/synco/shell.rb
CHANGED
@@ -1,24 +1,9 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# 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
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
20
2
|
|
21
|
-
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2009-2024, by Samuel Williams.
|
5
|
+
|
6
|
+
require "pathname"
|
22
7
|
|
23
8
|
module Synco
|
24
9
|
# A shell provides access to a server, typically to run commands.
|
data/lib/synco/shells/ssh.rb
CHANGED
@@ -1,48 +1,33 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# 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
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
20
2
|
|
21
|
-
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2011-2024, by Samuel Williams.
|
5
|
+
|
6
|
+
require_relative "../shell"
|
22
7
|
|
23
8
|
module Synco
|
24
9
|
module Shells
|
25
10
|
# SSH shell provides access to a remote server using SSH.
|
26
11
|
class SSH < Shell
|
27
12
|
def default_command
|
28
|
-
[
|
13
|
+
["ssh"]
|
29
14
|
end
|
30
15
|
|
31
16
|
def initialize(*command, arguments: [], port: nil, key: nil, user: nil, batch_mode: nil, **options)
|
32
17
|
if port
|
33
|
-
arguments <<
|
18
|
+
arguments << "-p" << port
|
34
19
|
end
|
35
20
|
|
36
21
|
if key
|
37
|
-
arguments <<
|
22
|
+
arguments << "-i" << key
|
38
23
|
end
|
39
24
|
|
40
25
|
if user
|
41
|
-
arguments <<
|
26
|
+
arguments << "-l" << user
|
42
27
|
end
|
43
28
|
|
44
29
|
unless batch_mode.nil?
|
45
|
-
arguments <<
|
30
|
+
arguments << "-o" << "BatchMode=#{batch_mode ? 'yes' : 'no'}"
|
46
31
|
end
|
47
32
|
|
48
33
|
super
|
data/lib/synco/version.rb
CHANGED
@@ -1,23 +1,8 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# 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
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2008-2024, by Samuel Williams.
|
20
5
|
|
21
6
|
module Synco
|
22
|
-
VERSION = "1.
|
7
|
+
VERSION = "1.3.0"
|
23
8
|
end
|
data/lib/synco.rb
CHANGED
@@ -1,36 +1,20 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# 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
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
20
2
|
|
21
|
-
|
22
|
-
|
23
|
-
require 'set'
|
24
|
-
require 'logger'
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2008-2024, by Samuel Williams.
|
25
5
|
|
26
|
-
|
27
|
-
|
28
|
-
|
6
|
+
require "yaml"
|
7
|
+
require "socket"
|
8
|
+
require "set"
|
29
9
|
|
30
|
-
|
31
|
-
|
10
|
+
require_relative "synco/version"
|
11
|
+
require_relative "synco/script"
|
12
|
+
require_relative "synco/scope"
|
32
13
|
|
33
|
-
require
|
14
|
+
require "fileutils"
|
15
|
+
require "optparse"
|
16
|
+
|
17
|
+
require "lockfile"
|
34
18
|
|
35
19
|
module Synco
|
36
20
|
# Run a prepared backup script using a lockfile.
|
data/license.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# MIT License
|
2
|
+
|
3
|
+
Copyright, 2008-2024, by Samuel Williams.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|