dokku-installer-cli 0.0.8 → 0.0.9
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/bin/dokku +67 -13
- data/lib/dokku_installer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25020f2b95b8dcff21290f451cf31c3bb288a424
|
4
|
+
data.tar.gz: 4d2f383fb98e9c810792f3c5e06fb890456231e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24ad507fb472e346ebaa848b6d0fcef0a875e83f3820c72ac46edc82d80c0d4583a29b47c35e9c66c42b5fec1b306447233d82829193f3ce8e2f31294b1bcfec
|
7
|
+
data.tar.gz: 91f9f6ac6ca6a70390eaadf6e242e3f5eecdb1c82bb9504a5f246084f41f209058094466651ad9ecaaa9e244c41b99dad666486b73a3c3cbce4833ada57bee2f
|
data/bin/dokku
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "shellwords"
|
4
4
|
require "thor"
|
5
|
+
require "YAML"
|
5
6
|
|
6
7
|
module DokkuInstaller
|
7
8
|
class Cli < Thor
|
@@ -78,21 +79,9 @@ module DokkuInstaller
|
|
78
79
|
|
79
80
|
desc "postgres:backups:download <number>", "Download the numbered PostgreSQL backup"
|
80
81
|
def postgres_backups_download(*args)
|
81
|
-
# Make sure the number is valid
|
82
82
|
number = args.first ? args.first : 1
|
83
|
-
number = number.to_s.gsub(/\D/, "").to_i
|
84
|
-
if number < 1
|
85
|
-
puts "Invalid backup number"
|
86
|
-
return
|
87
|
-
end
|
88
83
|
|
89
|
-
|
90
|
-
puts "Getting list of backups..."
|
91
|
-
command = "ssh -t dokku@#{domain} postgres:backups #{app_name}"
|
92
|
-
backups = `#{command}`
|
93
|
-
index = number - 1
|
94
|
-
backup = backups.split("\n").reverse[index].strip
|
95
|
-
if backup
|
84
|
+
if backup = backup_filename(number)
|
96
85
|
command = "postgres:backups:download #{app_name} #{backup} > #{backup}"
|
97
86
|
puts "Saving to local file: #{backup}"
|
98
87
|
run_command(command)
|
@@ -106,6 +95,28 @@ module DokkuInstaller
|
|
106
95
|
run_command "postgres:backups:enable #{app_name}"
|
107
96
|
end
|
108
97
|
|
98
|
+
desc "postgres:backups:restore:local <number>", "Restore the numbered PostgreSQL backup locally"
|
99
|
+
def postgres_backups_restore_local(*args)
|
100
|
+
# Download the backup file
|
101
|
+
number = args.first ? args.first : 1
|
102
|
+
|
103
|
+
if backup = backup_filename(number)
|
104
|
+
command = "ssh -t dokku@#{domain} postgres:backups:download #{app_name} #{backup} > #{backup}"
|
105
|
+
puts "Saving to local file: #{backup}"
|
106
|
+
`#{command}`
|
107
|
+
|
108
|
+
if psql_options
|
109
|
+
command = "psql #{psql_options} --file=#{backup}"
|
110
|
+
puts "Running #{command}..."
|
111
|
+
`#{command}`
|
112
|
+
puts "Deleting #{backup}..."
|
113
|
+
`rm #{backup}`
|
114
|
+
end
|
115
|
+
else
|
116
|
+
puts "Invalid backup number"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
109
120
|
desc "restart", "Restart the application"
|
110
121
|
def restart(*args)
|
111
122
|
run_command "restart #{app_name}"
|
@@ -175,6 +186,23 @@ module DokkuInstaller
|
|
175
186
|
@app_name ||= git_config_match[2]
|
176
187
|
end
|
177
188
|
|
189
|
+
def backup_filename(number)
|
190
|
+
# Make sure the number is valid or use 1
|
191
|
+
number = number.to_s.gsub(/\D/, "").to_i
|
192
|
+
number = 1 if number < 1
|
193
|
+
|
194
|
+
# Get the file name for the numbered backup
|
195
|
+
puts "Getting list of backups..."
|
196
|
+
command = "ssh -t dokku@#{domain} postgres:backups #{app_name}"
|
197
|
+
backups = `#{command}`
|
198
|
+
index = number - 1
|
199
|
+
if filename = backups.split("\n").reverse[index]
|
200
|
+
filename.strip
|
201
|
+
else
|
202
|
+
nil
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
178
206
|
def domain
|
179
207
|
@domain ||= git_config_match[1]
|
180
208
|
end
|
@@ -192,6 +220,32 @@ module DokkuInstaller
|
|
192
220
|
end
|
193
221
|
end
|
194
222
|
|
223
|
+
def psql_options
|
224
|
+
@psql_options ||= begin
|
225
|
+
restore_options = nil
|
226
|
+
|
227
|
+
if File.exist?("./config/database.yml")
|
228
|
+
if development_config = YAML::load(IO.read("./config/database.yml"))["development"]
|
229
|
+
restore_options = "--host=#{development_config['host']} --dbname=#{development_config['database']}"
|
230
|
+
|
231
|
+
if username = development_config["username"]
|
232
|
+
restore_options += " --username=#{username}"
|
233
|
+
end
|
234
|
+
|
235
|
+
if port = development_config["port"]
|
236
|
+
restore_options += " --port=#{port}"
|
237
|
+
end
|
238
|
+
else
|
239
|
+
puts "Missing database.yml config for development environment"
|
240
|
+
end
|
241
|
+
else
|
242
|
+
puts "Missing file config/database.yml"
|
243
|
+
end
|
244
|
+
|
245
|
+
restore_options
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
195
249
|
def run_command(command)
|
196
250
|
dokku_command = "ssh -t dokku@#{domain} #{command}"
|
197
251
|
|