<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sajit Maharjan</title>
    <description>The latest articles on DEV Community by Sajit Maharjan (@sajit21).</description>
    <link>https://dev.to/sajit21</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3937305%2F21e15bf2-5436-46b8-a61b-d8795936e8b1.jpg</url>
      <title>DEV Community: Sajit Maharjan</title>
      <link>https://dev.to/sajit21</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sajit21"/>
    <language>en</language>
    <item>
      <title>Building Hypervisor Infrastructure with Proxmox and Ceph</title>
      <dc:creator>Sajit Maharjan</dc:creator>
      <pubDate>Mon, 18 May 2026 11:22:32 +0000</pubDate>
      <link>https://dev.to/sajit21/building-hypervisor-infrastructure-with-proxmox-and-ceph-53km</link>
      <guid>https://dev.to/sajit21/building-hypervisor-infrastructure-with-proxmox-and-ceph-53km</guid>
      <description>&lt;p&gt;Author: Rajendra Acharya&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;Why Proxmox and Ceph?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Proxmox Virtual Environment (PVE) is a powerful, open-source platform for managing virtual machines and containers. Combined with Ceph, a distributed storage system, you can achieve:&lt;/p&gt;

&lt;p&gt;High Availability (HA): Minimized downtime with automatic failover.&lt;/p&gt;

&lt;p&gt;Scalability: Seamless expansion of compute and storage resources.&lt;/p&gt;

&lt;p&gt;Cost-Effectiveness: Open-source and community-driven solutions.&lt;/p&gt;

&lt;p&gt;This combination is ideal for enterprises, startups, and enthusiasts looking to build a production-grade hypervisor infrastructure.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;Setting Up Proxmox Infrastructure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Install Proxmox VE&lt;/strong&gt;&lt;br&gt;
.&lt;br&gt;
Download ISO: Download the Proxmox VE ISO.&lt;br&gt;
Install: Burn the ISO to a USB drive or use PXE boot, and install it on your server hardware.&lt;br&gt;
Initial Configuration:&lt;br&gt;
Set up the hostname, IP address, and root password.&lt;br&gt;
Ensure proper network configuration for management.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;Step 2: Network Configuration&lt;/strong&gt;&lt;br&gt;
.&lt;br&gt;
Use a bonded interface for redundancy.&lt;br&gt;
Create separate VLANs for:&lt;br&gt;
Management traffic.&lt;br&gt;
Ceph storage traffic.&lt;br&gt;
VM data traffic&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;Setting Up Ceph for Distributed Storage&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Prepare Proxmox Nodes&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ensure at least three Proxmox nodes for a reliable Ceph cluster.&lt;/li&gt;
&lt;li&gt;Install additional disks on each node for Ceph’s OSDs (Object Storage Daemons).
.
.
&lt;strong&gt;Step 2: Install and Configure Ceph&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Enable Ceph:&lt;/li&gt;
&lt;li&gt;Navigate to Datacenter → Ceph in the Proxmox web interface.&lt;/li&gt;
&lt;li&gt;Initialize the Ceph cluster.
.&lt;/li&gt;
&lt;li&gt;Deploy OSDs:&lt;/li&gt;
&lt;li&gt;Add the dedicated disks to the Ceph cluster via Ceph → OSD.
.&lt;/li&gt;
&lt;li&gt;Setup Monitors (MONs):&lt;/li&gt;
&lt;li&gt;Add at least three monitor nodes for quorum and cluster reliability.
.&lt;/li&gt;
&lt;li&gt;Configure Ceph Pools:&lt;/li&gt;
&lt;li&gt;Create pools for storage, defining redundancy settings like replication or erasure coding.
.
.
&lt;strong&gt;Integrating Ceph with Proxmox&lt;/strong&gt;
.
Step 1: Add Ceph Storage to Proxmox&lt;/li&gt;
&lt;li&gt;Go to Datacenter → Storage, and add Ceph RBD as a new storage type.&lt;/li&gt;
&lt;li&gt;Test connectivity and ensure proper pool access.
.
&lt;strong&gt;Step 2: Migrate VM Storage&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Move VM disks to the Ceph RBD pool for centralized storage and HA.
.
.
&lt;strong&gt;High Availability and Maintenance&lt;/strong&gt;
.
&lt;strong&gt;Configure HA in Proxmox&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Use HA Groups to define failover priorities.&lt;/li&gt;
&lt;li&gt;Ensure fencing devices or quorum settings are configured to avoid split-brain scenarios.
.
&lt;strong&gt;Regular Maintenance&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Monitor the health of the Ceph cluster (ceph status).&lt;/li&gt;
&lt;li&gt;Use the Proxmox dashboard to monitor and manage VM performance.
.
.
&lt;strong&gt;The Take-Away&lt;/strong&gt;
Building a hypervisor infrastructure with Proxmox and Ceph is a rewarding experience that blends the power of open-source tools with enterprise-grade features. While the initial setup requires thoughtful planning, the result is a resilient, scalable, and cost-effective environment.
.
.
&lt;strong&gt;Related Reading&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Proxmox VE Documentation&lt;/li&gt;
&lt;li&gt;Ceph Documentation&lt;/li&gt;
&lt;li&gt;Ceph Storage Basics&lt;/li&gt;
&lt;li&gt;Building a Hyper-Converged Infrastructure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By understanding and implementing these systems, you not only gain valuable experience but also the satisfaction of running an infrastructure that rivals commercial offerings in performance and reliability.&lt;/p&gt;

