A boring article is usually a story on my blog. We've all had those moments where the monotony of a day takes its toll. However, there are also those days where an unexpected event throws everything off course. The latter happened to me recently, and I decided to document it, not just to inform but to showcase how the seemingly boring tales of troubleshooting can sometimes be the heroic tales of a developer's daily life.
Introduction to Vagrant
Vagrant is an incredibly powerful command-line tool that interfaces with VirtualBox, allowing developers to create, manage, and streamline development environments. It saves a ton of time and effort by automating the setup of development environments through reproducible configurations.
However, someday, it was abruptly stopped working with one of my VirtualBox machine - terry - development. OMG, it was the development environment for mostly my works.
The Troubling Situation
How worst was that situations? Well, the gravity of the situation was significant:
- Shared folders I had set up in my Vagrantfile stopped working.
- I was unable to connect to the private IP address set in the Guest Operating System.
- The DNS resolution was no longer functional within the Guest OS.
Desperation kicked in. I scoured the Internet for answers, trying a plethora of different approaches. The dark clouds of desolation loomed as nothing seemed to work. It was clear that an ad-hoc rescue mission was in order.
Formulating a Rescue Plan
After much thought, a plan emerged. I would set up a shared folder, backup all the necessary files and directories, and place them into this shared folder.
Steps
(1) Setting Up Shared Folders
First, I accessed the VirtualBox Graphical User Interface (GUI). After selecting my virtual machine, I navigated to Settings and then clicked on Shared Folders.
(2) Configuration
In the Shared Folders settings, I chose a Folder Path (D:\terrylin\c
) and named it c
.
(3) Verifying Settings
I double-checked the settings, making sure everything was as I had configured.
Mounting the Shared Folder
Fortunately, I could still access my VirtualBox machine. I logged in using the username vagrant
and the password vagrant
. Changing to the root user, I executed commands to mount the shared folder I had just created.
mount -t vboxsf [-o OPTIONS] sharename mountpoint
Example
Create a new directory for mounting the share folder. In this case, I create a directory called c
in home
.
mkdir /home/c
Use the following command to mount the share folder. In this case, c
is the name I set in Shared Folders settings in VirutalBox GUI.
mount -t vboxsf c /home/c
Backing up Critical Data
The crucial step was backing up my MySQL databases. I exported all the data into an SQL file and placed it in the shared folder. I executed the command:
mysqldump -root -p --all-databases > /home/c/all.sql
After a few nerve-wracking minutes, the SQL file materialized on my Windows machine.
The relief was palpable.
Conclusion
This experience was a reminder of the importance of agility and resourcefulness. The ability to adapt and find solutions even when the sky seems to be falling is indispensable in a developer's toolkit. My environment was salvaged, and the day was won, but not without a few more gray hairs.
Comments