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/spec/synco/local_backup.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'synco'
|
4
|
-
require 'synco/shells/ssh'
|
5
|
-
require 'synco/methods/rsync'
|
6
|
-
|
7
|
-
# Check we've got two paths for sync.
|
8
|
-
unless ARGV.size == 2
|
9
|
-
$stderr.puts "Usage: #{$0} [master] [copy]"
|
10
|
-
exit(255)
|
11
|
-
end
|
12
|
-
|
13
|
-
# $growl = Growl.new "localhost", "Synco", ["Backup Status"]
|
14
|
-
# $growl.register
|
15
|
-
|
16
|
-
$stdout.sync = true
|
17
|
-
$stderr.sync = true
|
18
|
-
|
19
|
-
Synco::run_script do |script|
|
20
|
-
self.method = Synco::Methods::RSyncSnapshot.new(:push, "--archive", "--compress", "--stats")
|
21
|
-
|
22
|
-
self.master = :src
|
23
|
-
|
24
|
-
server(:src) do |server|
|
25
|
-
server.root = ARGV[0]
|
26
|
-
end
|
27
|
-
|
28
|
-
server(:dst) do |server|
|
29
|
-
server.root = ARGV[1]
|
30
|
-
|
31
|
-
# Runs after all directories have been successfully backed up.
|
32
|
-
server.on(:success) do
|
33
|
-
target.run "synco", "rotate"
|
34
|
-
target.run "synco", "prune"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# This event is fired before the backup starts
|
39
|
-
#script.on(:prepare) do
|
40
|
-
# $growl.notify "Backup Status", "Starting Backup", "Starting at #{Time.now.to_s}"
|
41
|
-
#end
|
42
|
-
#
|
43
|
-
## This event occurs if the backup is successful
|
44
|
-
#script.on(:success) do
|
45
|
-
# $growl.notify "Backup Status", "Backup Successful", script.log.string
|
46
|
-
#end
|
47
|
-
#
|
48
|
-
## This event occurs if any part of the backup fails and is not handled elsewhere.
|
49
|
-
#script.on(:failure) do |failure|
|
50
|
-
# $growl.notify "Backup Status", "Backup Failure", failure.to_s
|
51
|
-
#
|
52
|
-
# raise failure
|
53
|
-
#end
|
54
|
-
|
55
|
-
backup('./')
|
56
|
-
end
|
data/spec/synco/local_sync.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# You need to have the FSSM gem installed for this to work.
|
4
|
-
require 'fssm'
|
5
|
-
|
6
|
-
require 'synco'
|
7
|
-
require 'synco/shells/ssh'
|
8
|
-
require 'synco/methods/rsync'
|
9
|
-
require 'synco/event_timer'
|
10
|
-
|
11
|
-
MONITOR = ARGV.delete "-m"
|
12
|
-
|
13
|
-
# Check we've got two paths for sync.
|
14
|
-
unless ARGV.size == 2
|
15
|
-
$stderr.puts "Usage: #{$0} [master] [copy]"
|
16
|
-
exit(255)
|
17
|
-
end
|
18
|
-
|
19
|
-
script = Synco::Script.new do |script|
|
20
|
-
script.method = Synco::Methods::RSync.new(:push, :arguments => ["--archive", "--delete"])
|
21
|
-
|
22
|
-
script.master = :src
|
23
|
-
|
24
|
-
server(:src) do |server|
|
25
|
-
server.root = ARGV[0]
|
26
|
-
end
|
27
|
-
|
28
|
-
server(:dst) do |server|
|
29
|
-
server.root = ARGV[1]
|
30
|
-
|
31
|
-
#server.on(:prepare) do
|
32
|
-
# logger.warn "Aborting backup!"
|
33
|
-
# server.abort!
|
34
|
-
#end
|
35
|
-
end
|
36
|
-
|
37
|
-
#server(:remote) do |server|
|
38
|
-
# server.host = "ayako.oriontransfer.org"
|
39
|
-
# server.shell = Synco::Shells::SSH.new(:user => "nobody")
|
40
|
-
# server.root = "/tmp/sync-test"
|
41
|
-
#end
|
42
|
-
|
43
|
-
#server(:remote2) do |server|
|
44
|
-
# server.host = "remote2.example.com"
|
45
|
-
# server.root = "/tmp/sync-test"
|
46
|
-
#
|
47
|
-
# server.on(:prepare) do |controller|
|
48
|
-
# controller.run! "mysqldump", "..."
|
49
|
-
# end
|
50
|
-
#
|
51
|
-
# server.on(:success) do |controller|
|
52
|
-
# controller.run! "uname", "-a"
|
53
|
-
# end
|
54
|
-
#end
|
55
|
-
|
56
|
-
backup('./')
|
57
|
-
end
|
58
|
-
|
59
|
-
# Initial sync:
|
60
|
-
|
61
|
-
context = Synco::Context.new(script)
|
62
|
-
context.run!
|
63
|
-
|
64
|
-
if MONITOR
|
65
|
-
# Monitor directories for changes:
|
66
|
-
monitor = FSSM::Monitor.new(:directories => true)
|
67
|
-
|
68
|
-
# The event timer aggregates events into a single callback which will be called at most
|
69
|
-
# once every k seconds (where k = 10 in this case).
|
70
|
-
$event_timer = Synco::EventTimer.new(10) do
|
71
|
-
$script.run!
|
72
|
-
end
|
73
|
-
|
74
|
-
$script.directories.each do |directory|
|
75
|
-
full_path = $script[:src].full_path(directory)
|
76
|
-
puts "Monitoring path: #{full_path}"
|
77
|
-
|
78
|
-
monitor.path(full_path, "**/*") do
|
79
|
-
update { $event_timer.trigger! }
|
80
|
-
delete { $event_timer.trigger! }
|
81
|
-
create { $event_timer.trigger! }
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
begin
|
86
|
-
monitor.run
|
87
|
-
ensure
|
88
|
-
# We should wait for the backup to complete nicely.
|
89
|
-
$event_timer.join
|
90
|
-
end
|
91
|
-
end
|
data/spec/synco/method_spec.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rspec
|
2
|
-
|
3
|
-
# Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
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
|
13
|
-
# all 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
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'synco/scope'
|
24
|
-
require 'synco/methods/scp'
|
25
|
-
|
26
|
-
require_relative 'backup_script'
|
27
|
-
|
28
|
-
RSpec.describe Synco::Methods::SCP do
|
29
|
-
include_context "backup script"
|
30
|
-
|
31
|
-
let(:test_server) {ENV.fetch('TEST_SERVER', 'localhost')}
|
32
|
-
|
33
|
-
let(:script) {Synco::Script.new}
|
34
|
-
let(:logger) {Logger.new($stderr)}
|
35
|
-
let(:master_server) {Synco::Server.new('localhost', root: master_path)}
|
36
|
-
let(:target_server) {Synco::Server.new(test_server, root: target_path)}
|
37
|
-
|
38
|
-
let(:group) {Process::Group.new}
|
39
|
-
let(:script_scope) {Synco::ScriptScope.new(script, logger, group)}
|
40
|
-
let(:sync_scope) {Synco::TargetScope.new(script_scope, target_server)}
|
41
|
-
|
42
|
-
let(:directory) {Synco::Directory.new(".", arguments: ['--archive'])}
|
43
|
-
let(:directory_scope) {Synco::DirectoryScope.new(sync_scope, directory)}
|
44
|
-
|
45
|
-
# This example shows all the state which goes into one single method invocation:
|
46
|
-
it 'should copy files from master to target' do
|
47
|
-
script.instance_variable_set(:@master_server, master_server)
|
48
|
-
script.instance_variable_set(:@current_server, master_server)
|
49
|
-
|
50
|
-
expect(directory_scope.master_server).to_not be == nil
|
51
|
-
expect(directory_scope.target_server).to_not be == nil
|
52
|
-
expect(directory_scope.current_server).to_not be == nil
|
53
|
-
|
54
|
-
group.wait do
|
55
|
-
Fiber.new do
|
56
|
-
subject.call(directory_scope)
|
57
|
-
end.resume
|
58
|
-
end
|
59
|
-
|
60
|
-
expect(Fingerprint).to be_identical(master_path, target_path)
|
61
|
-
end
|
62
|
-
end
|
data/spec/synco/rsync_spec.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rspec
|
2
|
-
|
3
|
-
# Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
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
|
13
|
-
# all 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
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'logger'
|
24
|
-
require 'synco/script'
|
25
|
-
require 'synco/scope'
|
26
|
-
require 'synco/methods/rsync'
|
27
|
-
|
28
|
-
require_relative 'backup_script'
|
29
|
-
|
30
|
-
RSpec.describe Synco::Methods::RSync do
|
31
|
-
include_context "backup script"
|
32
|
-
|
33
|
-
it 'should copy files using rsync' do
|
34
|
-
script = Synco::Script.build do |script|
|
35
|
-
script.method = Synco::Methods::RSync.new(archive: true)
|
36
|
-
|
37
|
-
script.server(:master) do |server|
|
38
|
-
server.root = master_path
|
39
|
-
end
|
40
|
-
|
41
|
-
script.server(:backup) do |server|
|
42
|
-
server.root = target_path
|
43
|
-
end
|
44
|
-
|
45
|
-
script.copy '.'
|
46
|
-
end
|
47
|
-
|
48
|
-
expect(script.method.arguments).to include('--archive')
|
49
|
-
expect(script.method.arguments).to_not include('--stats')
|
50
|
-
|
51
|
-
Synco::Runner.new(script).call
|
52
|
-
|
53
|
-
expect(Fingerprint).to be_identical(master_path, target_path)
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'should copy files using rsync snapshot' do
|
57
|
-
script = Synco::Script.build do |script|
|
58
|
-
script.method = Synco::Methods::RSyncSnapshot.new
|
59
|
-
|
60
|
-
script.server(:master) do |server|
|
61
|
-
server.root = master_path
|
62
|
-
end
|
63
|
-
|
64
|
-
script.server(:backup) do |server|
|
65
|
-
server.root = target_path
|
66
|
-
|
67
|
-
server.on(:success) do
|
68
|
-
run SYNCO_PATH, "rotate", chdir: target_server.root
|
69
|
-
run SYNCO_PATH, "prune", chdir: target_server.root
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
script.copy '.', arguments: %W{--archive}
|
74
|
-
end
|
75
|
-
|
76
|
-
expect(script.method.arguments).to include('--archive', '--stats')
|
77
|
-
|
78
|
-
Synco::Runner.new(script).call
|
79
|
-
|
80
|
-
expect(Fingerprint).to be_identical(master_path, File.join(target_path, Synco::LATEST_NAME))
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
RSpec.describe Synco::Methods::RSyncSnapshot do
|
85
|
-
it 'should generate correct command for ssh shell' do
|
86
|
-
expect(subject.escape(['ssh', '-o', 'BatchMode=yes'])).to be == 'ssh -o BatchMode=yes'
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
data/spec/synco/scp_spec.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rspec
|
2
|
-
|
3
|
-
# Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
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
|
13
|
-
# all 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
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'logger'
|
24
|
-
require 'synco/script'
|
25
|
-
require 'synco/scope'
|
26
|
-
require 'synco/methods/scp'
|
27
|
-
|
28
|
-
require_relative 'backup_script'
|
29
|
-
|
30
|
-
RSpec.describe Synco::Methods::SCP do
|
31
|
-
include_context "backup script"
|
32
|
-
|
33
|
-
it 'should build a script with desired configuration' do
|
34
|
-
script = Synco::Script.build do |script|
|
35
|
-
script.method = Synco::Methods::SCP.new
|
36
|
-
|
37
|
-
script.server(:master) do |server|
|
38
|
-
server.root = master_path
|
39
|
-
end
|
40
|
-
|
41
|
-
script.server(:target) do |server|
|
42
|
-
server.root = target_path
|
43
|
-
end
|
44
|
-
|
45
|
-
script.copy(".")
|
46
|
-
|
47
|
-
script.on(:failure) do |exception|
|
48
|
-
logger.error{exception}
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
expect(script.events).to include(:failure)
|
53
|
-
|
54
|
-
Synco::Runner.new(script).call
|
55
|
-
|
56
|
-
expect(Fingerprint).to be_identical(master_path, target_path)
|
57
|
-
end
|
58
|
-
end
|
data/spec/synco/script_spec.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rspec
|
2
|
-
|
3
|
-
# Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
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
|
13
|
-
# all 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
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'logger'
|
24
|
-
require 'synco/script'
|
25
|
-
require 'synco/methods/scp'
|
26
|
-
|
27
|
-
RSpec.describe Synco::Script do
|
28
|
-
it 'should build a script with desired configuration' do
|
29
|
-
script = Synco::Script.build do |script|
|
30
|
-
script.server(:master) do |server|
|
31
|
-
end
|
32
|
-
|
33
|
-
script.server(:backup) do |server|
|
34
|
-
server.root = 'backup'
|
35
|
-
|
36
|
-
server.on(:prepare) do
|
37
|
-
run "synco", "mount", chdir: server.root
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# After building, everything should be frozen..
|
43
|
-
expect(script).to be_frozen
|
44
|
-
|
45
|
-
# We should have the two servers defined:
|
46
|
-
expect(script.servers).to include(:master, :backup)
|
47
|
-
|
48
|
-
# We should have a single event for backup server:
|
49
|
-
expect(script[:backup].events).to include(:prepare)
|
50
|
-
end
|
51
|
-
end
|
data/spec/synco/shell_spec.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rspec
|
2
|
-
|
3
|
-
# Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
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
|
13
|
-
# all 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
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'synco/server'
|
24
|
-
require 'synco/shells/ssh'
|
25
|
-
|
26
|
-
RSpec.describe Synco::Shells::SSH do
|
27
|
-
let(:server) {Synco::Server.new('localhost')}
|
28
|
-
|
29
|
-
it 'should generate a connection command' do
|
30
|
-
expect(subject.connection_command(server)).to be == ['ssh', 'localhost']
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
RSpec.describe Synco::Shells::SSH.new(batch_mode: true) do
|
35
|
-
let(:server) {Synco::Server.new('localhost')}
|
36
|
-
|
37
|
-
it 'should generate a connection command with options' do
|
38
|
-
expect(subject.connection_command(server)).to be == ['ssh', '-o', 'BatchMode=yes', 'localhost']
|
39
|
-
end
|
40
|
-
end
|
data/spec/synco/usb_spec.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rspec
|
2
|
-
|
3
|
-
# Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
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
|
13
|
-
# all 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
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'synco/disk'
|
24
|
-
require 'synco/methods/rsync'
|
25
|
-
require_relative 'backup_script'
|
26
|
-
|
27
|
-
RSpec.describe Synco::Methods::RSyncSnapshot, if: Synco::Disk.available?('TEST') do
|
28
|
-
include_context "backup script"
|
29
|
-
|
30
|
-
before(:each) do
|
31
|
-
Synco::Disk.unmount(target_path)
|
32
|
-
end
|
33
|
-
|
34
|
-
after(:each) do
|
35
|
-
Synco::Disk.unmount(target_path)
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should mount and backup to an attached USB stick' do
|
39
|
-
script = Synco::Script.build do |script|
|
40
|
-
script.method = Synco::Methods::RSyncSnapshot.new
|
41
|
-
|
42
|
-
script.master = :source
|
43
|
-
|
44
|
-
script.server(:source) do |server|
|
45
|
-
server.root = master_path
|
46
|
-
end
|
47
|
-
|
48
|
-
script.server(:destination) do |server|
|
49
|
-
server.mountpoint = target_path
|
50
|
-
server.root = target_path
|
51
|
-
|
52
|
-
server.on(:prepare) do
|
53
|
-
target_server.run "synco", "mount", target_server.mountpoint, 'TEST'
|
54
|
-
end
|
55
|
-
|
56
|
-
# Runs after all directories have been successfully backed up.
|
57
|
-
server.on(:success) do
|
58
|
-
run "synco", "rotate", chdir: server.root
|
59
|
-
run "synco", "prune", chdir: server.root
|
60
|
-
end
|
61
|
-
|
62
|
-
server.on(:finish) do
|
63
|
-
target_server.run "synco", "unmount", target_server.mountpoint
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
script.backup('.')
|
68
|
-
end
|
69
|
-
|
70
|
-
Synco::Runner.new(script).call
|
71
|
-
|
72
|
-
Synco::Disk.mount(target_path, 'TEST')
|
73
|
-
|
74
|
-
expect(Fingerprint).to be_identical(master_path, File.join(target_path, Synco::LATEST_NAME))
|
75
|
-
end
|
76
|
-
end
|
data/spec/synco/zfs_spec.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rspec
|
2
|
-
|
3
|
-
# Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
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
|
13
|
-
# all 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
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'logger'
|
24
|
-
require 'synco/script'
|
25
|
-
require 'synco/scope'
|
26
|
-
require 'synco/methods/zfs'
|
27
|
-
|
28
|
-
RSpec.describe Synco::Methods::ZFS do
|
29
|
-
xit 'should mirror two ZFS partitions' do
|
30
|
-
script = Synco::Script.build(master: :source) do |script|
|
31
|
-
script.method = Synco::Methods::ZFS.new
|
32
|
-
|
33
|
-
script.server(:master) do |server|
|
34
|
-
server.host = 'hinoki.local'
|
35
|
-
server.root = '/tank/test/source'
|
36
|
-
end
|
37
|
-
|
38
|
-
script.server(:backup) do |server|
|
39
|
-
server.host = 'hinoki.local'
|
40
|
-
server.root = '/tank/test/destination'
|
41
|
-
end
|
42
|
-
|
43
|
-
script.copy("./")
|
44
|
-
end
|
45
|
-
|
46
|
-
Synco::Runner.new(script).call
|
47
|
-
|
48
|
-
expect(Fingerprint).to be_identical(script[:master].root, script[:backup].root)
|
49
|
-
end
|
50
|
-
end
|
data/synco.gemspec
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative 'lib/synco/version'
|
3
|
-
|
4
|
-
Gem::Specification.new do |spec|
|
5
|
-
spec.name = "synco"
|
6
|
-
spec.version = Synco::VERSION
|
7
|
-
spec.authors = ["Samuel Williams"]
|
8
|
-
spec.email = ["samuel.williams@oriontransfer.co.nz"]
|
9
|
-
spec.summary = %q{Synco is a tool for scripted synchronization and backups.}
|
10
|
-
spec.homepage = ""
|
11
|
-
spec.license = "MIT"
|
12
|
-
|
13
|
-
spec.files = `git ls-files -z`.split("\x0")
|
14
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
|
-
spec.require_paths = ["lib"]
|
17
|
-
|
18
|
-
spec.add_dependency("periodical", "~> 1.1")
|
19
|
-
spec.add_dependency("samovar", "~> 2.0")
|
20
|
-
spec.add_dependency("fingerprint", "~> 3.0")
|
21
|
-
spec.add_dependency("mapping", "~> 1.0")
|
22
|
-
spec.add_dependency("build-files", "~> 1.0")
|
23
|
-
spec.add_dependency("process-group", "~> 1.1")
|
24
|
-
|
25
|
-
spec.add_dependency("lockfile")
|
26
|
-
|
27
|
-
spec.add_development_dependency "covered"
|
28
|
-
spec.add_development_dependency "bundler"
|
29
|
-
spec.add_development_dependency "rspec", "~> 3.4"
|
30
|
-
spec.add_development_dependency "rake"
|
31
|
-
end
|