</description>
      <category>infrastructure</category>
      <category>linux</category>
      <category>opensource</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>The Digital Tithe: Why Open Source is Nepal’s Only Path to Sovereignty</title>
      <dc:creator>Sajit Maharjan</dc:creator>
      <pubDate>Mon, 18 May 2026 11:05:08 +0000</pubDate>
      <link>https://dev.to/sajit21/the-digital-tithe-why-open-source-is-nepals-only-path-to-sovereignty-2296</link>
      <guid>https://dev.to/sajit21/the-digital-tithe-why-open-source-is-nepals-only-path-to-sovereignty-2296</guid>
      <description>&lt;p&gt;&lt;strong&gt;From Digital Vassalage to National Pride: Why a Sovereign Tech Stack is Nepal’s New Declaration of Independence.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Author&lt;/strong&gt;: Bishal KC | Cloud Native&lt;br&gt;
.&lt;br&gt;
Nepal’s foreign exchange reserves have reached a historic high of Rs. 2,677.68 billion. On paper, this is a triumph—a fortress built against the volatile tides of the global economy. Yet, beneath the celebratory headlines of the Nepal Rastra Bank lies a structural hemorrhage.&lt;/p&gt;

&lt;p&gt;But even as this wealth flows in through the front door, a significant and growing share of it quietly exits through the digital back door. It flows directly to the glass towers of Silicon Valley and the corporate campuses of Redmond.&lt;/p&gt;

&lt;p&gt;In our national accounts, these outflows are sanitized with labels like “charges for the use of intellectual property” or “computer services.” Let us call it what it actually is: a digital tithe. We are paying a recurring, never-ending rent simply to operate the systems that run our own country. As we push forward with the Digital Nepal Framework 2.0, we aren’t just building a modern state; we are building a digital plantation where we are the sharecroppers.&lt;br&gt;
.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgsj4p1xiazyoj4b59flh.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgsj4p1xiazyoj4b59flh.jpg" alt=" " width="800" height="447"&gt;&lt;/a&gt;&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;The Anatomy of Digital Colonialism: The Trap of Vendor Lock-In&lt;/strong&gt;&lt;br&gt;
.&lt;br&gt;
In the 20th century, colonialism was about land and resources. In the 21st, it is about code and data. The hidden cost of proprietary software is not the initial purchase price; it is the vendor lock-in—a state of captivity where the cost of switching becomes so high that the customer becomes a permanent asset of a foreign corporation.&lt;/p&gt;

&lt;p&gt;For Nepal, this means our state institutions are being held hostage by foreign boardrooms. The financial stakes are staggering. Globally, enterprise virtualization platforms—the software that allows one server to act as many—are licensed per CPU core. For a modest government data center with 1,000 cores, the annual “rent” can exceed $550,000 (approx. NPR 7.2 crore).&lt;/p&gt;

&lt;p&gt;This is not a hypothetical risk. Following Broadcom’s acquisition of VMware, customers globally—including Nepal’s banking and government sectors—were hit with price hikes of 150% to 300% almost overnight. As a small market, Nepal has zero negotiating power. If our National ID system, Social Security Fund, or Tax records are built on these “black boxes,” we have effectively handed the keys to our national infrastructure to a stranger who can change the locks at will.&lt;/p&gt;

&lt;p&gt;We are building our digital future on land we do not own, with materials we cannot inspect, for a rent we cannot control.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;The Sovereign Stack: Infrastructure is Not a Product​&lt;/strong&gt;&lt;br&gt;
.&lt;br&gt;
As we build our Digital Public Infrastructure (DPI)—the digital equivalent of our highways, electricity grids, and water systems—we must realize that Proprietary DPI is a contradiction in terms. DPI consists of the foundational layers of identity, payments, and data exchange. In the physical world, we would never allow a foreign corporation to own the exclusive rights to the blueprints of our national highways or the “off-switch” for our power grid. Yet, by building our “Citizen Stack” on closed-source platforms, we are doing exactly that.&lt;/p&gt;

&lt;p&gt;The antidote is the adoption of a “Sovereign Stack” built on foundations that are already the global standard. This is not an experimental dream; it is a reality proven by battle-tested open-source giants:&lt;br&gt;
.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8qlac00qoe4vo57olh02.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8qlac00qoe4vo57olh02.jpg" alt=" " width="800" height="387"&gt;&lt;/a&gt;&lt;br&gt;
.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk2nqi00b89ks88xqolji.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk2nqi00b89ks88xqolji.jpg" alt=" " width="800" height="302"&gt;&lt;/a&gt;&lt;br&gt;
.&lt;br&gt;
For Nepal, the mandate to use these open standards in our DPI is a Declaration of Independence. It ensures Portability as Power. If we build our national infrastructure on an open-source, Kubernetes-based architecture, our digital services become platform-agnostic. We are no longer at the mercy of any single provider’s uptime or pricing. If a vendor raises prices, we can move our entire national infrastructure to local servers in Kathmandu or a different provider overnight. We own the orchestration; therefore, we own the destiny of our data.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;Reversing the Brain Drain: From Resellers to Architects&lt;/strong&gt;&lt;br&gt;
.&lt;br&gt;
Nepal’s greatest loss is not financial; it is human. In 2023 alone, over 808,000 Nepalese departed for foreign shores. We produce approximately 9,000 IT graduates annually—brilliant minds capable of competing on a global stage. However, our current procurement ecosystem provides them with a bleak choice: leave or become a clerk.&lt;/p&gt;

&lt;p&gt;When the government and large enterprises continuously outsource their infrastructure to foreign proprietary vendors, local IT firms are reduced to acting as mere “license resellers.” This is a hollow business model. Our engineers become support staff for foreign products, trained only to “click buttons” on a dashboard designed in California.&lt;/p&gt;

&lt;p&gt;Transitioning to an open-source-first model fundamentally changes this dynamic. Mastering technologies like Kubernetes and OpenStack requires high-level architectural design and systems integration. It transforms our domestic IT sector from a middleman economy into a value-added industry.&lt;/p&gt;

