winton-rbackup 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/gemspec.rb +1 -1
- data/lib/rbackup.rb +20 -21
- data/rbackup.gemspec +1 -1
- metadata +1 -1
data/gemspec.rb
CHANGED
data/lib/rbackup.rb
CHANGED
@@ -17,6 +17,23 @@ class RBackup
|
|
17
17
|
get_profiles(args, @yaml)
|
18
18
|
end
|
19
19
|
|
20
|
+
def get_profiles(input, hash, force=false)
|
21
|
+
@profiles ||= []
|
22
|
+
hash.each do |key, value|
|
23
|
+
next unless value.respond_to?(:keys)
|
24
|
+
is_profile = value['source'] && value['destination']
|
25
|
+
if input.include?(key) || input.empty? || force
|
26
|
+
if is_profile
|
27
|
+
@profiles << value
|
28
|
+
else
|
29
|
+
get_profiles(input, value, true)
|
30
|
+
end
|
31
|
+
elsif !is_profile
|
32
|
+
get_profiles(input, value, force)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
20
37
|
def get_yaml
|
21
38
|
if $TESTING
|
22
39
|
config = SPEC + '/fixtures/rbackup.yml'
|
@@ -42,30 +59,11 @@ class RBackup
|
|
42
59
|
paths.collect { |path| path.gsub(' ', '\ ') }.join(' ')
|
43
60
|
end
|
44
61
|
|
45
|
-
def get_profiles(input, hash, force=false)
|
46
|
-
@profiles ||= []
|
47
|
-
hash.each do |key, value|
|
48
|
-
next unless value.respond_to?(:keys)
|
49
|
-
is_profile = value['source'] && value['destination']
|
50
|
-
if input.include?(key) || input.empty? || force
|
51
|
-
if is_profile
|
52
|
-
@profiles << value
|
53
|
-
else
|
54
|
-
get_profiles(input, value, true)
|
55
|
-
end
|
56
|
-
elsif !is_profile
|
57
|
-
get_profiles(input, value, force)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
62
|
def rsync(profile)
|
63
63
|
destination = profile['destination']
|
64
64
|
source = profile['source'].to_a
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
options = "--numeric-ids -axzSv"
|
66
|
+
options = "--numeric-ids --safe-links -axzSvL"
|
69
67
|
# --numeric-ids don't map uid/gid values by user/group name
|
70
68
|
# -a, --archive recursion and preserve almost everything (-rlptgoD)
|
71
69
|
# -x, --one-file-system don't cross filesystem boundaries
|
@@ -73,12 +71,13 @@ class RBackup
|
|
73
71
|
# -S, --sparse handle sparse files efficiently
|
74
72
|
# -v, --verbose verbose
|
75
73
|
|
76
|
-
if destination.include?('
|
74
|
+
if destination.include?(':') || source.include?(':')
|
77
75
|
options += ' -e ssh'
|
78
76
|
# -e, --rsh=COMMAND specify the remote shell to use
|
79
77
|
else
|
80
78
|
options += 'E'
|
81
79
|
# -E, --extended-attributes copy extended attributes, resource forks
|
80
|
+
FileUtils.mkdir_p destination
|
82
81
|
end
|
83
82
|
|
84
83
|
if profile['exclude']
|
data/rbackup.gemspec
CHANGED