interu-backup 3.0.16

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.
Files changed (151) hide show
  1. data/.gitignore +2 -0
  2. data/Gemfile +31 -0
  3. data/Gemfile.lock +117 -0
  4. data/Guardfile +17 -0
  5. data/LICENSE.md +24 -0
  6. data/README.md +332 -0
  7. data/backup.gemspec +31 -0
  8. data/bin/backup +267 -0
  9. data/lib/backup.rb +181 -0
  10. data/lib/backup/archive.rb +73 -0
  11. data/lib/backup/cli.rb +82 -0
  12. data/lib/backup/compressor/base.rb +17 -0
  13. data/lib/backup/compressor/bzip2.rb +64 -0
  14. data/lib/backup/compressor/gzip.rb +61 -0
  15. data/lib/backup/configuration/base.rb +15 -0
  16. data/lib/backup/configuration/compressor/base.rb +10 -0
  17. data/lib/backup/configuration/compressor/bzip2.rb +23 -0
  18. data/lib/backup/configuration/compressor/gzip.rb +23 -0
  19. data/lib/backup/configuration/database/base.rb +18 -0
  20. data/lib/backup/configuration/database/mongodb.rb +41 -0
  21. data/lib/backup/configuration/database/mysql.rb +37 -0
  22. data/lib/backup/configuration/database/postgresql.rb +37 -0
  23. data/lib/backup/configuration/database/redis.rb +35 -0
  24. data/lib/backup/configuration/encryptor/base.rb +10 -0
  25. data/lib/backup/configuration/encryptor/gpg.rb +17 -0
  26. data/lib/backup/configuration/encryptor/open_ssl.rb +26 -0
  27. data/lib/backup/configuration/helpers.rb +54 -0
  28. data/lib/backup/configuration/notifier/base.rb +39 -0
  29. data/lib/backup/configuration/notifier/campfire.rb +25 -0
  30. data/lib/backup/configuration/notifier/mail.rb +52 -0
  31. data/lib/backup/configuration/notifier/presently.rb +25 -0
  32. data/lib/backup/configuration/notifier/twitter.rb +21 -0
  33. data/lib/backup/configuration/storage/base.rb +18 -0
  34. data/lib/backup/configuration/storage/cloudfiles.rb +21 -0
  35. data/lib/backup/configuration/storage/dropbox.rb +29 -0
  36. data/lib/backup/configuration/storage/ftp.rb +25 -0
  37. data/lib/backup/configuration/storage/rsync.rb +25 -0
  38. data/lib/backup/configuration/storage/s3.rb +25 -0
  39. data/lib/backup/configuration/storage/scp.rb +25 -0
  40. data/lib/backup/configuration/storage/sftp.rb +25 -0
  41. data/lib/backup/configuration/syncer/rsync.rb +45 -0
  42. data/lib/backup/configuration/syncer/s3.rb +33 -0
  43. data/lib/backup/database/base.rb +33 -0
  44. data/lib/backup/database/mongodb.rb +179 -0
  45. data/lib/backup/database/mysql.rb +104 -0
  46. data/lib/backup/database/postgresql.rb +111 -0
  47. data/lib/backup/database/redis.rb +105 -0
  48. data/lib/backup/dependency.rb +96 -0
  49. data/lib/backup/encryptor/base.rb +17 -0
  50. data/lib/backup/encryptor/gpg.rb +78 -0
  51. data/lib/backup/encryptor/open_ssl.rb +67 -0
  52. data/lib/backup/exception/command_not_found.rb +8 -0
  53. data/lib/backup/finder.rb +39 -0
  54. data/lib/backup/logger.rb +102 -0
  55. data/lib/backup/model.rb +272 -0
  56. data/lib/backup/notifier/base.rb +29 -0
  57. data/lib/backup/notifier/binder.rb +32 -0
  58. data/lib/backup/notifier/campfire.rb +194 -0
  59. data/lib/backup/notifier/mail.rb +141 -0
  60. data/lib/backup/notifier/presently.rb +105 -0
  61. data/lib/backup/notifier/templates/notify_failure.erb +33 -0
  62. data/lib/backup/notifier/templates/notify_success.erb +16 -0
  63. data/lib/backup/notifier/twitter.rb +87 -0
  64. data/lib/backup/storage/base.rb +67 -0
  65. data/lib/backup/storage/cloudfiles.rb +95 -0
  66. data/lib/backup/storage/dropbox.rb +91 -0
  67. data/lib/backup/storage/ftp.rb +114 -0
  68. data/lib/backup/storage/object.rb +45 -0
  69. data/lib/backup/storage/rsync.rb +129 -0
  70. data/lib/backup/storage/s3.rb +180 -0
  71. data/lib/backup/storage/scp.rb +106 -0
  72. data/lib/backup/storage/sftp.rb +106 -0
  73. data/lib/backup/syncer/base.rb +10 -0
  74. data/lib/backup/syncer/rsync.rb +152 -0
  75. data/lib/backup/syncer/s3.rb +118 -0
  76. data/lib/backup/version.rb +43 -0
  77. data/lib/templates/archive +7 -0
  78. data/lib/templates/compressor/bzip2 +7 -0
  79. data/lib/templates/compressor/gzip +7 -0
  80. data/lib/templates/database/mongodb +14 -0
  81. data/lib/templates/database/mysql +14 -0
  82. data/lib/templates/database/postgresql +14 -0
  83. data/lib/templates/database/redis +13 -0
  84. data/lib/templates/encryptor/gpg +12 -0
  85. data/lib/templates/encryptor/openssl +8 -0
  86. data/lib/templates/notifier/campfire +11 -0
  87. data/lib/templates/notifier/mail +17 -0
  88. data/lib/templates/notifier/presently +12 -0
  89. data/lib/templates/notifier/twitter +12 -0
  90. data/lib/templates/readme +15 -0
  91. data/lib/templates/storage/cloudfiles +10 -0
  92. data/lib/templates/storage/dropbox +12 -0
  93. data/lib/templates/storage/ftp +11 -0
  94. data/lib/templates/storage/rsync +10 -0
  95. data/lib/templates/storage/s3 +21 -0
  96. data/lib/templates/storage/scp +11 -0
  97. data/lib/templates/storage/sftp +11 -0
  98. data/lib/templates/syncer/rsync +17 -0
  99. data/lib/templates/syncer/s3 +15 -0
  100. data/spec/archive_spec.rb +90 -0
  101. data/spec/backup_spec.rb +11 -0
  102. data/spec/compressor/bzip2_spec.rb +59 -0
  103. data/spec/compressor/gzip_spec.rb +59 -0
  104. data/spec/configuration/base_spec.rb +35 -0
  105. data/spec/configuration/compressor/gzip_spec.rb +28 -0
  106. data/spec/configuration/database/base_spec.rb +16 -0
  107. data/spec/configuration/database/mongodb_spec.rb +30 -0
  108. data/spec/configuration/database/mysql_spec.rb +32 -0
  109. data/spec/configuration/database/postgresql_spec.rb +32 -0
  110. data/spec/configuration/database/redis_spec.rb +30 -0
  111. data/spec/configuration/encryptor/gpg_spec.rb +25 -0
  112. data/spec/configuration/encryptor/open_ssl_spec.rb +31 -0
  113. data/spec/configuration/notifier/campfire_spec.rb +20 -0
  114. data/spec/configuration/notifier/mail_spec.rb +32 -0
  115. data/spec/configuration/notifier/twitter_spec.rb +22 -0
  116. data/spec/configuration/storage/cloudfiles_spec.rb +34 -0
  117. data/spec/configuration/storage/dropbox_spec.rb +43 -0
  118. data/spec/configuration/storage/ftp_spec.rb +40 -0
  119. data/spec/configuration/storage/rsync_spec.rb +37 -0
  120. data/spec/configuration/storage/s3_spec.rb +37 -0
  121. data/spec/configuration/storage/scp_spec.rb +40 -0
  122. data/spec/configuration/storage/sftp_spec.rb +40 -0
  123. data/spec/configuration/syncer/rsync_spec.rb +46 -0
  124. data/spec/configuration/syncer/s3_spec.rb +43 -0
  125. data/spec/database/base_spec.rb +30 -0
  126. data/spec/database/mongodb_spec.rb +181 -0
  127. data/spec/database/mysql_spec.rb +150 -0
  128. data/spec/database/postgresql_spec.rb +164 -0
  129. data/spec/database/redis_spec.rb +122 -0
  130. data/spec/encryptor/gpg_spec.rb +57 -0
  131. data/spec/encryptor/open_ssl_spec.rb +102 -0
  132. data/spec/logger_spec.rb +58 -0
  133. data/spec/model_spec.rb +236 -0
  134. data/spec/notifier/campfire_spec.rb +96 -0
  135. data/spec/notifier/mail_spec.rb +97 -0
  136. data/spec/notifier/presently_spec.rb +99 -0
  137. data/spec/notifier/twitter_spec.rb +86 -0
  138. data/spec/spec_helper.rb +25 -0
  139. data/spec/storage/base_spec.rb +33 -0
  140. data/spec/storage/cloudfiles_spec.rb +102 -0
  141. data/spec/storage/dropbox_spec.rb +105 -0
  142. data/spec/storage/ftp_spec.rb +133 -0
  143. data/spec/storage/object_spec.rb +74 -0
  144. data/spec/storage/rsync_spec.rb +131 -0
  145. data/spec/storage/s3_spec.rb +110 -0
  146. data/spec/storage/scp_spec.rb +129 -0
  147. data/spec/storage/sftp_spec.rb +125 -0
  148. data/spec/syncer/rsync_spec.rb +195 -0
  149. data/spec/syncer/s3_spec.rb +139 -0
  150. data/spec/version_spec.rb +21 -0
  151. metadata +231 -0
