Instantly share code, notes, and snippets.

Embed
What would you like to do?
A modified Vagrantfile to tell VVV to run import-sql script on up
# Vagrant Triggers
#
# If the vagrant-triggers plugin is installed, we can run various scripts on Vagrant
# state changes like `vagrant up`, `vagrant halt`, `vagrant suspend`, and `vagrant destroy`
#
# These scripts are run on the host machine, so we use `vagrant ssh` to tunnel back
# into the VM and execute things. By default, each of these scripts calls db_backup
# to create backups of all current databases. This can be overridden with custom
# scripting. See the individual files in config/homebin/ for details.
if defined? VagrantPlugins::Triggers
config.trigger.after :up, :stdout => true do
info "Importing databases..."
run_remote "bash /srv/database/sync-sql.sh"
end
config.trigger.before :halt, :stdout => true do
run "vagrant ssh -c 'vagrant_halt'"
end
config.trigger.before :suspend, :stdout => true do
run "vagrant ssh -c 'vagrant_suspend'"
end
config.trigger.before :destroy, :stdout => true do
run "vagrant ssh -c 'vagrant_destroy'"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment