Closed micheldenegri closed 10 years ago
Hey,
Despite the plugin is intended for running script on the host, it could perhaps be used in a quite hacky way to get what you need:
config.trigger.before :destroy do
info "Dumping the database before destroying the VM..."
run "vagrant ssh -c 'your dump command'"
end
Note that:
Thanks a lot @emyl it works
For anyone finding this, you can also now use 'run_remote':
config.trigger.before :destroy do
info "Dumping the database before destroying the VM..."
run_remote "command"
end
If you prefer to use a shell script to contain all your teardown/cleanup tasks:
config.trigger.before :destroy do
info "Dumping the database before destroying the VM..."
run_remote "bash /vagrant/cleanup.sh"
end
... where /vagrant/cleanup.sh is a script that will exist on both the host and the guest, because vagrant shares the directory containing the vagrantfile on the host, with /vagrant on the guest by default.
I see its a bit old but really useful, the run_remote command should be highlighted from the main documentation.
Hello, Im curious if i can use your plugin to execute a script that connects to guest machine and create a database dump before vagrant destroy. or is it possible to use those triggers to execute the script directly on the guest machine?