axtro-rubber 1.0.2.2 → 1.0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rubber/tasks/rubber.rb +6 -2
- metadata +1 -1
data/lib/rubber/tasks/rubber.rb
CHANGED
@@ -167,6 +167,7 @@ namespace :rubber do
|
|
167
167
|
This tries to find the last backup made or the s3 object identified by the
|
168
168
|
key FILENAME
|
169
169
|
The following arguments affect behavior:
|
170
|
+
BUCKET (optional): overwrite the bucket defined in rubber.yml
|
170
171
|
FILENAME (optional): key of S3 object to use
|
171
172
|
DBUSER (required) User to connect to the db as
|
172
173
|
DBPASS (optional): Pass to connect to the db with
|
@@ -174,6 +175,7 @@ namespace :rubber do
|
|
174
175
|
DBNAME (required): Database name to backup
|
175
176
|
DESC
|
176
177
|
task :restore_db_s3 do
|
178
|
+
bucket = get_env('BUCKET')
|
177
179
|
file = get_env('FILENAME')
|
178
180
|
user = get_env('DBUSER', true)
|
179
181
|
pass = get_env('DBPASS')
|
@@ -186,12 +188,12 @@ namespace :rubber do
|
|
186
188
|
db_restore_cmd = eval('%Q{' + db_restore_cmd + '}')
|
187
189
|
|
188
190
|
# try to fetch a matching file from s3 (if backup_bucket given)
|
189
|
-
backup_bucket = cloud_provider.backup_bucket
|
191
|
+
backup_bucket = bucket || cloud_provider.backup_bucket
|
190
192
|
raise "No backup_bucket defined in rubber.yml" unless backup_bucket
|
191
193
|
if (init_s3 &&
|
192
194
|
AWS::S3::Bucket.list.find { |b| b.name == backup_bucket })
|
193
195
|
s3objects = AWS::S3::Bucket.find(backup_bucket,
|
194
|
-
:prefix => 'db/')
|
196
|
+
:prefix => (file || 'db/'))
|
195
197
|
if file
|
196
198
|
puts "trying to fetch #{file} from s3"
|
197
199
|
data = s3objects.detect { |o| file == o.key }
|
@@ -209,6 +211,8 @@ namespace :rubber do
|
|
209
211
|
end
|
210
212
|
end
|
211
213
|
|
214
|
+
puts "Resetting incremental backups"
|
215
|
+
`/usr/local/ec2onrails/bin/backup_app_db --reset`
|
212
216
|
end
|
213
217
|
|
214
218
|
|