insxsync 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.idea/insxsync.iml +4 -4
- data/bin/insxsync +36 -19
- data/features/synchronization.feature +1220 -1220
- data/lib/insxsync.rb +3 -3
- data/lib/insxsync/version.rb +1 -1
- data/lib/sync_point_restore.rb +20 -1
- metadata +2 -2
data/lib/insxsync.rb
CHANGED
@@ -148,7 +148,7 @@ module InsxSync
|
|
148
148
|
|
149
149
|
# this assumes the role on the production account to access CGE backups
|
150
150
|
sts = AWS::STS.new(:access_key_id=>accessKeyId, :secret_access_key=>secretAccessKey)
|
151
|
-
role = sts.assume_role(:role_arn =>
|
151
|
+
role = sts.assume_role(:role_arn => $ROLE_ARN, :role_session_name => SecureRandom.uuid.gsub(/-/,''), :duration_seconds => 60 * 15)
|
152
152
|
|
153
153
|
# store role credentials
|
154
154
|
creds = role[:credentials]
|
@@ -300,13 +300,13 @@ module InsxSync
|
|
300
300
|
# Returns the truth value of whether the application is running$command an export operation
|
301
301
|
# @return [true, false] whether the application in running an export
|
302
302
|
def exporting?
|
303
|
-
$
|
303
|
+
$OLD_ARGV0 == "export"
|
304
304
|
end
|
305
305
|
|
306
306
|
# Returns the truth value of whether the application is running an sync operation
|
307
307
|
# @return [true, false] whether the application in running an sync
|
308
308
|
def syncing?
|
309
|
-
$
|
309
|
+
$OLD_ARGV0 =~ /sync(-uat)?/
|
310
310
|
end
|
311
311
|
|
312
312
|
# Acts like the *nix which command. Given an array of commands ordered from most prefered to lease, it
|
data/lib/insxsync/version.rb
CHANGED
data/lib/sync_point_restore.rb
CHANGED
@@ -192,9 +192,14 @@ class SyncPointRestore < ErrorHandlingIface
|
|
192
192
|
File.write(file, text)
|
193
193
|
end
|
194
194
|
|
195
|
+
Find.find(dest_dir) do |file|
|
196
|
+
puts "Test: #{file}"
|
197
|
+
end
|
198
|
+
|
195
199
|
Find.find(dest_dir) do |file|
|
196
200
|
next if file == "."
|
197
201
|
next if file == ".."
|
202
|
+
next if file == dest_dir
|
198
203
|
next unless File.directory?(file)
|
199
204
|
|
200
205
|
dirname = file.scan(/#{dest_dir}\/?(.*)/).flatten[0]
|
@@ -205,16 +210,18 @@ class SyncPointRestore < ErrorHandlingIface
|
|
205
210
|
end
|
206
211
|
end
|
207
212
|
|
208
|
-
def self.restore_data(sync_point_dir, time)
|
213
|
+
def self.restore_data(sync_point_dir, time, databases)
|
209
214
|
abbrvs = {'ian' => 1, 'feb' => 2, 'mar' => 3, 'apr' => 4, 'mai' => 5, 'iunie' => 6, 'iulie' => 7, 'aug' => 8, 'sept' => 9, 'oct' => 10, 'noem' => 11, 'dec' => 12}
|
210
215
|
reverse_abbrvs = abbrvs.invert
|
211
216
|
|
212
217
|
day = Time.at(time.to_i).strftime('%d')
|
213
218
|
month = reverse_abbrvs[Time.at(time.to_i).strftime('%m').to_i]
|
214
219
|
|
220
|
+
backup_dbs = []
|
215
221
|
Find.find(File.join(sync_point_dir, 'database')) do |file|
|
216
222
|
next if File.directory?(file)
|
217
223
|
old_name = File.basename(file, '.sql')
|
224
|
+
backup_dbs.push(old_name)
|
218
225
|
new_name = old_name.scan(/\A(.*?)(db)?\z/).flatten[0] + day + month
|
219
226
|
tmpfile = File.open("#{file}.tmp", 'w')
|
220
227
|
tmppath = tmpfile.path
|
@@ -227,8 +234,20 @@ class SyncPointRestore < ErrorHandlingIface
|
|
227
234
|
FileUtils.mv(tmpfile.path, file)
|
228
235
|
end
|
229
236
|
|
237
|
+
if databases.not_nil?
|
238
|
+
databases.each do |item|
|
239
|
+
require_condition backup_dbs.count(item) == 1, "\nArgument Error: Database \"#{item}\" does not exist in specified backup. No changes made. Exiting..."
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
|
230
244
|
Find.find(File.join(sync_point_dir, 'database')) do |file|
|
231
245
|
next if File.directory?(file)
|
246
|
+
|
247
|
+
if databases.not_nil?
|
248
|
+
next unless databases.count(File.basename(file, '.sql')) == 1
|
249
|
+
end
|
250
|
+
|
232
251
|
mysql = which("mysql")
|
233
252
|
raise if mysql.nil?
|
234
253
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: insxsync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-05-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|