&lt;p&gt;By adopting this model, the government’s massive IT budget—currently estimated at NPR 20–30 crore annually for licensing alone—can be rechannelled directly into the domestic economy. Instead of buying a license from a foreign giant, the government can pay a local Nepali company for support, customization, and maintenance. This creates high-value employment locally, offering our brightest engineers a compelling reason to stay and build the future of Nepal’s digital infrastructure. We must stop being a nation that consumes software and start being a nation that builds it.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;Shattering the Security Myth: Transparency over Obscurity&lt;/strong&gt;&lt;br&gt;
.&lt;/p&gt;

&lt;p&gt;​To make this transition, we must dismantle the most dangerous misconception held by conservative policymakers: the myth that “open source is open and therefore vulnerable.” This fallacy of “security through obscurity”—the idea that hiding source code makes it safer—is rejected by every modern cybersecurity standard.&lt;/p&gt;

&lt;p&gt;The security of open-source software is underpinned by Linus’s Law: “Given enough eyeballs, all bugs are shallow.” Because the code of the Linux kernel or Kubernetes is transparent, it is audited by a global community of thousands of independent security researchers. Vulnerabilities are detected and patched at a speed that proprietary “black boxes” cannot match.&lt;/p&gt;

&lt;p&gt;In a closed-source system, a flaw can sit hidden and unpatched for years, known only to the vendor and perhaps a sophisticated hacker or a foreign intelligence agency. True digital sovereignty is impossible if the state cannot independently audit the code running its critical infrastructure. In an era of increasing global cyber-warfare, using software you cannot inspect is like building a fortress and letting a stranger hold the only set of keys. If the titans of global technology trust open-source architecture to secure their empires, the Government of Nepal has no reason to fear it.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;The Geopolitical Necessity: Digital Non-Alignment&lt;/strong&gt;&lt;br&gt;
.&lt;br&gt;
In a world increasingly divided by “technological cold wars,” Nepal must practice Digital Non-Alignment. Relying on a single proprietary stack from one geopolitical region makes our national infrastructure a target for sanctions, trade wars, or political leverage.&lt;/p&gt;

&lt;p&gt;Open-source software belongs to no single nation. It is a global commons. By building on FOSS, Nepal ensures that its digital services remain operational regardless of changes in international relations or foreign export controls. Whether it is a health registry in Humla or a payment gateway in Birgunj, our software should not depend on the whims of a foreign government’s trade policy. We must protect our “Digital Sovereignty” by ensuring that no single foreign entity has the power to “turn off” Nepal.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;A Roadmap for Reform: The Three Pillars​&lt;/strong&gt;&lt;br&gt;
The path forward requires more than just speeches; it requires bold political will. The government must take three structural steps immediately:&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;1. Mandate an “Open Source First” Procurement Policy:&lt;/strong&gt; Public procurement laws must be updated. All government agencies must evaluate battle-tested open-source solutions by default. A proprietary solution should only be procured if the agency provides a rigorous, publicly documented justification proving that no viable open alternative exists, factoring in the long-term financial risks of vendor lock-in.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;2. Establish a National Open Source Program Office (OSPO):&lt;/strong&gt; Under the Ministry of Communication and Information Technology, a Nepalese OSPO would act as the central hub for strategy, capacity building, and security compliance. This office will bridge the gap between the state and our vibrant local tech community, ensuring that our civil servants are trained to manage the Sovereign Stack.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;3. Invest in “Local-First” Support Ecosystems:&lt;/strong&gt; The government should provide incentives for local IT startups that specialize in open-source implementation. By creating a certification program for “Sovereign Stack Providers,” we can ensure that when a government office chooses open source, they have reliable, local technical support.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;The Software Must Belong to the Nation​&lt;/strong&gt;&lt;br&gt;
.&lt;br&gt;
Adopting open-source technology is not a “cheaper” alternative; it is a strategic national imperative. We are at a crossroads. We can continue down the legacy path of digital vassalage, perpetually tethering our national budgets to foreign entities. Or, we can choose the path of resilience and independence.&lt;/p&gt;

