Closed danfoy closed 6 years ago
Hey @danfoy,
Thanks for opening this issue! I've just pulled down the extension as I haven't used this one in a while. The backup will fire if your machine is running after you've run vagrant up
then you do vagrant destroy
.
You should see this on the command line:
When you run a vagrant up
after that you should see the backup being restored at the very end of the provisioning process.
I was hoping I would be able to modify this to run every time Vagrant is halted, and then restore on
vagrant up
I like the idea of running it on halt
as well as destroy
. I should be able to whip up a PR for you that will add the prompt about the backup on vagrant halt
but I think off the top of my head rather than it running on vagrant up
you would have to do that and then also vagrant provision
to restore the backup. I'll look into this now for you and do a new PR to get @rmccue's feedback on that seeing as he might have a differing opinion on adding support for that.
@danfoy I've added https://github.com/Chassis/db-backup/pull/3/
When you're running vagrant halt
, your database stays safe on the machine's (virtual) hard drive, so there's typically no need to back it up. Only when you run vagrant destroy
does it need to actually run a backup, since that's when you're actually removing the hard drive.
That said, if you vagrant halt
then vagrant destroy
, I don't know what happens, since it won't be able to run the command inside the machine. Needs some testing there I think.
Is there a specific reason you would want the backup available on halt (apart from ensuring your database persists, which it does anyway)?
When you're running
vagrant halt
, your database stays safe on the machine's (virtual) hard drive, so there's typically no need to back it up.
I had the same thought but just assumed @danfoy might have a different kinda workflow.
That said, if you
vagrant halt
thenvagrant destroy
, I don't know what happens
With this PR you'll get prompted for a backup when you run vagrant halt
then when you run vagrant destroy
after that you'll still have the chassis-backup.sql
so when you vagrant up
you'll be back in action with that last DB export.
I'm totally cool with killing this PR once we get some feedback from Dan though. A better option might just be updating the readme. Time will tell! ⏱
This is perfect, thanks a lot!
Is there a specific reason you would want the backup available on halt (apart from ensuring your database persists, which it does anyway)?
My specific use case is when I'm working on a WordPress site either with someone else, or for someone who wants regular updates on what's going on but doesn't want the site online for whatever reason, and changes to the posts and and pages are integral to the work which is going on. When I'm done working I can send them the folder (or they can get it via git) and changes to the database travel with the folder.
It sounds like a better fit here would be to have a manual command (like vagrant db-backup
) that generates the backup for you. Backups are kind of expensive to generate often, especially for a common command like halt
. Would a manual command fit?
It sounds like a better fit here would be to have a manual command (like vagrant db-backup)
Well Chassis comes with wp-cli, so I can already do this by ssh
ing in and running wp db export portabledb.sql
on exit and wp db import portabledb.sql
on next load. It's more a convenience thing than a 'being able to do it' thing.
Backups are kind of expensive to generate often, especially for a common command like
halt
.
Yeah that's true. These aren't sprawling sites though, and it's usually towards the beginning of my projects when most of the database changes happen anyway. I wouldn't use it on halt
for huge existing builds, but for my current projects not having to remember to backup and restore the db outweighs having to wait a couple of extra seconds on up
and halt
.
I'd probably switch to the regular plugin further down the road, and it does interrupt the halt
process which I understand could be annoying, so I can see why you might not want this in the regular version of the plugin. But this modification is really useful for me at the moment (massive thanks again to @BronsonQuick!) so if you want to keep the plugin as-is maybe this version could be forked into an alternative or something.
I'm really new to Vagrant boxes though, so if I'm missing something really obvious please do say!
I've added some optional configs in the core plugin now: https://github.com/Chassis/db-backup#configuration
I can't seem to get this plugin to run. Chassis downloads it to the extensions folder whether I load it as
Chassis/db-backup
or just asdb-backup
inconfig.yaml
, and I've tried installing it manually via git also, but no matter what I do it never seems to fire.I was hoping I would be able to modify this to run every time Vagrant is halted, and then restore on
vagrant up
, but no matter how many times I reinstall it, re-provision, or destroy/re-up, it never seems to actually run.Any ideas?