scalingo_databases_rake_tasks 0.1.9 → 0.1.10

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3a5402b4ab31aa34e0ec54cc7c4b0524618944b
4
- data.tar.gz: bdb4484845c03b748a403bcbc22d27695a1af05d
3
+ metadata.gz: '0924ed88a76b3f23eff86859e42ada5579331c2c'
4
+ data.tar.gz: 35aad8839729081c3d7f4e340912de956da7850e
5
5
  SHA512:
6
- metadata.gz: c295edeb35ced25059bebf9a035c150ef05c52322fa4901a96b56568b1b37e30e91b66472fa56addf5e37c4e8d166f5b363a59bc98dff0b6ea80545ca340f99a
7
- data.tar.gz: 6071cc7c48a10c4544937e3f82dba681bb6cc4152adc0fb796f1ef4be35edda1ae77d822c6c840b798d07f0cef1ae89f23cdd255718a00755bbde1b951a5181a
6
+ metadata.gz: 81b514490cdeb6ecd90d25b8778b6fee3fc4a3acad1a1261539ac71a8864812c7cb17eb26f536c9de4d8b18270c18b5d54b899cff0a1c3fa842a732dcc4c4141
7
+ data.tar.gz: 0b9e25f9cf7fe5e5aa70c43afc655f086900baa4b3c4b1d08fc7063fd449aa56071f0bd06bb05dcd257d4a1581090108958f69daf10244efd2f118f3b2282800
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.10 (2017-04-25)
2
+
3
+ When extracting mongodb backup in /tmp, no permission to change utime on some system, so doing it in a sur directory
4
+
1
5
  ## 0.1.9 (2016-11-29)
2
6
 
3
7
  Compatibility with pg_restore 9.1
@@ -7,7 +7,7 @@ namespace :scalingo do
7
7
  end
8
8
 
9
9
  desc "Backup remote Scalingo MongoDB database"
10
- task :backup_remote => :environment do
10
+ task :backup_remote do
11
11
  open_tunnel("SCALINGO_MONGO_URL") do |database, user, password|
12
12
  ScalingoMongoDB.backup(database, user, password, "127.0.0.1:27717")
13
13
  end
@@ -20,7 +20,7 @@ namespace :scalingo do
20
20
  end
21
21
 
22
22
  desc "Restore remote Scalingo MongoDB database using local backup"
23
- task :restore_remote => :environment do
23
+ task :restore_remote do
24
24
  open_tunnel("SCALINGO_MONGO_URL") do |database, user, password|
25
25
  confirm_remote(database)
26
26
  ScalingoMongoDB.restore(database, user, password, "127.0.0.1:27717")
@@ -31,7 +31,6 @@ namespace :scalingo do
31
31
 
32
32
  module ScalingoMongoDB
33
33
  DUMP_NAME = "scalingo_mongodb_dump"
34
- DUMP_PATH = Dir.tmpdir() + "/#{DUMP_NAME}"
35
34
 
36
35
  def self.local_credentials(filename)
37
36
  filename ||= "mongoid"
@@ -63,7 +62,8 @@ namespace :scalingo do
63
62
  if ENV["EXCLUDE_COLLECTIONS"]
64
63
  extra_args = ENV["EXCLUDE_COLLECTIONS"].split(",").map{|c| "--excludeCollection=\"#{c}\""}.join(" ")
65
64
  end
66
- cmd = "rm -rf #{DUMP_PATH} 2>/dev/null && /usr/bin/env mongodump -h #{host} -d #{database} -o #{DUMP_PATH} #{extra_args}"
65
+ workdir = Dir.mktmpdir("scalingo-mongodb")
66
+ cmd = "/usr/bin/env mongodump -h #{host} -d #{database} -o #{workdir} #{extra_args}"
67
67
  if user.blank?
68
68
  output = cmd
69
69
  else
@@ -87,8 +87,9 @@ namespace :scalingo do
87
87
  end
88
88
 
89
89
  def self.restore database, user, password, host
90
- cmd = "rm -rf #{DUMP_PATH}/ 2>/dev/null && tar xvzf #{archive_name DUMP_NAME} -C #{Dir.tmpdir()}"
91
- cmd << " && /usr/bin/env mongorestore --drop -h #{host} -d #{database} --dir #{DUMP_PATH}/*"
90
+ workdir = Dir.mktmpdir("scalingo-mongodb")
91
+ cmd = "tar xvzf #{archive_name DUMP_NAME} -C #{workdir}"
92
+ cmd << " && /usr/bin/env mongorestore --drop -h #{host} -d #{database} --dir #{workdir}/*"
92
93
  if user.blank?
93
94
  output = cmd
94
95
  else
@@ -104,6 +105,8 @@ namespace :scalingo do
104
105
 
105
106
  puts "*** Executing #{output}"
106
107
  system(cmd)
108
+ puts "*** Cleaning #{workdir}"
109
+ FileUtils.rm_r workdir
107
110
  end
108
111
 
109
112
  def self.mongoid_configuration_key
@@ -7,7 +7,7 @@ namespace :scalingo do
7
7
  end
8
8
 
9
9
  desc "Backup remote Scalingo MySQL database"
10
- task :backup_remote => :environment do
10
+ task :backup_remote do
11
11
  open_tunnel("SCALINGO_MYSQL_URL") do |database, user, password|
12
12
  ScalingoMySQL.backup(database, user, password, "127.0.0.1", 27717)
13
13
  end
@@ -20,7 +20,7 @@ namespace :scalingo do
20
20
  end
21
21
 
22
22
  desc "Restore remote Scalingo MySQL database using local backup"
23
- task :restore_remote => :environment do
23
+ task :restore_remote do
24
24
  open_tunnel("SCALINGO_MYSQL_URL") do |database, user, password|
25
25
  confirm_remote(database)
26
26
  ScalingoMySQL.restore(database, user, password, "127.0.0.1", 27717)
@@ -7,7 +7,7 @@ namespace :scalingo do
7
7
  end
8
8
 
9
9
  desc "Backup remote Scalingo PostgreSQL database"
10
- task :backup_remote => :environment do
10
+ task :backup_remote do
11
11
  open_tunnel("SCALINGO_POSTGRESQL_URL") do |database, user, password|
12
12
  ScalingoPostgreSQL.backup(database, user, password, "127.0.0.1", "27717")
13
13
  end
@@ -20,7 +20,7 @@ namespace :scalingo do
20
20
  end
21
21
 
22
22
  desc "Restore remote Scalingo PostgreSQL database using local backup"
23
- task :restore_remote => :environment do
23
+ task :restore_remote do
24
24
  open_tunnel("SCALINGO_POSTGRESQL_URL") do |database, user, password|
25
25
  confirm_remote(database)
26
26
  ScalingoPostgreSQL.restore(database, user, password, "127.0.0.1", "27717")
@@ -117,7 +117,7 @@ namespace :scalingo do
117
117
  major, minor = version.split('.')
118
118
  major.to_i >= 9 && minor.to_i >= 4
119
119
  end
120
-
120
+
121
121
  def self.pg_restore_9_1?
122
122
  pg_restore_cmd = ENV["PG_RESTORE_CMD"] || "pg_restore"
123
123
  version = `#{pg_restore_cmd} --version`.split.last
@@ -1,3 +1,3 @@
1
1
  module ScalingoDbTasks
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scalingo_databases_rake_tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scalingo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-29 00:00:00.000000000 Z
11
+ date: 2017-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler