psychic-nemesis-ninja 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,14 @@
1
+ class ExportDb < Vagrant.plugin(2, :command)
2
+ def execute
3
+ with_target_vms([], :single_target => true) do |vm|
4
+ @logger.debug("Exporting databases to vagrant folder")
5
+ env = vm.action(:ssh_run, :ssh_run_command => "filename=`date +%Y%m%d-%H%M%S`; mkdir -p /vagrant/db-export; mysqldump -uroot --all-databases > /vagrant/db-export/${filename}.sql")
6
+
7
+ # Exit with the exit status of the command or a 0 if we didn't
8
+ # get one.
9
+ exit_status = env[:ssh_run_exit_status] || 0
10
+ return exit_status
11
+ end
12
+ 0
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ class ImportDb < Vagrant.plugin(2, :command)
2
+ def execute
3
+ with_target_vms([], :single_target => true) do |vm|
4
+ @logger.debug("Import databases from /vagrant/exported_dbs.sql")
5
+ env = vm.action(:ssh_run, :ssh_run_command => "filename=`ls | sort -r | head -1`; mysql -uroot < /vagrant/db-export/${filename}")
6
+
7
+ # Exit with the exit status of the command or a 0 if we didn't
8
+ # get one.
9
+ exit_status = env[:ssh_run_exit_status] || 0
10
+ return exit_status
11
+ end
12
+ 0
13
+ end
14
+ end
@@ -15,4 +15,14 @@ class PsychicMemesisNinja < Vagrant.plugin("2")
15
15
  require_relative "commands/restart-memcached"
16
16
  RestartMemcached
17
17
  end
18
- end
18
+
19
+ command "export-db" do
20
+ require_relative "commands/export-db"
21
+ ExportDb
22
+ end
23
+
24
+ command "import-db" do
25
+ require_relative "commands/import-db"
26
+ ImportDb
27
+ end
28
+ end
@@ -1,7 +1,7 @@
1
1
  module Psychic
2
2
  module Nemesis
3
3
  module Ninja
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.3"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Christopher Valles
@@ -33,6 +33,8 @@ files:
33
33
  - LICENSE.txt
34
34
  - README.md
35
35
  - Rakefile
36
+ - lib/commands/export-db.rb
37
+ - lib/commands/import-db.rb
36
38
  - lib/commands/restart-apache.rb
37
39
  - lib/commands/restart-memcached.rb
38
40
  - lib/commands/restart-mysql.rb