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,7 @@
1
+ ##
2
+ # Gzip [Compressor]
3
+ #
4
+ compress_with Gzip do |compression|
5
+ compression.best = true
6
+ compression.fast = false
7
+ end
@@ -0,0 +1,14 @@
1
+ ##
2
+ # MongoDB [Database]
3
+ #
4
+ database MongoDB do |db|
5
+ db.name = "my_database_name"
6
+ db.username = "my_username"
7
+ db.password = "my_password"
8
+ db.host = "localhost"
9
+ db.port = 5432
10
+ db.ipv6 = false
11
+ db.only_collections = ['only', 'these' 'collections']
12
+ db.additional_options = []
13
+ db.lock = false
14
+ end
@@ -0,0 +1,14 @@
1
+ ##
2
+ # MySQL [Database]
3
+ #
4
+ database MySQL do |db|
5
+ db.name = "my_database_name"
6
+ db.username = "my_username"
7
+ db.password = "my_password"
8
+ db.host = "localhost"
9
+ db.port = 3306
10
+ db.socket = "/tmp/mysql.sock"
11
+ db.skip_tables = ['skip', 'these', 'tables']
12
+ db.only_tables = ['only', 'these' 'tables']
13
+ db.additional_options = ['--quick', '--single-transaction']
14
+ end
@@ -0,0 +1,14 @@
1
+ ##
2
+ # PostgreSQL [Database]
3
+ #
4
+ database PostgreSQL do |db|
5
+ db.name = "my_database_name"
6
+ db.username = "my_username"
7
+ db.password = "my_password"
8
+ db.host = "localhost"
9
+ db.port = 5432
10
+ db.socket = "/tmp/pg.sock"
11
+ db.skip_tables = ['skip', 'these', 'tables']
12
+ db.only_tables = ['only', 'these' 'tables']
13
+ db.additional_options = ['-xc', '-E=utf8']
14
+ end
@@ -0,0 +1,13 @@
1
+ ##
2
+ # Redis [Database]
3
+ #
4
+ database Redis do |db|
5
+ db.name = "my_database_name"
6
+ db.path = "/usr/local/var/db/redis"
7
+ db.password = "my_password"
8
+ db.host = "localhost"
9
+ db.port = 5432
10
+ db.socket = "/tmp/redis.sock"
11
+ db.additional_options = []
12
+ db.invoke_save = true
13
+ end
@@ -0,0 +1,12 @@
1
+ ##
2
+ # GPG [Encryptor]
3
+ #
4
+ encrypt_with GPG do |encryption|
5
+ encryption.key = <<-KEY
6
+ -----BEGIN PGP PUBLIC KEY BLOCK-----
7
+ Version: GnuPG v1.4.11 (Darwin)
8
+
9
+ <Your GPG Public Key Here>
10
+ -----END PGP PUBLIC KEY BLOCK-----
11
+ KEY
12
+ end
@@ -0,0 +1,8 @@
1
+ ##
2
+ # OpenSSL [Encryptor]
3
+ #
4
+ encrypt_with OpenSSL do |encryption|
5
+ encryption.password = 'my_password'
6
+ encryption.base64 = true
7
+ encryption.salt = true
8
+ end
@@ -0,0 +1,11 @@
1
+ ##
2
+ # Campfire [Notifier]
3
+ #
4
+ notify_by Campfire do |campfire|
5
+ campfire.on_success = true
6
+ campfire.on_failure = true
7
+
8
+ campfire.api_token = 'my_api_authentication_token'
9
+ campfire.subdomain = 'my_subdomain'
10
+ campfire.room_id = 'my_room_id'
11
+ end
@@ -0,0 +1,17 @@
1
+ ##
2
+ # Mail [Notifier]
3
+ #
4
+ notify_by Mail do |mail|
5
+ mail.on_success = true
6
+ mail.on_failure = true
7
+
8
+ mail.from = 'sender@email.com'
9
+ mail.to = 'receiver@email.com'
10
+ mail.address = 'smtp.gmail.com'
11
+ mail.port = 587
12
+ mail.domain = 'your.host.name'
13
+ mail.user_name = 'sender@email.com'
14
+ mail.password = 'my_password'
15
+ mail.authentication = 'plain'
16
+ mail.enable_starttls_auto = true
17
+ end
@@ -0,0 +1,12 @@
1
+ ##
2
+ # Presently [Notifier]
3
+ #
4
+ notify_by Presently do |presently|
5
+ presently.on_success = true
6
+ presently.on_failure = true
7
+
8
+ presently.subdomain = 'my_subdomain'
9
+ presently.user_name = 'my_user_name'
10
+ presently.password = 'my_password'
11
+ presently.group_id = 'my_group_id' # optional
12
+ end
@@ -0,0 +1,12 @@
1
+ ##
2
+ # Twitter [Notifier]
3
+ #
4
+ notify_by Twitter do |tweet|
5
+ tweet.on_success = true
6
+ tweet.on_failure = true
7
+
8
+ tweet.consumer_key = 'my_consumer_key'
9
+ tweet.consumer_secret = 'my_consumer_secret'
10
+ tweet.oauth_token = 'my_oauth_token'
11
+ tweet.oauth_token_secret = 'my_oauth_token_secret'
12
+ end
@@ -0,0 +1,15 @@
1
+ ##
2
+ # Backup
3
+ # Generated Template
4
+ #
5
+ # For more information:
6
+ #
7
+ # View the Git repository at https://github.com/meskyanichi/backup
8
+ # View the Wiki/Documentation at https://github.com/meskyanichi/backup/wiki
9
+ # View the issue log at https://github.com/meskyanichi/backup/issues
10
+ #
11
+ # When you're finished configuring this configuration file,
12
+ # you can run it from the command line by issuing the following command:
13
+ #
14
+ # $ backup perform -t my_backup [-c <path_to_configuration_file>]
15
+
@@ -0,0 +1,10 @@
1
+ ##
2
+ # Rackspace Cloud Files [Storage]
3
+ #
4
+ store_with CloudFiles do |cf|
5
+ cf.api_key = 'my_api_key'
6
+ cf.username = 'my_username'
7
+ cf.container = 'my_container'
8
+ cf.path = '/path/to/my/backups'
9
+ cf.keep = 5
10
+ end
@@ -0,0 +1,12 @@
1
+ ##
2
+ # Dropbox File Hosting Service [Storage]
3
+ #
4
+ store_with Dropbox do |db|
5
+ db.email = 'my@email.com'
6
+ db.password = 'my_password'
7
+ db.api_key = 'my_api_key'
8
+ db.api_secret = 'my_api_secret'
9
+ db.timeout = 300
10
+ db.path = '/path/to/my/backups'
11
+ db.keep = 25
12
+ end
@@ -0,0 +1,11 @@
1
+ ##
2
+ # FTP (File Transfer Protocol) [Storage]
3
+ #
4
+ store_with FTP do |server|
5
+ server.username = 'my_username'
6
+ server.password = 'my_password'
7
+ server.ip = '123.45.678.90'
8
+ server.port = 21
9
+ server.path = '~/backups/'
10
+ server.keep = 5
11
+ end
@@ -0,0 +1,10 @@
1
+ ##
2
+ # RSync [Storage]
3
+ #
4
+ store_with RSync do |server|
5
+ server.username = 'my_username'
6
+ server.password = 'my_password'
7
+ server.ip = '123.45.678.90'
8
+ server.port = 22
9
+ server.path = '~/backups/'
10
+ end
@@ -0,0 +1,21 @@
1
+ ##
2
+ # Amazon Simple Storage Service [Storage]
3
+ #
4
+ # Available Regions:
5
+ #
6
+ # - ap-northeast-1
7
+ # - ap-southeast-1
8
+ # - eu-west-1
9
+ # - us-east-1
10
+ # - us-west-1
11
+ #
12
+ store_with S3 do |s3|
13
+ s3.access_key_id = 'my_access_key_id'
14
+ s3.secret_access_key = 'my_secret_access_key'
15
+ s3.region = 'us-east-1'
16
+ s3.bucket = 'bucket-name'
17
+ s3.path = '/path/to/my/backups'
18
+ s3.keep = 10
19
+ end
20
+
21
+
@@ -0,0 +1,11 @@
1
+ ##
2
+ # SCP (Secure Copy) [Storage]
3
+ #
4
+ store_with SCP do |server|
5
+ server.username = 'my_username'
6
+ server.password = 'my_password'
7
+ server.ip = '123.45.678.90'
8
+ server.port = 22
9
+ server.path = '~/backups/'
10
+ server.keep = 5
11
+ end
@@ -0,0 +1,11 @@
1
+ ##
2
+ # SFTP (Secure File Transfer Protocol) [Storage]
3
+ #
4
+ store_with SFTP do |server|
5
+ server.username = 'my_username'
6
+ server.password = 'my_password'
7
+ server.ip = '123.45.678.90'
8
+ server.port = 22
9
+ server.path = '~/backups/'
10
+ server.keep = 5
11
+ end
@@ -0,0 +1,17 @@
1
+ ##
2
+ # RSync [Syncer]
3
+ #
4
+ sync_with RSync do |rsync|
5
+ rsync.ip = "123.45.678.90"
6
+ rsync.port = 22
7
+ rsync.username = "my_username"
8
+ rsync.password = "my_password"
9
+ rsync.path = "~/backups/"
10
+ rsync.mirror = true
11
+ rsync.compress = true
12
+
13
+ rsync.directories do |directory|
14
+ directory.add "/var/apps/my_app/public/uploads"
15
+ directory.add "/var/apps/my_app/logs"
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ ##
2
+ # Amazon Simple Storage Service [Syncer]
3
+ #
4
+ sync_with S3 do |s3|
5
+ s3.access_key_id = "my_access_key_id"
6
+ s3.secret_access_key = "my_secret_access_key"
7
+ s3.bucket = "my-bucket"
8
+ s3.path = "/backups"
9
+ s3.mirror = true
10
+
11
+ s3.directories do |directory|
12
+ directory.add "/path/to/directory/to/sync"
13
+ directory.add "/path/to/other/directory/to/sync"
14
+ end
15
+ end
@@ -0,0 +1,90 @@
1
+ # encoding: utf-8
2
+
3
+ require File.dirname(__FILE__) + '/spec_helper'
4
+
5
+ describe Backup::Archive do
6
+
7
+ let(:archive) do
8
+ Backup::Archive.new(:dummy_archive) do |a|
9
+ a.add '/home/rspecuser/somefile'
10
+ a.add '/home/rspecuser/logs/'
11
+ a.add '/home/rspecuser/dotfiles/'
12
+ a.exclude '/home/rspecuser/badfile'
13
+ a.exclude '/home/rspecuser/wrongdir/'
14
+ end
15
+ end
16
+
17
+ it 'should have no paths' do
18
+ archive = Backup::Archive.new(:dummy_archive) { |a| }
19
+ archive.paths.count.should == 0
20
+ end
21
+
22
+ it 'should have no excludes' do
23
+ archive = Backup::Archive.new(:dummy_archive) { |a| }
24
+ archive.excludes.count.should == 0
25
+ end
26
+
27
+ it 'should have 3 paths' do
28
+ archive.paths.count.should == 3
29
+ end
30
+
31
+ it 'should have 2 excludes' do
32
+ archive.excludes.count.should == 2
33
+ end
34
+
35
+ it do
36
+ archive.name.should == :dummy_archive
37
+ end
38
+
39
+ describe '#paths_to_package' do
40
+ it 'should return a tar -c friendly string' do
41
+ archive.send(:paths_to_package).should ==
42
+ "'/home/rspecuser/somefile' '/home/rspecuser/logs/' '/home/rspecuser/dotfiles/'"
43
+ end
44
+ end
45
+
46
+ describe '#paths_to_exclude' do
47
+ it 'should be empty' do
48
+ archive = Backup::Archive.new(:dummy_archive) { |a| }
49
+ archive.send(:paths_to_exclude).should be_nil
50
+ end
51
+
52
+ it 'should return a tar -c friendly string' do
53
+ archive.send(:paths_to_exclude).should ==
54
+ "--exclude='/home/rspecuser/badfile' --exclude='/home/rspecuser/wrongdir/'"
55
+ end
56
+ end
57
+
58
+ describe '#perform!' do
59
+ before do
60
+ [:mkdir, :run, :utility].each { |method| archive.stubs(method) }
61
+ Backup::Logger.stubs(:message)
62
+ end
63
+
64
+ context 'when both paths were added and paths that should be excluded were added' do
65
+ it 'should render both the syntax for the paths that be included as well as excluded' do
66
+ archive.expects(:mkdir).with(File.join(Backup::TMP_PATH, Backup::TRIGGER, 'archive'))
67
+ archive.expects(:run).with("tar -c -f '#{File.join(Backup::TMP_PATH, Backup::TRIGGER, 'archive', "#{:dummy_archive}.tar")}' --exclude='/home/rspecuser/badfile' --exclude='/home/rspecuser/wrongdir/' '/home/rspecuser/somefile' '/home/rspecuser/logs/' '/home/rspecuser/dotfiles/' 2> /dev/null")
68
+ archive.expects(:utility).with(:tar).returns(:tar)
69
+ archive.perform!
70
+ end
71
+ end
72
+
73
+ context 'when there are paths to add, and no exclude patterns were defined' do
74
+ it 'should only render syntax for the defined paths' do
75
+ archive = Backup::Archive.new(:dummy_archive) do |a|
76
+ a.add '/path/to/archive'
77
+ end
78
+
79
+ archive.stubs(:utility).returns(:tar)
80
+ archive.expects(:run).with("tar -c -f '#{File.join(Backup::TMP_PATH, Backup::TRIGGER, 'archive', "#{:dummy_archive}.tar")}' '/path/to/archive' 2> /dev/null")
81
+ archive.perform!
82
+ end
83
+ end
84
+
85
+ it 'should log the status' do
86
+ Backup::Logger.expects(:message).with("Backup::Archive started packaging and archiving \"/home/rspecuser/somefile\", \"/home/rspecuser/logs/\", \"/home/rspecuser/dotfiles/\".")
87
+ archive.perform!
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ require File.dirname(__FILE__) + '/spec_helper'
4
+
5
+ describe Backup do
6
+ it do
7
+ Backup::TMP_PATH.should == File.join(ENV['HOME'], 'Backup', '.tmp')
8
+ Backup::DATA_PATH.should == File.join(ENV['HOME'], 'Backup', 'data')
9
+ Backup::CONFIG_FILE.should == File.join(ENV['HOME'], 'Backup', 'config.rb')
10
+ end
11
+ end
@@ -0,0 +1,59 @@
1
+ # encoding: utf-8
2
+
3
+ require File.dirname(__FILE__) + '/../spec_helper'
4
+
5
+ describe Backup::Compressor::Bzip2 do
6
+ let(:compressor) { Backup::Compressor::Bzip2.new }
7
+
8
+ before do
9
+ Backup::Model.extension = 'tar'
10
+ end
11
+
12
+ describe 'the options' do
13
+ it do
14
+ compressor.send(:best).should == []
15
+ end
16
+
17
+ it do
18
+ compressor.send(:fast).should == []
19
+ end
20
+ end
21
+
22
+ describe '#perform!' do
23
+ before do
24
+ [:run, :utility].each { |method| compressor.stubs(method) }
25
+ Backup::Logger.stubs(:message)
26
+ end
27
+
28
+ it 'should perform the compression' do
29
+ compressor.expects(:utility).with(:bzip2).returns(:bzip2)
30
+ compressor.expects(:run).with("bzip2 '#{ File.join(Backup::TMP_PATH, "#{ Backup::TIME }.#{ Backup::TRIGGER }.tar") }'")
31
+ compressor.perform!
32
+ end
33
+
34
+ it 'should perform the compression with the --best and --fast options' do
35
+ compressor = Backup::Compressor::Bzip2.new do |c|
36
+ c.best = true
37
+ c.fast = true
38
+ end
39
+
40
+ compressor.stubs(:utility).returns(:bzip2)
41
+ compressor.expects(:run).with("bzip2 --best --fast '#{ File.join(Backup::TMP_PATH, "#{ Backup::TIME }.#{ Backup::TRIGGER }.tar") }'")
42
+ compressor.perform!
43
+ end
44
+
45
+ it 'should set the class variable @extension (Backup::Model.extension) to .bz2' do
46
+ compressor.stubs(:utility).returns(:bzip2)
47
+ compressor.expects(:run)
48
+
49
+ Backup::Model.extension.should == 'tar'
50
+ compressor.perform!
51
+ Backup::Model.extension.should == 'tar.bz2'
52
+ end
53
+
54
+ it 'should log' do
55
+ Backup::Logger.expects(:message).with("Backup::Compressor::Bzip2 started compressing the archive.")
56
+ compressor.perform!
57
+ end
58
+ end
59
+ end