We recently had a Windows update that messed up our Virtualbox. After reinstalling our VVV box we realized we only had database backups from a few days ago due to a vagrant halt, and lost 2 days worth of work. Is there an automatic database backup plugin / cron job / etc available? After searching for half an hour I haven't found anything I trust.
If someone can provide a plugin, cron job code, examples, that would be perfect because I cannot write what I need top of my head yet.
We run gulp on our projects within VVV, so I'm wondering if we can trigger a database backup every time we run gulp through our command line through a vagrant-trigger. Is this possible?
Vagrant triggers runs the command db_backup to dump databases. You could set a cron job to run that command from inside the vm as frequently as you need.
If you wanted to run the cron on the host then the command would be vagrant ssh -c 'db_backup' from the vvv folder.
@LoreleiAurora thank you, this is exactly what I'm looking for. Have you or anyone set this up or something similar that I can edit? After setting up everything for 2 hours today I'm afraid to add or append anything that might cause it to break. Is this a separate shell script that hooks in or? Please advise.
As root create the following file at /etc/cron.d/auto-backup in the vm
0 * * * * vagrant /bin/bash /home/vagrant/bin/db_backup >> /vagrant/db_backup.log
This will backup the databases every hour.
This is why vagrant-triggers was integrated.
Thank you, I'll let you know if this works! Sometimes we leave the server running overnight or over several nights. We could easily shut down every night (as we should have, and will) but we're looking to backup more frequently during the day with more devs onboarding.
@LoreleiAurora this worked perfectly. Can't thank you enough!
@LoreleiAurora sorry to reopen this. Wanted to check and see if multiple database backups are possible.
What you have provided is working flawlessly. However, with some major projects we have on the table we want the ability to save multiple versions of the same database.
Is it possible to update the script so that we can have a weeks worth of backups?
backups/
../backup.sql
../backup-1.sql
../backup-2.sql
../backup-2.sql
../anothersite.sql
../anothersite-2.sql
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
@LoreleiAurora this worked perfectly. Can't thank you enough!