pvcglue 0.1.17 → 0.1.18
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 +4 -4
- data/README.md +1 -1
- data/lib/pvcglue.rb +10 -0
- data/lib/pvcglue/db.rb +28 -12
- data/lib/pvcglue/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9582fa0791b38da8006bf4672032b35d97bfa11b
|
4
|
+
data.tar.gz: 3facc6e4e1c64d0baec87d6cc24503958a67f812
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc1af302e92fc29daa6bde7a2ac3ab30ee1becf137c055f1b116746d90036303e9c0050124eef04a42bede3fde155f9ab59ae26251696be8e071b45e2bd28ea8
|
7
|
+
data.tar.gz: 03fee3e424a4c4fe9ab2b5fdaf62b4431ed00b9b5ff231bf69d2763fa86c5570639806c7e2a27cbe5bea78e3dd412091881b283b6c378f8b0ea26b773d04c7bc
|
data/README.md
CHANGED
@@ -158,7 +158,7 @@ Add these lines to your application's Gemfile. `dotenv-rails` must be listed fi
|
|
158
158
|
|
159
159
|
Then add these lines to your application's Gemfile, whereever you like (usually at the end):
|
160
160
|
|
161
|
-
gem 'pvcglue', "~> 0.1.
|
161
|
+
gem 'pvcglue', "~> 0.1.18", :group => :development
|
162
162
|
gem 'pvcglue_dbutils', "~> 0.5.3"
|
163
163
|
|
164
164
|
And then execute:
|
data/lib/pvcglue.rb
CHANGED
@@ -35,6 +35,16 @@ module Pvcglue
|
|
35
35
|
data
|
36
36
|
end
|
37
37
|
|
38
|
+
def self.run_remote(host, port, user, cmd)
|
39
|
+
cmd = "ssh -p #{port} #{user}@#{host} '#{cmd}'"
|
40
|
+
# puts "Running `#{cmd}`"
|
41
|
+
|
42
|
+
unless system cmd
|
43
|
+
raise(Thor::Error, "Error: #{$?}")
|
44
|
+
end
|
45
|
+
true
|
46
|
+
end
|
47
|
+
|
38
48
|
class Version
|
39
49
|
def self.version
|
40
50
|
VERSION
|
data/lib/pvcglue/db.rb
CHANGED
@@ -15,7 +15,7 @@ module Pvcglue
|
|
15
15
|
pg_restore(self.class.remote, file_name)
|
16
16
|
end
|
17
17
|
|
18
|
-
desc "pull", "Pull copy of database from remote stage. Pass -f to exclude tables defined in the
|
18
|
+
desc "pull", "Pull copy of database from remote stage. Pass -f to exclude tables defined in the configuration file. If no tables are specified in the `excluded_db_tables` option, 'versions' will be used by default."
|
19
19
|
method_option :fast, :type => :boolean, :aliases => "-f"
|
20
20
|
def pull(file_name = nil)
|
21
21
|
raise(Thor::Error, "Stage required.") if Pvcglue.cloud.stage_name.nil?
|
@@ -25,14 +25,14 @@ module Pvcglue
|
|
25
25
|
desc "dump", "dump"
|
26
26
|
|
27
27
|
def dump(file_name = nil)
|
28
|
-
raise(Thor::Error, "Stage should not be set for this command.") unless Pvcglue.cloud.stage_name.nil?
|
28
|
+
raise(Thor::Error, "Stage should not be set for this command. (Use 'pull' for remote databases.)") unless Pvcglue.cloud.stage_name.nil?
|
29
29
|
pg_dump(self.class.local, file_name)
|
30
30
|
end
|
31
31
|
|
32
32
|
desc "restore", "restore"
|
33
33
|
|
34
34
|
def restore(file_name = nil)
|
35
|
-
raise(Thor::Error, "Stage should not be set for this command.") unless Pvcglue.cloud.stage_name.nil?
|
35
|
+
raise(Thor::Error, "Stage should not be set for this command. (Use 'push' for remote databases.)") unless Pvcglue.cloud.stage_name.nil?
|
36
36
|
pg_restore(self.class.local, file_name)
|
37
37
|
end
|
38
38
|
|
@@ -101,7 +101,7 @@ module Pvcglue
|
|
101
101
|
def self.file_helper(file_name)
|
102
102
|
# TODO: make it more helpful ;)
|
103
103
|
stage = Pvcglue.cloud.stage_name || "dev"
|
104
|
-
file_name = "#{Pvcglue.configuration.application_name}_#{stage}_#{Time.now.strftime("%Y-%m-%d")}.dump" unless file_name
|
104
|
+
file_name = "#{Pvcglue.configuration.application_name}_#{stage}_#{Time.now.strftime("%Y-%m-%d-%H%M")}.dump" unless file_name
|
105
105
|
# "#{File.dirname(file_name)}/#{File.basename(file_name, '.*')}.dump"
|
106
106
|
file_name
|
107
107
|
end
|
@@ -118,26 +118,42 @@ module Pvcglue
|
|
118
118
|
|
119
119
|
def destroy_prod?
|
120
120
|
say("Are you *REALLY* sure you want to DESTROY the PRODUCTION database?")
|
121
|
-
input = ask("Type 'destroy
|
122
|
-
raise(Thor::Error, "Ain't gonna do it.") if input.downcase != "destroy
|
123
|
-
puts "ok, going through with the it..."
|
121
|
+
input = ask("Type 'destroy #{source.database}' if you are:")
|
122
|
+
raise(Thor::Error, "Ain't gonna do it.") if input.downcase != "destroy #{source.database}"
|
123
|
+
puts "ok, going through with the it... (I sure hope you know what you are doing, Keith!)"
|
124
124
|
end
|
125
125
|
|
126
126
|
|
127
|
-
def pg_dump(
|
128
|
-
|
129
|
-
|
127
|
+
def pg_dump(db, file_name, fast)
|
128
|
+
host = Pvcglue.cloud.nodes_in_stage('db')['db']['public_ip']
|
129
|
+
port = Pvcglue.cloud.port_in_context(:shell)
|
130
|
+
user = 'deploy'
|
131
|
+
file_name = self.class.file_helper(file_name)
|
132
|
+
|
133
|
+
cmd = "pg_dump -Fc --no-acl --no-owner -h #{db.host} -p #{db.port}"
|
134
|
+
cmd += " -U #{db.username}" if db.username
|
130
135
|
if fast
|
131
136
|
Pvcglue.cloud.exclude_tables.each do |table|
|
132
137
|
cmd += " --exclude-table=#{table}"
|
133
138
|
end
|
134
139
|
end
|
135
|
-
cmd += " #{
|
140
|
+
cmd += " #{db.database} -v -f #{file_name}"
|
141
|
+
|
136
142
|
puts cmd
|
137
|
-
unless
|
143
|
+
unless Pvcglue.run_remote(host, port, user, " PGPASSWORD=#{db.password} #{cmd}")
|
138
144
|
puts "ERROR:"
|
139
145
|
puts $?.inspect
|
146
|
+
raise(Thor::Error, "Error: #{$?}")
|
140
147
|
end
|
148
|
+
|
149
|
+
cmd = %{scp -P #{port} #{user}@#{host}:#{file_name} #{self.class.file_helper(file_name)}}
|
150
|
+
puts "Running `#{cmd}`"
|
151
|
+
|
152
|
+
unless system cmd
|
153
|
+
raise(Thor::Error, "Error: #{$?}")
|
154
|
+
end
|
155
|
+
|
156
|
+
|
141
157
|
end
|
142
158
|
|
143
159
|
def pg_destroy(dest)
|
data/lib/pvcglue/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pvcglue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Lyric
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|