synco 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2220364fdaf5ff681db98ef502f6ba6cf3564a126881f4836f99c900a11c2683
|
4
|
+
data.tar.gz: 0e540bde6b6037f01a2d1afde4e7625e053d548a5ee2abfb773f7338767bb893
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c19fc3258b7fa09c588c29161d184783d334e6e9454ef7c9b202c9ae5bc0fb7fe0755a4f2ed9313359e1411e6848b42c619a5a273d1cbdb385ccb2a6f4b6805
|
7
|
+
data.tar.gz: 1d9dde6a44640464d8651ebce01acbdadcb470139e665c15985cb10172e1cd47467ad1ec2cb700fcdf9506ba8e4e6e03122f716193c8a039d4bb9e10dcc69b72
|
checksums.yaml.gz.sig
ADDED
data/bin/synco
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
# Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
5
|
#
|
@@ -24,6 +25,6 @@
|
|
24
25
|
# It then ensures that there is a symlink called "latest" that points
|
25
26
|
# to the renamed directory.
|
26
27
|
|
27
|
-
require
|
28
|
+
require "synco/command"
|
28
29
|
|
29
30
|
Synco::Command::Top.call
|
data/lib/synco/command/disk.rb
CHANGED
@@ -1,30 +1,15 @@
|
|
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
|
# This script takes a given path, and renames it with the given format.
|
22
7
|
# It then ensures that there is a symlink called "latest" that points
|
23
8
|
# to the renamed directory.
|
24
9
|
|
25
|
-
require
|
10
|
+
require "samovar"
|
26
11
|
|
27
|
-
require_relative
|
12
|
+
require_relative "../disk"
|
28
13
|
|
29
14
|
module Synco
|
30
15
|
module Command
|
data/lib/synco/command/prune.rb
CHANGED
@@ -1,33 +1,18 @@
|
|
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, 2009-2024, by Samuel Williams.
|
20
5
|
|
21
6
|
# This script takes a given path, and renames it with the given format.
|
22
7
|
# It then ensures that there is a symlink called "latest" that points
|
23
8
|
# to the renamed directory.
|
24
9
|
|
25
|
-
require
|
10
|
+
require "samovar"
|
26
11
|
|
27
|
-
require
|
12
|
+
require "periodical/filter"
|
28
13
|
|
29
14
|
# Required for strptime
|
30
|
-
require
|
15
|
+
require "date"
|
31
16
|
|
32
17
|
module Synco
|
33
18
|
module Command
|
@@ -79,7 +64,7 @@ module Synco
|
|
79
64
|
option "--format <name>", "Set the name of the backup rotations, including strftime expansions.", default: BACKUP_NAME
|
80
65
|
option "--latest <name>", "The name of the latest backup symlink.", default: LATEST_NAME
|
81
66
|
|
82
|
-
option "--keep <new|old>", "Keep the younger or older backups within the same period division", default:
|
67
|
+
option "--keep <new|old>", "Keep the younger or older backups within the same period division", default: "old"
|
83
68
|
|
84
69
|
option "--dry", "Print out what would be done rather than doing it."
|
85
70
|
end
|
@@ -100,7 +85,7 @@ module Synco
|
|
100
85
|
def current_backups
|
101
86
|
backups = []
|
102
87
|
|
103
|
-
Dir[
|
88
|
+
Dir["*"].each do |path|
|
104
89
|
next if path == @options[:latest]
|
105
90
|
date_string = File.basename(path)
|
106
91
|
|
data/lib/synco/command/rotate.rb
CHANGED
@@ -1,86 +1,71 @@
|
|
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, 2009-2024, by Samuel Williams.
|
20
5
|
|
21
6
|
# This script takes a given path, and renames it with the given format.
|
22
7
|
# It then ensures that there is a symlink called "latest" that points
|
23
8
|
# to the renamed directory.
|
24
9
|
|
25
|
-
require
|
10
|
+
require "samovar"
|
26
11
|
|
27
|
-
require_relative
|
12
|
+
require_relative "../method"
|
28
13
|
|
29
14
|
module Synco
|
30
15
|
module Command
|
31
16
|
class Rotate < Samovar::Command
|
32
|
-
|
17
|
+
self.description = "Rotate a backup snapshot into a timestamped directory."
|
33
18
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
19
|
+
options do
|
20
|
+
option "--format <name>", "Set the name of the backup rotations, including strftime expansions.", default: BACKUP_NAME
|
21
|
+
option "--latest <name>", "The name of the latest backup symlink.", default: LATEST_NAME
|
22
|
+
option "--snapshot <name>", "The name of the in-progress backup snapshot.", default: SNAPSHOT_NAME
|
38
23
|
|
39
|
-
|
40
|
-
|
24
|
+
# option "--timezone <name>", "The default timezone for backup timestamps.", default: BACKUP_TIMEZONE
|
25
|
+
end
|
41
26
|
|
42
|
-
|
43
|
-
|
27
|
+
def backup_timestamp
|
28
|
+
timestamp = Time.now.utc
|
44
29
|
|
45
|
-
|
46
|
-
|
47
|
-
|
30
|
+
#if timezone = @options[:timezone]
|
31
|
+
# timestamp = timestamp.in_time_zone(timezone)
|
32
|
+
#end
|
48
33
|
|
49
|
-
|
50
|
-
|
34
|
+
return timestamp
|
35
|
+
end
|
51
36
|
|
52
|
-
|
53
|
-
|
54
|
-
|
37
|
+
def backup_name
|
38
|
+
backup_timestamp.strftime(@options[:format])
|
39
|
+
end
|
55
40
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
41
|
+
def call
|
42
|
+
snapshot_name = @options[:snapshot]
|
43
|
+
unless File.exist? snapshot_name
|
44
|
+
$stderr.puts "Snapshot directory #{snapshot_name} does not exist!"
|
45
|
+
exit(10)
|
46
|
+
end
|
62
47
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
48
|
+
rotated_name = backup_name
|
49
|
+
if File.exist? rotated_name
|
50
|
+
$stderr.puts "Destination rotation name #{rotated_name} already exists!"
|
51
|
+
exit(20)
|
52
|
+
end
|
68
53
|
|
69
|
-
|
54
|
+
puts "Rotating #{snapshot_name} to #{rotated_name} in #{Dir.pwd}"
|
70
55
|
|
71
|
-
|
72
|
-
|
56
|
+
# Move rotated dir
|
57
|
+
FileUtils.mv(snapshot_name, rotated_name)
|
73
58
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
puts "Creating latest symlink to #{rotated_name}"
|
82
|
-
FileUtils.ln_s(rotated_name, latest_link)
|
59
|
+
# Recreate latest symlink
|
60
|
+
latest_link = @options[:latest]
|
61
|
+
if File.symlink?(latest_link)
|
62
|
+
puts "Removing old latest link..."
|
63
|
+
FileUtils.rm(latest_link)
|
83
64
|
end
|
65
|
+
|
66
|
+
puts "Creating latest symlink to #{rotated_name}"
|
67
|
+
FileUtils.ln_s(rotated_name, latest_link)
|
68
|
+
end
|
84
69
|
end
|
85
70
|
end
|
86
71
|
end
|
data/lib/synco/command/spawn.rb
CHANGED
@@ -1,39 +1,24 @@
|
|
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, 2009-2024, by Samuel Williams.
|
20
5
|
|
21
6
|
# This script takes a given path, and renames it with the given format.
|
22
7
|
# It then ensures that there is a symlink called "latest" that points
|
23
8
|
# to the renamed directory.
|
24
9
|
|
25
|
-
require
|
10
|
+
require "samovar"
|
26
11
|
|
27
12
|
module Synco
|
28
13
|
module Command
|
29
14
|
class Spawn < Samovar::Command
|
30
|
-
|
15
|
+
self.description = "Run a command using the synco environment and root directory."
|
31
16
|
|
32
|
-
|
17
|
+
split :argv, "Command to spawn."
|
33
18
|
|
34
|
-
|
35
|
-
|
36
|
-
|
19
|
+
def call
|
20
|
+
Process.exec(*@argv)
|
21
|
+
end
|
37
22
|
end
|
38
23
|
end
|
39
24
|
end
|
data/lib/synco/command.rb
CHANGED
@@ -1,33 +1,20 @@
|
|
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, 2016-2024, by Samuel Williams.
|
20
5
|
|
21
6
|
# This script takes a given path, and renames it with the given format.
|
22
7
|
# It then ensures that there is a symlink called "latest" that points
|
23
8
|
# to the renamed directory.
|
24
9
|
|
25
|
-
require
|
10
|
+
require "samovar"
|
11
|
+
|
12
|
+
require_relative "command/spawn"
|
13
|
+
require_relative "command/rotate"
|
14
|
+
require_relative "command/prune"
|
15
|
+
require_relative "command/disk"
|
26
16
|
|
27
|
-
require_relative
|
28
|
-
require_relative 'command/rotate'
|
29
|
-
require_relative 'command/prune'
|
30
|
-
require_relative 'command/disk'
|
17
|
+
require_relative "version"
|
31
18
|
|
32
19
|
module Synco
|
33
20
|
module Command
|
@@ -35,9 +22,9 @@ module Synco
|
|
35
22
|
self.description = "A backup and synchronizatio tool."
|
36
23
|
|
37
24
|
options do
|
38
|
-
option
|
39
|
-
option
|
40
|
-
option
|
25
|
+
option "--root <path>", "Work in the given root directory."
|
26
|
+
option "-h/--help", "Print out help information."
|
27
|
+
option "-v/--version", "Print out the application version."
|
41
28
|
end
|
42
29
|
|
43
30
|
def chdir(&block)
|
@@ -49,11 +36,11 @@ module Synco
|
|
49
36
|
end
|
50
37
|
|
51
38
|
nested :command, {
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
39
|
+
"spawn" => Spawn,
|
40
|
+
"rotate" => Rotate,
|
41
|
+
"prune" => Prune,
|
42
|
+
"mount" => Mount,
|
43
|
+
"unmount" => Unmount
|
57
44
|
}
|
58
45
|
|
59
46
|
def call
|
data/lib/synco/controller.rb
CHANGED
@@ -1,22 +1,7 @@
|
|
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, 2011-2024, by Samuel Williams.
|
20
5
|
|
21
6
|
module Synco
|
22
7
|
# Basic event handling and delegation.
|
data/lib/synco/directory.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_relative "controller"
|
22
7
|
|
23
8
|
module Synco
|
24
9
|
class AbsolutePathError < ArgumentError
|
@@ -28,7 +13,7 @@ module Synco
|
|
28
13
|
# such as excludes and other options may be specified.
|
29
14
|
class Directory < Controller
|
30
15
|
def initialize(path, arguments: [])
|
31
|
-
if path.start_with?(
|
16
|
+
if path.start_with?("/")
|
32
17
|
raise AbsolutePathError.new("#{path} must be relative!")
|
33
18
|
end
|
34
19
|
|
@@ -50,11 +35,11 @@ module Synco
|
|
50
35
|
end
|
51
36
|
|
52
37
|
def self.normalize(path)
|
53
|
-
path.end_with?(
|
38
|
+
path.end_with?("/") ? path : path + "/"
|
54
39
|
end
|
55
40
|
|
56
41
|
def self.depth(path)
|
57
|
-
path.count(
|
42
|
+
path.count("/")
|
58
43
|
end
|
59
44
|
end
|
60
45
|
end
|
data/lib/synco/disk.rb
CHANGED
@@ -1,22 +1,7 @@
|
|
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, 2016-2024, by Samuel Williams.
|
20
5
|
|
21
6
|
module Synco
|
22
7
|
# Depending on how you have things set up, you'll probably want to add
|
data/lib/synco/method.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
|
-
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2008-2024, by Samuel Williams.
|
5
|
+
|
6
|
+
require "fileutils"
|
7
|
+
require "pathname"
|
8
|
+
require_relative "controller"
|
24
9
|
|
25
10
|
module Synco
|
26
|
-
SNAPSHOT_NAME =
|
27
|
-
LATEST_NAME =
|
28
|
-
BACKUP_NAME =
|
29
|
-
BACKUP_TIMEZONE =
|
11
|
+
SNAPSHOT_NAME = "latest.snapshot"
|
12
|
+
LATEST_NAME = "latest"
|
13
|
+
BACKUP_NAME = "%Y.%m.%d-%H.%M.%S"
|
14
|
+
BACKUP_TIMEZONE = "UTC"
|
30
15
|
|
31
16
|
# A backup method provides the interface to copy data from one system to another.
|
32
17
|
class Method < Controller
|
data/lib/synco/methods/rsync.rb
CHANGED
@@ -1,25 +1,10 @@
|
|
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
|
-
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2011-2024, by Samuel Williams.
|
5
|
+
|
6
|
+
require_relative "../method"
|
7
|
+
require "shellwords"
|
23
8
|
|
24
9
|
module Synco
|
25
10
|
module Methods
|
@@ -48,16 +33,16 @@ module Synco
|
|
48
33
|
|
49
34
|
class RSync < Method
|
50
35
|
def default_command
|
51
|
-
[
|
36
|
+
["rsync"]
|
52
37
|
end
|
53
38
|
|
54
39
|
def initialize(*command, arguments: [], archive: false, stats: nil, **options)
|
55
40
|
if archive
|
56
|
-
arguments <<
|
41
|
+
arguments << "--archive"
|
57
42
|
end
|
58
43
|
|
59
44
|
if stats
|
60
|
-
arguments <<
|
45
|
+
arguments << "--stats"
|
61
46
|
end
|
62
47
|
|
63
48
|
super
|
@@ -67,7 +52,7 @@ module Synco
|
|
67
52
|
def escape(command)
|
68
53
|
case command
|
69
54
|
when Array
|
70
|
-
command.collect{|arg| escape(arg)}.join(
|
55
|
+
command.collect{|arg| escape(arg)}.join(" ")
|
71
56
|
when String
|
72
57
|
command =~ /\s|"|'/ ? command.dump : command
|
73
58
|
else
|
@@ -88,7 +73,7 @@ module Synco
|
|
88
73
|
command.pop
|
89
74
|
end
|
90
75
|
|
91
|
-
return [
|
76
|
+
return ["-e", escape(command)]
|
92
77
|
end
|
93
78
|
|
94
79
|
def call(scope)
|
@@ -131,7 +116,7 @@ module Synco
|
|
131
116
|
|
132
117
|
latest_path = File.join("../" * depth, latest_name, directory.path)
|
133
118
|
|
134
|
-
return [
|
119
|
+
return ["--link-dest", latest_path]
|
135
120
|
end
|
136
121
|
|
137
122
|
def call(scope)
|
@@ -143,7 +128,7 @@ module Synco
|
|
143
128
|
link_arguments = compute_link_arguments(directory, incremental_path)
|
144
129
|
|
145
130
|
# Create the destination backup directory
|
146
|
-
target_server.run(
|
131
|
+
target_server.run("mkdir", "-p", target_server.full_path(incremental_path))
|
147
132
|
|
148
133
|
master_server.run(
|
149
134
|
*@command,
|
@@ -159,4 +144,4 @@ module Synco
|
|
159
144
|
end
|
160
145
|
end
|
161
146
|
end
|
162
|
-
end
|
147
|
+
end
|