rbackup 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/rbackup +1 -1
- data/gemspec.rb +1 -1
- data/lib/rbackup.rb +12 -4
- data/spec/fixtures/rbackup_reverse.yml +27 -0
- data/spec/rbackup_spec.rb +53 -44
- metadata +4 -3
data/bin/rbackup
CHANGED
data/gemspec.rb
CHANGED
data/lib/rbackup.rb
CHANGED
@@ -15,7 +15,8 @@ class RBackup
|
|
15
15
|
|
16
16
|
attr_accessor :profiles, :yaml
|
17
17
|
|
18
|
-
def initialize(*args)
|
18
|
+
def initialize(reverse, *args)
|
19
|
+
@reverse = reverse
|
19
20
|
get_yaml
|
20
21
|
get_profiles(args, @yaml)
|
21
22
|
end
|
@@ -38,8 +39,8 @@ class RBackup
|
|
38
39
|
end
|
39
40
|
|
40
41
|
def get_yaml
|
41
|
-
if $
|
42
|
-
config =
|
42
|
+
if $rbackup_config
|
43
|
+
config = $rbackup_config
|
43
44
|
else
|
44
45
|
config = File.expand_path("~/.rbackup.yml")
|
45
46
|
end
|
@@ -66,7 +67,14 @@ class RBackup
|
|
66
67
|
inc1ude = []
|
67
68
|
exclude = []
|
68
69
|
destination = profile['destination']
|
69
|
-
source =
|
70
|
+
source = profile['source']
|
71
|
+
|
72
|
+
if @reverse
|
73
|
+
last = source.split('/').last
|
74
|
+
source = source.split('/')[0..-2].join('/')
|
75
|
+
destination = [ destination, '/', last ].join('/')
|
76
|
+
destination, source = source, destination
|
77
|
+
end
|
70
78
|
|
71
79
|
options = "--numeric-ids --safe-links -axzSvL"
|
72
80
|
# --numeric-ids don't map uid/gid values by user/group name
|
@@ -0,0 +1,27 @@
|
|
1
|
+
profile_1:
|
2
|
+
source: SPEC/fixtures/destination/*
|
3
|
+
destination: SPEC/fixtures/source
|
4
|
+
exclude: 1.txt
|
5
|
+
profile_2:
|
6
|
+
source: SPEC/fixtures/destination/*
|
7
|
+
destination: SPEC/fixtures/source
|
8
|
+
exclude: 2.txt
|
9
|
+
profile_3:
|
10
|
+
profile_4:
|
11
|
+
source: SPEC/fixtures/destination/*
|
12
|
+
destination: SPEC/fixtures/source
|
13
|
+
exclude:
|
14
|
+
- 1.txt
|
15
|
+
- 2.txt
|
16
|
+
profile_5:
|
17
|
+
source: SPEC/fixtures/destination/*
|
18
|
+
destination: SPEC/fixtures/source
|
19
|
+
exclude:
|
20
|
+
- 1.txt
|
21
|
+
- 3.txt
|
22
|
+
profile_6:
|
23
|
+
source: SPEC/fixtures/destination/*
|
24
|
+
destination: SPEC/fixtures/source
|
25
|
+
include:
|
26
|
+
- 2.txt
|
27
|
+
- 3.txt
|
data/spec/rbackup_spec.rb
CHANGED
@@ -1,55 +1,64 @@
|
|
1
1
|
require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
|
2
2
|
|
3
3
|
describe RBackup do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
[ :normal, :reverse ].each do |type|
|
5
|
+
before(:each) do
|
6
|
+
if type == :normal
|
7
|
+
$rbackup_config = SPEC + '/fixtures/rbackup.yml'
|
8
|
+
@reverse = false
|
9
|
+
else
|
10
|
+
$rbackup_config = SPEC + '/fixtures/rbackup_reverse.yml'
|
11
|
+
@reverse = true
|
12
|
+
end
|
13
|
+
Dir[SPEC + '/fixtures/destination/*'].each do |path|
|
14
|
+
FileUtils.rm_rf(path)
|
15
|
+
end
|
7
16
|
end
|
8
|
-
end
|
9
17
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
it "should backup all profiles" do
|
19
|
+
RBackup.new(@reverse).run
|
20
|
+
File.exists?(SPEC + '/fixtures/destination/1.txt').should == true
|
21
|
+
File.exists?(SPEC + '/fixtures/destination/2.txt').should == true
|
22
|
+
File.exists?(SPEC + '/fixtures/destination/3.txt').should == true
|
23
|
+
File.read(SPEC + '/fixtures/destination/1.txt').should == '1'
|
24
|
+
File.read(SPEC + '/fixtures/destination/2.txt').should == '2'
|
25
|
+
File.read(SPEC + '/fixtures/destination/3.txt').should == '3'
|
26
|
+
end
|
19
27
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
+
it "should backup profile_1" do
|
29
|
+
RBackup.new(@reverse, 'profile_1').run
|
30
|
+
File.exists?(SPEC + '/fixtures/destination/1.txt').should == false
|
31
|
+
File.exists?(SPEC + '/fixtures/destination/2.txt').should == true
|
32
|
+
File.exists?(SPEC + '/fixtures/destination/3.txt').should == true
|
33
|
+
File.read(SPEC + '/fixtures/destination/2.txt').should == '2'
|
34
|
+
File.read(SPEC + '/fixtures/destination/3.txt').should == '3'
|
35
|
+
end
|
28
36
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
+
it "should backup profile_2" do
|
38
|
+
RBackup.new(@reverse, 'profile_2').run
|
39
|
+
File.exists?(SPEC + '/fixtures/destination/1.txt').should == true
|
40
|
+
File.exists?(SPEC + '/fixtures/destination/2.txt').should == false
|
41
|
+
File.exists?(SPEC + '/fixtures/destination/3.txt').should == true
|
42
|
+
File.read(SPEC + '/fixtures/destination/1.txt').should == '1'
|
43
|
+
File.read(SPEC + '/fixtures/destination/3.txt').should == '3'
|
44
|
+
end
|
37
45
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
+
it "should backup profile_3" do
|
47
|
+
RBackup.new(@reverse, 'profile_3').run
|
48
|
+
File.exists?(SPEC + '/fixtures/destination/1.txt').should == false
|
49
|
+
File.exists?(SPEC + '/fixtures/destination/2.txt').should == true
|
50
|
+
File.exists?(SPEC + '/fixtures/destination/3.txt').should == true
|
51
|
+
File.read(SPEC + '/fixtures/destination/2.txt').should == '2'
|
52
|
+
File.read(SPEC + '/fixtures/destination/3.txt').should == '3'
|
53
|
+
end
|
46
54
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
55
|
+
it "should backup profile_6" do
|
56
|
+
RBackup.new(@reverse, 'profile_6').run
|
57
|
+
File.exists?(SPEC + '/fixtures/destination/1.txt').should == false
|
58
|
+
File.exists?(SPEC + '/fixtures/destination/2.txt').should == true
|
59
|
+
File.exists?(SPEC + '/fixtures/destination/3.txt').should == true
|
60
|
+
File.read(SPEC + '/fixtures/destination/2.txt').should == '2'
|
61
|
+
File.read(SPEC + '/fixtures/destination/3.txt').should == '3'
|
62
|
+
end
|
54
63
|
end
|
55
64
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 9
|
9
|
+
version: 0.1.9
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Winton Welsh
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2011-02-03 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- rbackup.gemspec
|
36
36
|
- README.markdown
|
37
37
|
- spec/fixtures/rbackup.yml
|
38
|
+
- spec/fixtures/rbackup_reverse.yml
|
38
39
|
- spec/fixtures/source/1.txt
|
39
40
|
- spec/fixtures/source/2.txt
|
40
41
|
- spec/fixtures/source/3.txt
|