&lt;p&gt;The era of renting our digital future must end. The software that runs the nation must belong to the nation.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>When VM Data Goes Missing</title>
      <dc:creator>Sajit Maharjan</dc:creator>
      <pubDate>Mon, 18 May 2026 06:39:52 +0000</pubDate>
      <link>https://dev.to/sajit21/when-vm-data-goes-missing-2j0n</link>
      <guid>https://dev.to/sajit21/when-vm-data-goes-missing-2j0n</guid>
      <description>&lt;p&gt;&lt;strong&gt;The Incident: A Client’s Unexpected Data Disruption&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Even with the best plans, things can go wrong. Recently, one of our valued clients faced a tough situation: a key virtual machine (VM) on their office server lost important data, including all VM configuration files and critical binary files. This post will walk you through how we stepped in to help them get everything back, what we learned from the experience, and how we’re now working with them to ensure such an incident doesn’t happen again.&lt;/p&gt;

&lt;p&gt;It all started during what should have been routine virtual machine management at our client’s site. Without anyone deleting anything on purpose, a system anomaly led to the inadvertent removal of critical files from an office server VM. This immediately caused problems with their services, disrupted daily internal operations, and raised significant concerns about their data integrity. As their trusted IT consultants, we were immediately engaged to assess the situation and lead the recovery effort.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;How We Got It Back: Our Step-by-Step Recovery Protocol&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Our recovery plan for the client was clear: to restore the entire VM’s functionality, including its configuration, binary files, and any application data like MySQL tables. Just copying files wasn’t an option, as crucial setup information was missing. We had to approach this with precision and care.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;Getting Ready for Recovery&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Initial Assessment and Containment&lt;/strong&gt;: As soon as we were brought in, our first priority was to quickly assess the full extent of the data loss and immediately contain the incident. This was crucial to prevent any further data corruption or potential spread of the issue.
.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Set Up the Recovery Environment&lt;/strong&gt;: We established a safe, isolated recovery environment at the client’s location. First of all, we took a backup of what was left on the affected system. This involved securing all their existing backups too, and making sure we had the right permissions to do the work without affecting their live systems.
.
.
&lt;strong&gt;Attempting Direct Disk Recovery and VM Reconstruction&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This phase involved our initial, fastest attempt at recovery directly from the affected disk, followed by VM reconstruction if needed.&lt;br&gt;
.&lt;br&gt;
1.&lt;strong&gt;Attempting Direct File Recovery with TestDisk (Our First Line of Defense)&lt;/strong&gt;: Our client’s last full VM backup was 15 days old, meaning a direct restore would lead to a significant data loss gap. To minimize this, we first attempted to recover files directly from the deleted disk. This was our fastest path to potentially recovering the most recent data.&lt;br&gt;
The reason this approach holds promise is due to how file deletion typically works in Linux systems. When a file is “deleted” on a Linux filesystem, the data itself isn’t immediately erased from the disk sectors. Instead, the operating system primarily removes the file’s metadata (like its name, location, and size) from the filesystem’s index. The sectors where the data resides are merely marked as available for new data. Until new data overwrites those sectors, the original data might still be present.&lt;br&gt;
We utilized TestDisk, a powerful free and open-source data recovery utility, designed to recover lost partitions and make non-booting disks bootable again, but it’s also highly effective at recovering deleted files.&lt;br&gt;
.&lt;br&gt;
Here’s a simplified overview of how we used TestDisk:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installation&lt;/strong&gt;: TestDisk was installed on a separate a live Linux environment.&lt;br&gt;
.&lt;br&gt;
&lt;code&gt;sudo apt-get install testdisk&lt;/code&gt;&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;Disk Selection&lt;/strong&gt;: We launched testdisk and selected the affected disk drive where the VM data was lost.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Partition Analysis&lt;/strong&gt;: TestDisk was instructed to analyze the partition structure, looking for lost partitions or deleted files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;File Recovery&lt;/strong&gt;: We navigated through the detected filesystem structure, searching for the critical VM configuration files and binary files that were reported missing. TestDisk attempts to scan the unallocated sectors and rebuild the file metadata, allowing for recovery.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;Outcome of TestDisk:&lt;/strong&gt;&lt;br&gt;
.&lt;br&gt;
Unfortunately, despite our best efforts and TestDisk’s capabilities, in this specific instance, the tool did not yield the desired results for the critical VM configuration and binary files. This suggested that the sectors containing the crucial metadata or parts of the files might have already been overwritten or were too fragmented for a complete recovery in this complex VM environment. While this was a setback, it was a necessary and rapid first attempt to minimize data loss.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;Identifying Post-Backup Changes and Data Location&lt;/strong&gt;&lt;br&gt;
.&lt;br&gt;
After TestDisk didn’t provide a full recovery, we shifted focus to identifying what data might have changed since the 15-day-old backup. We determined that:&lt;/p&gt;

