eventhub-command 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/eh/commands/db.rb +61 -0
- data/lib/eh/settings.rb +1 -1
- data/lib/eh/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4da56a2bac456ac5244f676a92ebd2992b12f22
|
4
|
+
data.tar.gz: 01139ef38f51ba64c180567cc9dd9bb495578e4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c417a4b3abf4add944c5830a24f43155c5be174832f56a582b3a4c402d0ada35b2d30963a805782622b04d3092334308309171d6fc5b366bce057affabdfb461
|
7
|
+
data.tar.gz: 0aefa86aca74759c02eb2d5a151524ef94b012733d2c8e35fcd2048dc6aa25b10e6e2ef599fd223dc5d64d1da9174bca574bd195f528de0e9e4c16403ddf444e
|
data/README.md
CHANGED
@@ -87,3 +87,5 @@ Those config files will be used uppon next deployment.
|
|
87
87
|
* package_ruby: package ruby processors to zip files and copy to release directory on local machines. Those packages
|
88
88
|
will be used upon next "deploy_via scp" or if you commit them to SVN then upon next "deploy_via svn"
|
89
89
|
* generate_processor: generate a processor from a basic template
|
90
|
+
|
91
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
desc 'dump and restore db. Attention: those commands run on the local machine, not remote.'
|
2
|
+
command :db do |command|
|
3
|
+
|
4
|
+
command.switch([:v, :verbose], :desc => 'Show additional output.')
|
5
|
+
command.flag([:user], default_value: 'event_hub_console', desc: 'DB User')
|
6
|
+
command.flag([:db], default_value: 'event_hub_console', desc: 'DB name')
|
7
|
+
command.flag([:file], desc: "Output Filename, last backup will be taken as default")
|
8
|
+
|
9
|
+
command.command :dump do |c|
|
10
|
+
c.action do |global_options, options, args|
|
11
|
+
base = Eh::Settings.current.db_backups_dir
|
12
|
+
stamp = Time.now.strftime('%Y%m%d%H%M%S')
|
13
|
+
target = options[:file] || "#{stamp}-console-dump.sql"
|
14
|
+
|
15
|
+
cmd = "mkdir -p #{base} && cd #{base} && pg_dump -U#{options[:user]} #{options[:db]} -f#{target}"
|
16
|
+
if options[:verbose]
|
17
|
+
puts "will execute '#{cmd}'"
|
18
|
+
end
|
19
|
+
system cmd
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
command.command :restore do |c|
|
24
|
+
c.action do |global_options, options, args|
|
25
|
+
source = options[:file] || begin
|
26
|
+
base = Eh::Settings.current.db_backups_dir
|
27
|
+
pattern = File.join(base, '*')
|
28
|
+
files = Dir.glob(pattern).sort
|
29
|
+
files.last
|
30
|
+
end
|
31
|
+
if source.nil?
|
32
|
+
raise ArgumentError.new("No source file found in #{base} and none passed via --file")
|
33
|
+
end
|
34
|
+
cmd = "psql -U#{options[:user]} -d#{options[:db]} -f#{source}"
|
35
|
+
if options[:verbose]
|
36
|
+
puts "will execute '#{cmd}'"
|
37
|
+
end
|
38
|
+
system cmd
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
command.command :cleanup_dumps do |c|
|
43
|
+
c.flag([:keep], type: Integer, desc: "How many dumps to keep", default_value: 5)
|
44
|
+
c.action do |global_options, options, args|
|
45
|
+
keep = options[:keep]
|
46
|
+
base = Eh::Settings.current.db_backups_dir
|
47
|
+
pattern = File.join(base, '*')
|
48
|
+
files = Dir.glob(pattern).sort.reverse # keep most recent
|
49
|
+
to_delete = files[keep..-1] || []
|
50
|
+
|
51
|
+
to_delete.each do |file|
|
52
|
+
if options[:verbose]
|
53
|
+
puts "will delete #{file}"
|
54
|
+
end
|
55
|
+
system "rm #{file}"
|
56
|
+
end
|
57
|
+
puts "deleted #{to_delete.size} file(s)"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
data/lib/eh/settings.rb
CHANGED
data/lib/eh/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eventhub-command
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pascal Betz
|
@@ -153,6 +153,7 @@ files:
|
|
153
153
|
- lib/deployer/stage.rb
|
154
154
|
- lib/eh-commands.rb
|
155
155
|
- lib/eh.rb
|
156
|
+
- lib/eh/commands/db.rb
|
156
157
|
- lib/eh/commands/deploy_config.rb
|
157
158
|
- lib/eh/commands/deploy_console.rb
|
158
159
|
- lib/eh/commands/deploy_mule.rb
|