synco 1.1.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +3 -0
  3. data/bin/synco +3 -3
  4. data/lib/synco/command/disk.rb +8 -23
  5. data/lib/synco/command/prune.rb +10 -25
  6. data/lib/synco/command/rotate.rb +46 -61
  7. data/lib/synco/command/spawn.rb +10 -25
  8. data/lib/synco/command.rb +23 -35
  9. data/lib/synco/controller.rb +4 -19
  10. data/lib/synco/directory.rb +8 -23
  11. data/lib/synco/disk.rb +4 -19
  12. data/lib/synco/method.rb +11 -26
  13. data/lib/synco/methods/rsync.rb +14 -29
  14. data/lib/synco/methods/scp.rb +8 -23
  15. data/lib/synco/methods/zfs.rb +7 -22
  16. data/lib/synco/scope.rb +33 -68
  17. data/lib/synco/script.rb +15 -32
  18. data/lib/synco/server.rb +9 -24
  19. data/lib/synco/shell.rb +5 -20
  20. data/lib/synco/shells/ssh.rb +10 -25
  21. data/lib/synco/version.rb +5 -20
  22. data/lib/synco.rb +13 -29
  23. data/license.md +21 -0
  24. data/readme.md +248 -0
  25. data.tar.gz.sig +0 -0
  26. metadata +60 -120
  27. metadata.gz.sig +0 -0
  28. data/.gitignore +0 -22
  29. data/.rspec +0 -4
  30. data/.simplecov +0 -9
  31. data/.travis.yml +0 -14
  32. data/Gemfile +0 -11
  33. data/README.md +0 -246
  34. data/Rakefile +0 -8
  35. data/lib/synco/compact_formatter.rb +0 -115
  36. data/media/LSync Logo.artx/Preview/preview.png +0 -0
  37. data/media/LSync Logo.artx/QuickLook/Preview.pdf +0 -0
  38. data/media/LSync Logo.artx/doc.thread +0 -0
  39. data/media/LSync Logo.png +0 -0
  40. data/spec/synco/backup_script.rb +0 -63
  41. data/spec/synco/directory_spec.rb +0 -33
  42. data/spec/synco/local_backup.rb +0 -56
  43. data/spec/synco/local_sync.rb +0 -91
  44. data/spec/synco/method_spec.rb +0 -62
  45. data/spec/synco/rsync_spec.rb +0 -89
  46. data/spec/synco/scp_spec.rb +0 -58
  47. data/spec/synco/script_spec.rb +0 -51
  48. data/spec/synco/shell_spec.rb +0 -42
  49. data/spec/synco/usb_spec.rb +0 -76
  50. data/spec/synco/zfs_spec.rb +0 -50
  51. data/synco.gemspec +0 -35
@@ -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
- 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
- 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
-
@@ -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
- 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
@@ -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
- 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
@@ -1,42 +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
- module Synco::ShellSpec
27
- describe Synco::Shells::SSH do
28
- let(:server) {Synco::Server.new('localhost')}
29
-
30
- it 'should generate a connection command' do
31
- expect(subject.connection_command(server)).to be == ['ssh', 'localhost']
32
- end
33
- end
34
-
35
- describe Synco::Shells::SSH.new(batch_mode: true) do
36
- let(:server) {Synco::Server.new('localhost')}
37
-
38
- it 'should generate a connection command with options' do
39
- expect(subject.connection_command(server)).to be == ['ssh', '-o', 'BatchMode=yes', 'localhost']
40
- end
41
- end
42
- end
@@ -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
- 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
@@ -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
- 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,35 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'synco/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "synco"
8
- spec.version = Synco::VERSION
9
- spec.authors = ["Samuel Williams"]
10
- spec.email = ["samuel.williams@oriontransfer.co.nz"]
11
- spec.summary = %q{Synco is a tool for scripted synchronization and backups.}
12
- spec.homepage = ""
13
- spec.license = "MIT"
14
-
15
- spec.files = `git ls-files -z`.split("\x0")
16
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ["lib"]
19
-
20
- spec.add_dependency("periodical", "~> 1.1")
21
- spec.add_dependency("samovar", "~> 1.3")
22
- spec.add_dependency("fingerprint", "~> 2.0")
23
- spec.add_dependency("mapping", "~> 1.0")
24
- spec.add_dependency("build-files", "~> 1.0")
25
- spec.add_dependency("process-group", "~> 1.1")
26
-
27
- spec.add_dependency("lockfile")
28
- spec.add_dependency("rainbow", "~> 2.0")
29
-
30
- spec.has_rdoc = "yard"
31
-
32
- spec.add_development_dependency "bundler", "~> 1.11"
33
- spec.add_development_dependency "rspec", "~> 3.4"
34
- spec.add_development_dependency "rake"
35
- end