Closed Twansparant closed 9 years ago
Your second question re: invalid option looks like a quoting issue. The arguments you intend to pass to "mysqldump" are being passed to "vagrant ssh". Try:
run "vagrant ssh -c 'mysqldump -u#{db_user} -p#{db_pass} #{db_name} > /srv/database/backups/#{db_name}.sql'"
Alternatively, use run_remote()
. It's a helper method that vagrant-triggers exposes (see: issue #8).
I agree with @hallman76, run_remote
should fit perfectly to your use case.
Hi there,
I'm trying to achieve a workflow similar to https://github.com/Varying-Vagrant-Vagrants/VVV/ where (if available) the database is imported from a synched folder on
vagrant up
and exported onvagrant halt
,suspend
anddestroy
.VVV uses an external command from a specific directory /config/homebin/vagrant_halt which referes to another command db_backup in that same directory.
I'm trying to understand how these commands are recognized in their Vagrantfile, because when I try to run the command
vagrant_halt
in the halt trigger I get an error:Which makes sense. So my first question is how can I run a command in the vagrant-triggers that's in a separate command file?
As a workaround I tried to run the db_backup lines directly in the vagrant-trigger like this:
Where db_name, db_user & db_pass are specified in a group_vars/development file. The loop and variables all work, but I keep on getting the following error when running
vagrant halt
:What exactly is this invalid option that is specified? I tried running it without the
-c
flag but that makes no difference.Thanks for your help!