backup 3.0.2 → 3.0.3.build.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. data/bin/backup +12 -190
  2. metadata +7 -191
  3. data/.gitignore +0 -2
  4. data/.infinity_test +0 -7
  5. data/.rspec +0 -3
  6. data/Gemfile +0 -17
  7. data/Gemfile.lock +0 -88
  8. data/LICENSE.md +0 -24
  9. data/README.md +0 -236
  10. data/backup.gemspec +0 -41
  11. data/lib/backup.rb +0 -148
  12. data/lib/backup/archive.rb +0 -54
  13. data/lib/backup/cli.rb +0 -50
  14. data/lib/backup/compressor/base.rb +0 -17
  15. data/lib/backup/compressor/gzip.rb +0 -61
  16. data/lib/backup/configuration/base.rb +0 -15
  17. data/lib/backup/configuration/compressor/base.rb +0 -10
  18. data/lib/backup/configuration/compressor/gzip.rb +0 -23
  19. data/lib/backup/configuration/database/base.rb +0 -18
  20. data/lib/backup/configuration/database/mongodb.rb +0 -37
  21. data/lib/backup/configuration/database/mysql.rb +0 -37
  22. data/lib/backup/configuration/database/postgresql.rb +0 -37
  23. data/lib/backup/configuration/database/redis.rb +0 -35
  24. data/lib/backup/configuration/encryptor/base.rb +0 -10
  25. data/lib/backup/configuration/encryptor/gpg.rb +0 -17
  26. data/lib/backup/configuration/encryptor/open_ssl.rb +0 -26
  27. data/lib/backup/configuration/helpers.rb +0 -54
  28. data/lib/backup/configuration/notifier/base.rb +0 -39
  29. data/lib/backup/configuration/notifier/mail.rb +0 -52
  30. data/lib/backup/configuration/storage/base.rb +0 -18
  31. data/lib/backup/configuration/storage/cloudfiles.rb +0 -21
  32. data/lib/backup/configuration/storage/dropbox.rb +0 -25
  33. data/lib/backup/configuration/storage/ftp.rb +0 -25
  34. data/lib/backup/configuration/storage/rsync.rb +0 -25
  35. data/lib/backup/configuration/storage/s3.rb +0 -25
  36. data/lib/backup/configuration/storage/scp.rb +0 -25
  37. data/lib/backup/configuration/storage/sftp.rb +0 -25
  38. data/lib/backup/database/base.rb +0 -33
  39. data/lib/backup/database/mongodb.rb +0 -137
  40. data/lib/backup/database/mysql.rb +0 -104
  41. data/lib/backup/database/postgresql.rb +0 -111
  42. data/lib/backup/database/redis.rb +0 -105
  43. data/lib/backup/encryptor/base.rb +0 -17
  44. data/lib/backup/encryptor/gpg.rb +0 -78
  45. data/lib/backup/encryptor/open_ssl.rb +0 -67
  46. data/lib/backup/finder.rb +0 -39
  47. data/lib/backup/logger.rb +0 -80
  48. data/lib/backup/model.rb +0 -249
  49. data/lib/backup/notifier/base.rb +0 -29
  50. data/lib/backup/notifier/binder.rb +0 -32
  51. data/lib/backup/notifier/mail.rb +0 -141
  52. data/lib/backup/notifier/templates/notify_failure.erb +0 -31
  53. data/lib/backup/notifier/templates/notify_success.erb +0 -16
  54. data/lib/backup/storage/base.rb +0 -67
  55. data/lib/backup/storage/cloudfiles.rb +0 -95
  56. data/lib/backup/storage/dropbox.rb +0 -82
  57. data/lib/backup/storage/ftp.rb +0 -114
  58. data/lib/backup/storage/object.rb +0 -45
  59. data/lib/backup/storage/rsync.rb +0 -100
  60. data/lib/backup/storage/s3.rb +0 -108
  61. data/lib/backup/storage/scp.rb +0 -105
  62. data/lib/backup/storage/sftp.rb +0 -106
  63. data/lib/backup/version.rb +0 -72
  64. data/lib/templates/archive +0 -4
  65. data/lib/templates/compressor/gzip +0 -4
  66. data/lib/templates/database/mongodb +0 -10
  67. data/lib/templates/database/mysql +0 -11
  68. data/lib/templates/database/postgresql +0 -11
  69. data/lib/templates/database/redis +0 -10
  70. data/lib/templates/encryptor/gpg +0 -9
  71. data/lib/templates/encryptor/openssl +0 -5
  72. data/lib/templates/notifier/mail +0 -14
  73. data/lib/templates/readme +0 -15
  74. data/lib/templates/storage/cloudfiles +0 -7
  75. data/lib/templates/storage/dropbox +0 -8
  76. data/lib/templates/storage/ftp +0 -8
  77. data/lib/templates/storage/rsync +0 -7
  78. data/lib/templates/storage/s3 +0 -8
  79. data/lib/templates/storage/scp +0 -8
  80. data/lib/templates/storage/sftp +0 -8
  81. data/spec/archive_spec.rb +0 -53
  82. data/spec/backup_spec.rb +0 -11
  83. data/spec/compressor/gzip_spec.rb +0 -59
  84. data/spec/configuration/base_spec.rb +0 -35
  85. data/spec/configuration/compressor/gzip_spec.rb +0 -28
  86. data/spec/configuration/database/base_spec.rb +0 -16
  87. data/spec/configuration/database/mongodb_spec.rb +0 -30
  88. data/spec/configuration/database/mysql_spec.rb +0 -32
  89. data/spec/configuration/database/postgresql_spec.rb +0 -32
  90. data/spec/configuration/database/redis_spec.rb +0 -30
  91. data/spec/configuration/encryptor/gpg_spec.rb +0 -25
  92. data/spec/configuration/encryptor/open_ssl_spec.rb +0 -31
  93. data/spec/configuration/notifier/mail_spec.rb +0 -32
  94. data/spec/configuration/storage/cloudfiles_spec.rb +0 -34
  95. data/spec/configuration/storage/dropbox_spec.rb +0 -40
  96. data/spec/configuration/storage/ftp_spec.rb +0 -40
  97. data/spec/configuration/storage/rsync_spec.rb +0 -37
  98. data/spec/configuration/storage/s3_spec.rb +0 -37
  99. data/spec/configuration/storage/scp_spec.rb +0 -40
  100. data/spec/configuration/storage/sftp_spec.rb +0 -40
  101. data/spec/database/base_spec.rb +0 -30
  102. data/spec/database/mongodb_spec.rb +0 -144
  103. data/spec/database/mysql_spec.rb +0 -150
  104. data/spec/database/postgresql_spec.rb +0 -164
  105. data/spec/database/redis_spec.rb +0 -122
  106. data/spec/encryptor/gpg_spec.rb +0 -57
  107. data/spec/encryptor/open_ssl_spec.rb +0 -102
  108. data/spec/logger_spec.rb +0 -37
  109. data/spec/model_spec.rb +0 -236
  110. data/spec/notifier/mail_spec.rb +0 -97
  111. data/spec/spec_helper.rb +0 -21
  112. data/spec/storage/base_spec.rb +0 -33
  113. data/spec/storage/cloudfiles_spec.rb +0 -102
  114. data/spec/storage/dropbox_spec.rb +0 -89
  115. data/spec/storage/ftp_spec.rb +0 -133
  116. data/spec/storage/object_spec.rb +0 -74
  117. data/spec/storage/rsync_spec.rb +0 -115
  118. data/spec/storage/s3_spec.rb +0 -110
  119. data/spec/storage/scp_spec.rb +0 -129
  120. data/spec/storage/sftp_spec.rb +0 -125
  121. data/spec/version_spec.rb +0 -32
@@ -1,144 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.dirname(__FILE__) + '/../spec_helper'
4
-
5
- describe Backup::Database::MongoDB do
6
-
7
- before do
8
- Backup::Database::MongoDB.any_instance.stubs(:load_defaults!)
9
- end
10
-
11
- let(:db) do
12
- Backup::Database::MongoDB.new do |db|
13
- db.name = 'mydatabase'
14
- db.username = 'someuser'
15
- db.password = 'secret'
16
- db.host = 'localhost'
17
- db.port = 123
18
-
19
- db.ipv6 = true
20
- db.only_collections = ['users', 'pirates']
21
- db.additional_options = ['--query']
22
- end
23
- end
24
-
25
- describe '#new' do
26
- it 'should read the adapter details correctly' do
27
- db.name.should == 'mydatabase'
28
- db.username.should == 'someuser'
29
- db.password.should == 'secret'
30
- db.host.should == 'localhost'
31
- db.port.should == 123
32
-
33
- db.only_collections.should == ['users', 'pirates']
34
- db.additional_options.should == '--query'
35
- end
36
-
37
- it 'arrays should default to empty arrays when not specified' do
38
- db = Backup::Database::MongoDB.new do |db|
39
- db.name = 'mydatabase'
40
- db.username = 'someuser'
41
- db.password = 'secret'
42
- end
43
-
44
- db.only_collections.should == []
45
- db.additional_options.should == ""
46
- end
47
-
48
- it 'should ensure the directory is available' do
49
- Backup::Database::MongoDB.any_instance.expects(:mkdir).with("#{Backup::TMP_PATH}/myapp/MongoDB")
50
- Backup::Database::MongoDB.new {}
51
- end
52
- end
53
-
54
- describe '#only_collections' do
55
- it 'should return a string for the mongodump selected table to dump option' do
56
- db.collections_to_dump.should == %w[users pirates]
57
- end
58
- end
59
-
60
- describe '#credential_options' do
61
- it 'should return the mongo syntax for the credential options' do
62
- db.credential_options.should == "--username='someuser' --password='secret'"
63
- end
64
-
65
- it 'should only return the mongo syntax for the user' do
66
- db = Backup::Database::MongoDB.new do |db|
67
- db.username = 'someuser'
68
- end
69
-
70
- db.credential_options.should == "--username='someuser'"
71
- end
72
- end
73
-
74
- describe '#connectivity_options' do
75
- it 'should return the mongo syntax for the connectivity options' do
76
- db.connectivity_options.should == "--host='localhost' --port='123'"
77
- end
78
-
79
- it 'should return only the socket' do
80
- db = Backup::Database::MongoDB.new do |db|
81
- db.host = ''
82
- db.port = 123
83
- end
84
-
85
- db.connectivity_options.should == "--port='123'"
86
- end
87
- end
88
-
89
- describe '#ipv6' do
90
- it 'should return a mongodb syntax compatible ipv6 flag' do
91
- db.ipv6 = true
92
- db.ipv6.should == '--ipv6'
93
- end
94
-
95
- it 'should return an empty string' do
96
- db.ipv6 = nil
97
- db.ipv6.should == ''
98
- end
99
- end
100
-
101
- describe '#mongodump_string' do
102
- it 'should return the full mongodump string' do
103
- db.expects(:utility).with(:mongodump).returns('mongodump')
104
- db.mongodump.should ==
105
- "mongodump --db='mydatabase' --username='someuser' --password='secret' " +
106
- "--host='localhost' --port='123' --ipv6 --query --out='#{ File.join(Backup::TMP_PATH, Backup::TRIGGER, 'MongoDB') }'"
107
- end
108
- end
109
-
110
- describe '#perform!' do
111
- before do
112
- Backup::Logger.stubs(:message)
113
- db.stubs(:utility).returns('mongodump')
114
- db.stubs(:mkdir)
115
- db.stubs(:run)
116
- end
117
-
118
- it 'should run the mongodump command and dump all collections' do
119
- db.only_collections = []
120
- db.expects(:dump!)
121
-
122
- db.perform!
123
- end
124
-
125
- it 'should run the mongodump command and dump all collections' do
126
- db.only_collections = nil
127
- db.expects(:dump!)
128
-
129
- db.perform!
130
- end
131
-
132
- it 'should dump only the provided collections' do
133
- db.only_collections = %w[users admins profiles]
134
- db.expects(:specific_collection_dump!)
135
-
136
- db.perform!
137
- end
138
-
139
- it do
140
- Backup::Logger.expects(:message).with("Backup::Database::MongoDB started dumping and archiving \"mydatabase\".")
141
- db.perform!
142
- end
143
- end
144
- end
@@ -1,150 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.dirname(__FILE__) + '/../spec_helper'
4
-
5
- describe Backup::Database::MySQL do
6
-
7
- before do
8
- Backup::Database::MySQL.any_instance.stubs(:load_defaults!)
9
- end
10
-
11
- let(:db) do
12
- Backup::Database::MySQL.new do |db|
13
- db.name = 'mydatabase'
14
- db.username = 'someuser'
15
- db.password = 'secret'
16
- db.host = 'localhost'
17
- db.port = '123'
18
- db.socket = '/mysql.sock'
19
-
20
- db.skip_tables = ['logs', 'profiles']
21
- db.only_tables = ['users', 'pirates']
22
- db.additional_options = ['--single-transaction', '--quick']
23
- end
24
- end
25
-
26
- describe '#new' do
27
- it 'should read the adapter details correctly' do
28
- db.name.should == 'mydatabase'
29
- db.username.should == 'someuser'
30
- db.password.should == 'secret'
31
- db.host.should == 'localhost'
32
- db.port.should == '123'
33
- db.socket.should == '/mysql.sock'
34
-
35
- db.skip_tables.should == ['logs', 'profiles']
36
- db.only_tables.should == ['users', 'pirates']
37
- db.additional_options.should == ['--single-transaction', '--quick']
38
- end
39
-
40
- it 'arrays should default to empty arrays when not specified' do
41
- db = Backup::Database::MySQL.new do |db|
42
- db.name = 'mydatabase'
43
- db.username = 'someuser'
44
- db.password = 'secret'
45
- end
46
-
47
- db.skip_tables.should == []
48
- db.only_tables.should == []
49
- db.additional_options.should == []
50
- end
51
-
52
- it 'should ensure the directory is available' do
53
- Backup::Database::MySQL.any_instance.expects(:mkdir).with("#{Backup::TMP_PATH}/myapp/MySQL")
54
- Backup::Database::MySQL.new {}
55
- end
56
- end
57
-
58
- describe '#skip_tables' do
59
- it 'should return a string for the mysqldump --ignore-tables option' do
60
- db.tables_to_skip.should == "--ignore-table='mydatabase.logs'\s--ignore-table='mydatabase.profiles'"
61
- end
62
-
63
- it 'should return an empty string' do
64
- db = Backup::Database::MySQL.new {}
65
- db.tables_to_skip.should == ""
66
- end
67
- end
68
-
69
- describe '#only_tables' do
70
- it 'should return a string for the mysqldump selected table to dump option' do
71
- db.tables_to_dump.should == "users\spirates"
72
- end
73
-
74
- it 'should return an empty string' do
75
- db = Backup::Database::MySQL.new {}
76
- db.tables_to_dump.should == ""
77
- end
78
- end
79
-
80
- describe '#credential_options' do
81
- it 'should return the mysql syntax for the credential options' do
82
- db.credential_options.should == "--user='someuser' --password='secret'"
83
- end
84
-
85
- it 'should only return the mysql syntax for the user' do
86
- db = Backup::Database::MySQL.new do |db|
87
- db.username = 'someuser'
88
- end
89
-
90
- db.credential_options.should == "--user='someuser'"
91
- end
92
- end
93
-
94
- describe '#connectivity_options' do
95
- it 'should return the mysql syntax for the connectivity options' do
96
- db.connectivity_options.should == "--host='localhost' --port='123' --socket='/mysql.sock'"
97
- end
98
-
99
- it 'should return only the socket' do
100
- db = Backup::Database::MySQL.new do |db|
101
- db.host = ''
102
- db.port = nil
103
- db.socket = '/mysql.sock'
104
- end
105
-
106
- db.connectivity_options.should == "--socket='/mysql.sock'"
107
- end
108
- end
109
-
110
- describe '#additional_options' do
111
- it 'should return a string of additional options specified by the user' do
112
- db.options.should == '--single-transaction --quick'
113
- end
114
-
115
- it 'should return an empty string' do
116
- db = Backup::Database::MySQL.new {}
117
- db.options.should == ""
118
- end
119
- end
120
-
121
- describe '#mysqldump_string' do
122
- it 'should return the full mysqldump string' do
123
- db.expects(:utility).with(:mysqldump).returns('mysqldump')
124
- db.mysqldump.should ==
125
- "mysqldump --user='someuser' --password='secret' " +
126
- "--host='localhost' --port='123' --socket='/mysql.sock' " +
127
- "--single-transaction --quick mydatabase users pirates " +
128
- "--ignore-table='mydatabase.logs' --ignore-table='mydatabase.profiles'"
129
- end
130
- end
131
-
132
- describe '#perform!' do
133
- before do
134
- Backup::Logger.stubs(:message)
135
- db.stubs(:utility).returns('mysqldump')
136
- db.stubs(:mkdir)
137
- db.stubs(:run)
138
- end
139
-
140
- it 'should run the mysqldump command and dump it to the specified path' do
141
- db.expects(:run).with("#{db.mysqldump} > '#{Backup::TMP_PATH}/myapp/MySQL/mydatabase.sql'")
142
- db.perform!
143
- end
144
-
145
- it do
146
- Backup::Logger.expects(:message).with("Backup::Database::MySQL started dumping and archiving \"mydatabase\".")
147
- db.perform!
148
- end
149
- end
150
- end
@@ -1,164 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.dirname(__FILE__) + '/../spec_helper'
4
-
5
- describe Backup::Database::PostgreSQL do
6
-
7
- before do
8
- Backup::Database::PostgreSQL.any_instance.stubs(:load_defaults!)
9
- end
10
-
11
- let(:db) do
12
- Backup::Database::PostgreSQL.new do |db|
13
- db.name = 'mydatabase'
14
- db.username = 'someuser'
15
- db.password = 'secret'
16
- db.host = 'localhost'
17
- db.port = '123'
18
- db.socket = '/pg.sock'
19
-
20
- db.skip_tables = ['logs', 'profiles']
21
- db.only_tables = ['users', 'pirates']
22
- db.additional_options = ['--single-transaction', '--quick']
23
- end
24
- end
25
-
26
- describe '#new' do
27
- it 'should read the adapter details correctly' do
28
- db.name.should == 'mydatabase'
29
- db.username.should == 'someuser'
30
- db.password.should == 'secret'
31
- db.host.should == 'localhost'
32
- db.port.should == '123'
33
- db.socket.should == '/pg.sock'
34
-
35
- db.skip_tables.should == ['logs', 'profiles']
36
- db.only_tables.should == ['users', 'pirates']
37
- db.additional_options.should == ['--single-transaction', '--quick']
38
- end
39
-
40
- it 'arrays should default to empty arrays when not specified' do
41
- db = Backup::Database::PostgreSQL.new do |db|
42
- db.name = 'mydatabase'
43
- db.username = 'someuser'
44
- db.password = 'secret'
45
- end
46
-
47
- db.skip_tables.should == []
48
- db.only_tables.should == []
49
- db.additional_options.should == []
50
- end
51
-
52
- it do
53
- db = Backup::Database::PostgreSQL.new {}
54
- db.username = ''
55
-
56
- db.credential_options.should == ''
57
- end
58
-
59
- it do
60
- db = Backup::Database::PostgreSQL.new {}
61
- db.username = nil
62
-
63
- db.credential_options.should == ''
64
- end
65
-
66
- it 'should ensure the directory is available' do
67
- Backup::Database::PostgreSQL.any_instance.expects(:mkdir).with("#{Backup::TMP_PATH}/myapp/PostgreSQL")
68
- Backup::Database::PostgreSQL.new {}
69
- end
70
- end
71
-
72
- describe '#skip_tables' do
73
- it 'should return a string for the pg_dump --ignore-tables option' do
74
- db.tables_to_skip.should == "--exclude-table='logs' --exclude-table='profiles'"
75
- end
76
-
77
- it 'should return an empty string' do
78
- db = Backup::Database::PostgreSQL.new {}
79
- db.tables_to_skip.should == ""
80
- end
81
- end
82
-
83
- describe '#only_tables' do
84
- it 'should return a string for the pg_dump selected table to dump option' do
85
- db.tables_to_dump.should == "--table='users' --table='pirates'"
86
- end
87
-
88
- it 'should return an empty string' do
89
- db = Backup::Database::PostgreSQL.new {}
90
- db.tables_to_dump.should == ""
91
- end
92
- end
93
-
94
- describe '#credential_options' do
95
- it 'should return the postgresql syntax for the credential options' do
96
- db.credential_options.should == "--username='someuser'"
97
- end
98
-
99
- it 'should only return the postgresql syntax for the user' do
100
- db = Backup::Database::PostgreSQL.new do |db|
101
- db.username = 'someuser'
102
- end
103
-
104
- db.credential_options.should == "--username='someuser'"
105
- end
106
- end
107
-
108
- describe '#connectivity_options' do
109
- it 'should return the postgresql syntax for the connectivity options' do
110
- db.connectivity_options.should == "--host='localhost' --port='123' --host='/pg.sock'"
111
- end
112
-
113
- it 'should return only the socket' do
114
- db = Backup::Database::PostgreSQL.new do |db|
115
- db.host = ''
116
- db.port = nil
117
- db.socket = '/pg.sock'
118
- end
119
-
120
- db.connectivity_options.should == "--host='/pg.sock'"
121
- end
122
- end
123
-
124
- describe '#additional_options' do
125
- it 'should return a string of additional options specified by the user' do
126
- db.options.should == '--single-transaction --quick'
127
- end
128
-
129
- it 'should return an empty string' do
130
- db = Backup::Database::PostgreSQL.new {}
131
- db.options.should == ""
132
- end
133
- end
134
-
135
- describe '#pg_dump_string' do
136
- it 'should return the full pg_dump string' do
137
- db.expects(:utility).with(:pg_dump).returns('pg_dump')
138
- db.pgdump.should ==
139
- "pg_dump --username='someuser' " +
140
- "--host='localhost' --port='123' --host='/pg.sock' " +
141
- "--single-transaction --quick --table='users' --table='pirates' " +
142
- "--exclude-table='logs' --exclude-table='profiles' mydatabase"
143
- end
144
- end
145
-
146
- describe '#perform!' do
147
- before do
148
- Backup::Logger.stubs(:message)
149
- db.stubs(:utility).returns('pg_dump')
150
- db.stubs(:mkdir)
151
- db.stubs(:run)
152
- end
153
-
154
- it 'should run the pg_dump command and dump it to the specified path' do
155
- db.expects(:run).with("#{db.pgdump} > '#{Backup::TMP_PATH}/myapp/PostgreSQL/mydatabase.sql'")
156
- db.perform!
157
- end
158
-
159
- it do
160
- Backup::Logger.expects(:message).with("Backup::Database::PostgreSQL started dumping and archiving \"mydatabase\".")
161
- db.perform!
162
- end
163
- end
164
- end