@@ -0,0 +1,129 @@
1
+ # encoding: utf-8
2
+
3
+ require File.dirname(__FILE__) + '/../spec_helper'
4
+
5
+ describe Backup::Storage::SCP do
6
+
7
+ let(:scp) do
8
+ Backup::Storage::SCP.new do |scp|
9
+ scp.username = 'my_username'
10
+ scp.password = 'my_password'
11
+ scp.ip = '123.45.678.90'
12
+ scp.port = 22
13
+ scp.path = '~/backups/'
14
+ scp.keep = 20
15
+ end
16
+ end
17
+
18
+ before do
19
+ Backup::Configuration::Storage::SCP.clear_defaults!
20
+ end
21
+
22
+ it 'should have defined the configuration properly' do
23
+ scp.username.should == 'my_username'
24
+ scp.password.should == 'my_password'
25
+ scp.ip.should == '123.45.678.90'
26
+ scp.port.should == 22
27
+ scp.path.should == 'backups/'
28
+ scp.keep.should == 20
29
+ end
30
+
31
+ it 'should use the defaults if a particular attribute has not been defined' do
32
+ Backup::Configuration::Storage::SCP.defaults do |scp|
33
+ scp.username = 'my_default_username'
34
+ scp.password = 'my_default_password'
35
+ scp.path = '~/backups'
36
+ end
37
+
38
+ scp = Backup::Storage::SCP.new do |scp|
39
+ scp.password = 'my_password'
40
+ scp.ip = '123.45.678.90'
41
+ end
42
+
43
+ scp.username.should == 'my_default_username'
44
+ scp.password.should == 'my_password'
45
+ scp.ip.should == '123.45.678.90'
46
+ scp.port.should == 22
47
+ end
48
+
49
+ it 'should have its own defaults' do
50
+ scp = Backup::Storage::SCP.new
51
+ scp.port.should == 22
52
+ scp.path.should == 'backups'
53
+ end
54
+
55
+ describe '#connection' do
56
+ it 'should establish a connection to the remote server using the provided ip address and credentials' do
57
+ Net::SSH.expects(:start).with('123.45.678.90', 'my_username', :password => 'my_password', :port => 22)
58
+ scp.send(:connection)
59
+ end
60
+ end
61
+
62
+ describe '#transfer!' do
63
+ let(:connection) { mock('Net::SCP') }
64
+
65
+ before do
66
+ Net::SSH.stubs(:start).returns(connection)
67
+ scp.stubs(:create_remote_directories!)
68
+ Backup::Logger.stubs(:message)
69
+ end
70
+
71
+ it 'should transfer the provided file to the path' do
72
+ Backup::Model.new('blah', 'blah') {}
73
+ file = mock("Backup::Storage::SCP::File")
74
+
75
+ scp.expects(:create_remote_directories!)
76
+
77
+ ssh_scp = mock('Net::SSH::SCP')
78
+ connection.expects(:scp).returns(ssh_scp)
79
+
80
+ ssh_scp.expects(:upload!).with(
81
+ File.join(Backup::TMP_PATH, "#{ Backup::TIME }.#{ Backup::TRIGGER }.tar"),
82
+ File.join('backups/myapp', "#{ Backup::TIME }.#{ Backup::TRIGGER }.tar")
83
+ )
84
+
85
+ scp.send(:transfer!)
86
+ end
87
+ end
88
+
89
+ describe '#remove!' do
90
+ let(:connection) { mock('Net::SCP') }
91
+
92
+ before do
93
+ Net::SSH.stubs(:start).returns(connection)
94
+ end
95
+
96
+ it 'should remove the file from the remote server path' do
97
+ connection.expects(:exec!).with("rm backups/myapp/#{ Backup::TIME }.#{ Backup::TRIGGER }.tar")
98
+ scp.send(:remove!)
99
+ end
100
+ end
101
+
102
+ describe '#create_remote_directories!' do
103
+ let(:connection) { mock('Net::SSH') }
104
+
105
+ before do
106
+ Net::SSH.stubs(:start).returns(connection)
107
+ end
108
+
109
+ it 'should properly create remote directories one by one' do
110
+ scp.path = 'backups/some_other_folder/another_folder'
111
+
112
+ connection.expects(:exec!).with("mkdir 'backups'")
113
+ connection.expects(:exec!).with("mkdir 'backups/some_other_folder'")
114
+ connection.expects(:exec!).with("mkdir 'backups/some_other_folder/another_folder'")
115
+ connection.expects(:exec!).with("mkdir 'backups/some_other_folder/another_folder/myapp'")
116
+
117
+ scp.send(:create_remote_directories!)
118
+ end
119
+ end
120
+
121
+ describe '#perform' do
122
+ it 'should invoke transfer! and cycle!' do
123
+ scp.expects(:transfer!)
124
+ scp.expects(:cycle!)
125
+ scp.perform!
126
+ end
127
+ end
128
+
129
+ end
@@ -0,0 +1,125 @@
1
+ # encoding: utf-8
2
+
3
+ require File.dirname(__FILE__) + '/../spec_helper'
4
+
5
+ describe Backup::Storage::SFTP do
6
+
7
+ let(:sftp) do
8
+ Backup::Storage::SFTP.new do |sftp|
9
+ sftp.username = 'my_username'
10
+ sftp.password = 'my_password'
11
+ sftp.ip = '123.45.678.90'
12
+ sftp.port = 22
13
+ sftp.path = '~/backups/'
14
+ sftp.keep = 20
15
+ end
16
+ end
17
+
18
+ before do
19
+ Backup::Configuration::Storage::SFTP.clear_defaults!
20
+ end
21
+
22
+ it 'should have defined the configuration properly' do
23
+ sftp.username.should == 'my_username'
24
+ sftp.password.should == 'my_password'
25
+ sftp.ip.should == '123.45.678.90'
26
+ sftp.port.should == 22
27
+ sftp.path.should == 'backups/'
28
+ sftp.keep.should == 20
29
+ end
30
+
31
+ it 'should use the defaults if a particular attribute has not been defined' do
32
+ Backup::Configuration::Storage::SFTP.defaults do |sftp|
33
+ sftp.username = 'my_default_username'
34
+ sftp.password = 'my_default_password'
35
+ sftp.path = '~/backups'
36
+ end
37
+
38
+ sftp = Backup::Storage::SFTP.new do |sftp|
39
+ sftp.password = 'my_password'
40
+ sftp.ip = '123.45.678.90'
41
+ end
42
+
43
+ sftp.username.should == 'my_default_username'
44
+ sftp.password.should == 'my_password'
45
+ sftp.ip.should == '123.45.678.90'
46
+ sftp.port.should == 22
47
+ end
48
+
49
+ it 'should have its own defaults' do
50
+ sftp = Backup::Storage::SFTP.new
51
+ sftp.port.should == 22
52
+ sftp.path.should == 'backups'
53
+ end
54
+
55
+ describe '#connection' do
56
+ it 'should establish a connection to the remote server using the provided ip address and credentials' do
57
+ Net::SFTP.expects(:start).with('123.45.678.90', 'my_username', :password => 'my_password', :port => 22)
58
+ sftp.send(:connection)
59
+ end
60
+ end
61
+
62
+ describe '#transfer!' do
63
+ let(:connection) { mock('Fog::Storage') }
64
+
65
+ before do
66
+ Net::SFTP.stubs(:start).returns(connection)
67
+ sftp.stubs(:create_remote_directories!)
68
+ Backup::Logger.stubs(:message)
69
+ end
70
+
71
+ it 'should transfer the provided file to the path' do
72
+ Backup::Model.new('blah', 'blah') {}
73
+ file = mock("Backup::Storage::SFTP::File")
74
+
75
+ sftp.expects(:create_remote_directories!)
76
+ connection.expects(:upload!).with(
77
+ File.join(Backup::TMP_PATH, "#{ Backup::TIME }.#{ Backup::TRIGGER }.tar"),
78
+ File.join('backups/myapp', "#{ Backup::TIME }.#{ Backup::TRIGGER }.tar")
79
+ )
80
+
81
+ sftp.send(:transfer!)
82
+ end
83
+ end
84
+
85
+ describe '#remove!' do
86
+ let(:connection) { mock('Net::SFTP') }
87
+
88
+ before do
89
+ Net::SFTP.stubs(:start).returns(connection)
90
+ end
91
+
92
+ it 'should remove the file from the remote server path' do
93
+ connection.expects(:remove!).with("backups/myapp/#{ Backup::TIME }.#{ Backup::TRIGGER }.tar")
94
+ sftp.send(:remove!)
95
+ end
96
+ end
97
+
98
+ describe '#create_remote_directories!' do
99
+ let(:connection) { mock('Net::SFTP') }
100
+
101
+ before do
102
+ Net::SFTP.stubs(:start).returns(connection)
103
+ end
104
+
105
+ it 'should properly create remote directories one by one' do
106
+ sftp.path = 'backups/some_other_folder/another_folder'
107
+
108
+ connection.expects(:mkdir!).with('backups')
109
+ connection.expects(:mkdir!).with('backups/some_other_folder')
110
+ connection.expects(:mkdir!).with('backups/some_other_folder/another_folder')
111
+ connection.expects(:mkdir!).with('backups/some_other_folder/another_folder/myapp')
112
+
113
+ sftp.send(:create_remote_directories!)
114
+ end
115
+ end
116
+
117
+ describe '#perform' do
118
+ it 'should invoke transfer! and cycle!' do
119
+ sftp.expects(:transfer!)
120
+ sftp.expects(:cycle!)
121
+ sftp.perform!
122
+ end
123
+ end
124
+
125
+ end
@@ -0,0 +1,195 @@
1
+ # encoding: utf-8
2
+
3
+ require File.dirname(__FILE__) + '/../spec_helper'
4
+
5
+ describe Backup::Syncer::RSync do
6
+
7
+ let(:rsync) do
8
+ Backup::Syncer::RSync.new do |rsync|
9
+ rsync.username = 'my_username'
10
+ rsync.password = 'my_password'
11
+ rsync.ip = '123.45.678.90'
12
+ rsync.port = 22
13
+ rsync.path = '~/backups/'
14
+ rsync.mirror = true
15
+ rsync.compress = true
16
+ rsync.additional_options = []
17
+
18
+ rsync.directories do |directory|
19
+ directory.add "/some/random/directory"
20
+ directory.add "/another/random/directory"
21
+ end
22
+ end
23
+ end
24
+
25
+ before do
26
+ Backup::Configuration::Syncer::RSync.clear_defaults!
27
+ end
28
+
29
+ it 'should have defined the configuration properly' do
30
+ rsync.username.should == 'my_username'
31
+ rsync.password.should =~ /backup-rsync-password/
32
+ rsync.ip.should == '123.45.678.90'
33
+ rsync.port.should == "--port='22'"
34
+ rsync.path.should == 'backups/'
35
+ rsync.mirror.should == "--delete"
36
+ rsync.compress.should == "--compress"
37
+
38
+ File.read(rsync.instance_variable_get('@password_file').path).should == 'my_password'
39
+ end
40
+
41
+ it 'should use the defaults if a particular attribute has not been defined' do
42
+ Backup::Configuration::Syncer::RSync.defaults do |rsync|
43
+ rsync.username = 'my_default_username'
44
+ rsync.password = 'my_default_password'
45
+ rsync.path = '~/backups'
46
+ rsync.mirror = false
47
+ end
48
+
49
+ rsync = Backup::Syncer::RSync.new do |rsync|
50
+ rsync.password = 'my_password'
51
+ rsync.ip = '123.45.678.90'
52
+ rsync.compress = false
53
+ end
54
+
55
+ rsync.username.should == 'my_default_username'
56
+ rsync.password.should =~ /backup-rsync-password/
57
+ rsync.ip.should == '123.45.678.90'
58
+ rsync.port.should == "--port='22'"
59
+ rsync.mirror.should == nil
60
+ rsync.compress.should == nil
61
+
62
+ File.read(rsync.instance_variable_get('@password_file').path).should == 'my_password'
63
+ end
64
+
65
+ it 'should have its own defaults' do
66
+ rsync = Backup::Syncer::RSync.new
67
+ rsync.port.should == "--port='22'"
68
+ rsync.path.should == 'backups'
69
+ rsync.compress.should == nil
70
+ rsync.mirror.should == nil
71
+ rsync.directories.should == ''
72
+ rsync.additional_options.should == []
73
+ end
74
+
75
+ describe '#mirror' do
76
+ context 'when true' do
77
+ it do
78
+ rsync.mirror = true
79
+ rsync.mirror.should == '--delete'
80
+ end
81
+ end
82
+
83
+ context 'when nil/false' do
84
+ it do
85
+ rsync.mirror = nil
86
+ rsync.mirror.should == nil
87
+ end
88
+
89
+ it do
90
+ rsync.mirror = false
91
+ rsync.mirror.should == nil
92
+ end
93
+ end
94
+ end
95
+
96
+ describe '#compress' do
97
+ context 'when true' do
98
+ it do
99
+ rsync.compress = true
100
+ rsync.compress.should == '--compress'
101
+ end
102
+ end
103
+
104
+ context 'when nil/false' do
105
+ it do
106
+ rsync.compress = nil
107
+ rsync.compress.should == nil
108
+ end
109
+
110
+ it do
111
+ rsync.compress = false
112
+ rsync.compress.should == nil
113
+ end
114
+ end
115
+ end
116
+
117
+ describe '#archive' do
118
+ it do
119
+ rsync.archive.should == '--archive'
120
+ end
121
+ end
122
+
123
+ describe '#port' do
124
+ it do
125
+ rsync.port.should == "--port='22'"
126
+ end
127
+ end
128
+
129
+ describe '#directories' do
130
+ context 'when its empty' do
131
+ it do
132
+ rsync.directories = []
133
+ rsync.directories.should == ''
134
+ end
135
+ end
136
+
137
+ context 'when it has items' do
138
+ it do
139
+ rsync.directories = ['directory1', 'directory1/directory2', 'directory1/directory2/directory3']
140
+ rsync.directories.should == "'directory1' 'directory1/directory2' 'directory1/directory2/directory3'"
141
+ end
142
+ end
143
+ end
144
+
145
+ describe '#options' do
146
+ it do
147
+ rsync.options.should == "--archive --delete --compress --port='22' " +
148
+ "--password-file='#{rsync.instance_variable_get('@password_file').path}'"
149
+ end
150
+ end
151
+
152
+ describe '#password' do
153
+ before do
154
+ Backup::Logger.stubs(:message)
155
+ rsync.stubs(:utility).with(:rsync).returns(:rsync)
156
+ rsync.stubs(:run)
157
+ end
158
+
159
+ it do
160
+ rsync.password = 'my_password'
161
+ rsync.expects(:remove_password_file!)
162
+
163
+ rsync.perform!
164
+ end
165
+
166
+ it do
167
+ rsync.password = nil
168
+ rsync.expects(:remove_password_file!)
169
+
170
+ rsync.perform!
171
+ end
172
+ end
173
+
174
+ describe '#perform' do
175
+ it 'should invoke the rsync command to transfer the files and directories' do
176
+ Backup::Logger.expects(:message).with("Backup::Syncer::RSync started syncing '/some/random/directory' '/another/random/directory'.")
177
+ rsync.expects(:utility).with(:rsync).returns(:rsync)
178
+ rsync.expects(:remove_password_file!)
179
+ rsync.expects(:run).with("rsync -vhP --archive --delete --compress --port='22' --password-file='#{rsync.instance_variable_get('@password_file').path}' " +
180
+ "'/some/random/directory' '/another/random/directory' 'my_username@123.45.678.90:backups/'")
181
+ rsync.perform!
182
+ end
183
+
184
+ it 'should not pass in the --password-file option' do
185
+ Backup::Logger.expects(:message).with("Backup::Syncer::RSync started syncing '/some/random/directory' '/another/random/directory'.")
186
+ rsync.password = nil
187
+ rsync.expects(:utility).with(:rsync).returns(:rsync)
188
+ rsync.expects(:remove_password_file!)
189
+ rsync.expects(:run).with("rsync -vhP --archive --delete --compress --port='22' " +
190
+ "'/some/random/directory' '/another/random/directory' 'my_username@123.45.678.90:backups/'")
191
+ rsync.perform!
192
+ end
193
+ end
194
+
195
+ end