psychic-nemesis-ninja 0.0.2 → 0.0.3
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.
- data/lib/commands/export-db.rb +14 -0
- data/lib/commands/import-db.rb +14 -0
- data/lib/psychic-nemesis-ninja.rb +11 -1
- data/lib/psychic-nemesis-ninja/version.rb +1 -1
- metadata +4 -2
@@ -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
|
-
|
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
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
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
|