&lt;p&gt;Most of the core system configuration files would likely be the same as in the backup.&lt;/p&gt;

&lt;p&gt;The Gitea repository (for code) and its commit data would definitely have changed.&lt;/p&gt;

&lt;p&gt;The MySQL database data would also have been updated.&lt;/p&gt;

&lt;p&gt;Luckily, we found that the &lt;strong&gt;/var/lib&lt;/strong&gt; directory on the corrupt disk still contained the data for both MySQL and Gitea. This was a crucial discovery, as these directories typically store the application’s persistent data.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;VM Reconstruction and Configuration Restoration:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since a direct recovery wasn’t fully successful, we proceeded to recreate the VM environment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;New VM Setup&lt;/strong&gt;: We set up a brand new Ubuntu 22 VM (matching the client’s original operating system) to serve as the recovery target.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Package Installation&lt;/strong&gt;: All necessary software packages were installed on this new VM.&lt;/p&gt;

&lt;p&gt;Configuration Replacement: We then replaced the default configuration files on the new VM with the configuration files recovered from the 15-day-old backup. This brought the system’s core settings back to a known good state.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;Firewall Rules and Gitea Data Recovery:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Firewall Rules&lt;/strong&gt;: The client’s firewall rules were well-documented in their change logs. We manually recreated these rules on the new VM, a process that did not take much time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gitea Data Recovery&lt;/strong&gt;: For the Gitea application, we simply replaced its data directory on the new VM with the Gitea data directory we had recovered from the corrupt disk’s /var/lib location. After carefully managing file permissions and ownership, database recovery was the only thing left to bring back back Gitea and other service online with its latest data.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;MySQL Data Recovery – The Core Challenge&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After the configurations were restored, the most important task was recovering the MySQL data. This required a detailed approach, especially since the .ibd files were crucial and directly copying them wasn’t straightforward due to missing metadata.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Database Structure Re-initialization:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The foundational step was to re-establish the database’s structural integrity. We did this by importing an SQL dump from the older, 15-day-old backup. This recreated all database schemas, table definitions, and initial configurations.&lt;br&gt;
&lt;code&gt;**sudo mysql &amp;lt; backup.sql**&lt;/code&gt;&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;2.User Privilege Configuration:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Following the schema restoration, we recreated the necessary database user accounts for the client and reinstated their respective privileges. All user credentials were securely retrieved from backed-up configurations files.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;3.Understanding InnoDB and .ibd File Restoration:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To effectively restore the client’s MySQL database, we leveraged our deep understanding of the MySQL InnoDB storage engine, particularly its transactional properties and recovery mechanisms. This was crucial for handling the .ibd files.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;4.Temporarily Disable Database Rules:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To ensure a smooth import process and prevent any integrity errors, we temporarily turned off foreign key checks.&lt;br&gt;
&lt;code&gt;SET FOREIGN_KEY_CHECKS = 0;&lt;/code&gt;&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;5.Discard Existing Data Links (Tablespaces)&lt;/strong&gt;: &lt;br&gt;
To prepare for the seamless import of the new .ibd files, we first told the database to forget where its current data files were. This effectively unlinks the table definitions from their associated data files, clearing the way for the new ones.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
Important Note: This operation disconnects the current data. We always ensure our clients have a complete and verified backup before performing this step!&lt;br&gt;
&lt;code&gt;SELECT CONCAT('ALTER TABLE&lt;/code&gt;', TABLE_SCHEMA, '&lt;code&gt;.&lt;/code&gt;', TABLE_NAME, '&lt;code&gt;DISCARD TABLESPACE;') &lt;br&gt;
AS sql_command FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = &amp;lt;DatabaseName&amp;gt; AND ENGINE = 'InnoDB';&lt;/code&gt;&lt;br&gt;
.&lt;br&gt;
We executed each command generated by this query individually to maintain precise control.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;Copy and Secure the Data Files:&lt;/strong&gt;&lt;br&gt;
.&lt;br&gt;
After discarding the old links, we carefully copied recovered .ibd files from the corrupt into the corresponding database folder on the new VM. It was crucial to set the right ownership for these files. Incorrect permissions would have prevented MySQL from accessing them.&lt;br&gt;
&lt;code&gt;/old/var/lib/mysql/&amp;lt;DatabaseName&amp;gt;/ # Source path on the corrupt disk&lt;br&gt;
chown mysql:mysql /var/lib/mysql/&amp;lt;DatabaseName&amp;gt;/*&lt;/code&gt;&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;Import the New Data (Tablespaces)&lt;/strong&gt;: With the .ibd files correctly positioned and permissions accurately configured, the next step was to instruct MySQL to use these new data files. This action successfully linked the table designs with their actual data, bringing them back online.&lt;br&gt;
&lt;code&gt;SELECT CONCAT('ALTER TABLE&lt;/code&gt;', TABLE_SCHEMA, '&lt;code&gt;.&lt;/code&gt;', TABLE_NAME, '&lt;code&gt;IMPORT TABLESPACE;') AS sql_command FROM INFORMATION_SCHEMA.TABLES &lt;br&gt;
WHERE TABLE_SCHEMA = &amp;lt;DatabaseName&amp;gt; AND ENGINE = 'InnoDB';&lt;/code&gt;&lt;br&gt;
.&lt;br&gt;
We executed the resulting commands sequentially for each table.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;Re-enable Database Rules&lt;/strong&gt;: Upon the successful import of all data, we promptly turned the foreign key checks back on. This restored the rules that maintain data consistency and integrity within the database for all future operations.&lt;br&gt;
.&lt;br&gt;
&lt;code&gt;SET FOREIGN_KEY_CHECKS = 1;&lt;/code&gt;&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;Addressing Advanced Recovery Challenges (Schema Mismatches):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A significant hurdle emerged when we discovered that 19 out of 127 tables of “Gitea’ had different designs. This was primarily due to recent updates to the Gitea application, which prevented a straightforward .ibd file restoration for these specific tables.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;Leveraging ibd2sql for Data Extraction:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For tables with schema discrepancies or where standard recovery methods were ineffective, we employed a specialized tool called ibd2sql. This utility is designed to parse InnoDB .ibd files and extract the contained data as SQL INSERT statements, even when a complete MySQL instance or .frm files are unavailable.&lt;br&gt;
&lt;code&gt;cd ibd2sql&lt;br&gt;
for path in $(realpath /old/var/lib/mysql/&amp;lt;DatabaseName&amp;gt;);&lt;br&gt;
 do python3 main.py $path --sql --ddl | mysql; done&lt;/code&gt;&lt;br&gt;
.&lt;br&gt;
Important Note: While ibd2sql is a powerful recovery tool, it may not fully support all complex data types, and we always recommend thorough post-recovery data validation.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
In instances where ibd2sql provided table designs that didn’t perfectly align with the current schema, manual intervention was required. We meticulously consulted the client’s application’s (Gitea’s) official database schema changelogs and migration scripts. These resources provided the precise Data Definition Language (DDL) for each table at various points in time, allowing us to accurately reconstruct the correct table definitions.&lt;br&gt;
.&lt;br&gt;
After carefully modifying the table designs to reflect the correct schema gleaned from the changelogs, we tested them. This involved creating temporary tables and performing small-scale data imports to ensure the design precisely matched the .ibd file structure and that data integrity was fully maintained. This meticulous manual process, combined with leveraging historical schema information, was crucial for successfully recovering data from files that initially seemed lost.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;Validation and Final Checks&lt;/strong&gt;&lt;br&gt;
1.System Integrity Checks: After all files were restored, we performed comprehensive checks to ensure the VM and all its applications were running correctly and without errors. This included verifying file integrity and system services.&lt;br&gt;
.&lt;br&gt;
2.Data Validation: For critical applications like the database and Gitea, we worked closely with the client to validate the restored data, ensuring its accuracy and completeness.&lt;br&gt;
.&lt;br&gt;
&lt;strong&gt;Key Takeaways&lt;/strong&gt;&lt;br&gt;
This incident, while challenging, served as a powerful catalyst for re-evaluating and fortifying our client’s data management strategies. Here are the refined best practices we’ve firmly integrated into our recommendations for them and other clients:&lt;br&gt;
.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Automated and Verified Backups&lt;/strong&gt;: We strongly advocate for and help implement a comprehensive, automated backup strategy for all critical VMs and their components (config, binaries, data). This includes a robust mix of full, incremental, and differential backups with clearly defined retention policies. Crucially, we emphasize regular verification of these backups through simulated test restores to ensure actual recoverability.
.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regular Snapshots&lt;/strong&gt;: We advise clients to consistently use VM snapshots before any significant system changes, updates, or routine maintenance operations. These are quick backups that let you go back to a previous state if something goes wrong immediately.
.
-&lt;strong&gt;Principle of Least Privilege&lt;/strong&gt;: We help clients set up and enforce strict access controls and permissions across all systems. By granting only the absolute necessary privileges to users and automated processes, we significantly mitigate the risk of both accidental and malicious data manipulation.
.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Immutable Backups&lt;/strong&gt;: We guide clients on exploring and implementing immutable backup solutions. These backups, by design, cannot be altered or deleted, providing a formidable defense layer against advanced threats like ransomware and inadvertent deletions.
.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Comprehensive Documentation&lt;/strong&gt;: We encourage clients to maintain meticulous and up-to-date documentation of all infrastructure components, detailed VM configurations, database schemas, precise backup procedures, and established recovery protocols. This documentation proves invaluable during crisis management, especially with larger teams.
.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regular Disaster Recovery Drills&lt;/strong&gt;: We recommend and assist clients in conducting periodic disaster recovery drills. These drills are essential for testing the efficacy of recovery plans, identifying any potential weaknesses in their processes, and ensuring their team is not only ready but proficient during actual incidents.
.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proactive Monitoring and Alerts&lt;/strong&gt;: We help clients set up robust systems that watch over their VMs and databases. They receive alerts for any unusual activities, critical disk space anomalies, or failures in backup processes. Catching problems early can prevent them from escalating into significant data loss events.
.
.
&lt;strong&gt;In Conclusion&lt;/strong&gt;
The VM data loss incident at our client’s site was undoubtedly a demanding experience, but it also proved to be a profound learning opportunity for both them and us. It underscored the critical importance of proactive prevention, meticulous planning, and the ability to maintain composure and execute methodically under pressure. Getting their data back successfully has strengthened their reliance on robust data management practices, and we are proud to have been their partner in this recovery. By implementing these reinforced best practices, we are confident that we can help our clients turn potential data catastrophes into manageable incidents, ensuring their services run smoothly and their data remains safe.``&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>virtualmachine</category>
      <category>backup</category>
    </item>
  </channel>
</rss>
