Setting Up My Homelab: A Journey Into Self-Sufficiency

As a tech enthusiast, I’ve always found the idea of building my own server environment at home fascinating. The idea of having full control over my data, creating a personal cloud, and experimenting with various applications is something that excites me both professionally and personally. So, I decided to take the plunge and set up my very own homelab. Here’s a look at the journey and how I made it happen.

The Hardware: Building the Base

For my homelab project, I needed something compact yet capable enough to handle the tasks I planned on running. After considering various options, I landed on the Intel Celeron NUC, which was one unused in my library. It’s small, efficient, and perfect for a home server setup. With 4GB of RAM and a 120GB SSD, it was ideal for my use case — no need for a massive server, just something reliable.

The beauty of the NUC is its minimal power consumption and tiny footprint. It doesn’t take up much space and won’t run up your electricity bill. This made it the perfect starting point for my lab. After getting the hardware in place, I decided to go with Debian 12 as the operating system. It’s a stable, lightweight OS that gave me the flexibility I needed to run various applications.

The Software: CasaOS and the Cloud VPS

Once I had the hardware ready, the next step was finding a way to manage all the services I wanted to run. I didn’t want something too complex, so I needed a simple and user-friendly interface. After doing some research, I discovered CasaOS, an open-source home server operating system. It offers an intuitive dashboard that lets you easily manage cloud storage, services, and applications. It was exactly what I needed to bring everything together.

However, there was a small problem: I didn’t have a public static IP at home, which meant accessing my homelab remotely would be tricky. To get around this, I subscribed to a cloud VPS to act as a bridge between my home network and the outside world. This VPS runs Debian 12 and offers 1 vCPU, 512MB of RAM, and 10GB of SSD storage. For just $3.5/month, it was an affordable solution that allowed me to access my lab remotely without any issues.

VPN Setup: Securing Connections with Netbird

Security is always a top priority, especially when you’re exposing your network to the internet. To ensure that my homelab remained safe, I decided to set up Netbird VPN. Netbird is an open-source VPN based on WireGuard, a fast and secure protocol that’s perfect for this type of setup.

With the VPN in place, I could securely connect to my homelab from anywhere without risking exposure to external threats. I configured the VPN on both the cloud VPS and my local machine, which gave me a secure tunnel to access all the services I was running. Now I had peace of mind knowing my data was safe and my connections were encrypted.

For completely free remote access to your homelab, you can use Twingate, which offers a personal plan free for one device—perfect for homelab setups. Click here to learn more about Twingate.

Final Touches and Running Services

After setting up the hardware, software, and security, it was time to get everything running. I began by experimenting with various services that could run smoothly on my homelab. From personal cloud storage to home automation tools, I wanted to make the most out of the setup. The beauty of using CasaOS was how easy it was to deploy apps like Nextcloud (for cloud storage), Jellyfin (for media streaming), and Pi-hole (for ad-blocking).

I could access everything remotely through the Netbird VPN, which meant I wasn’t tied to a single location. Whether I was at home or on the go, I could manage and monitor my services with ease.

Reflection: The Rewards of a DIY Homelab

Looking back at the process, setting up this homelab has been incredibly rewarding. Not only did I learn a lot about networking, security, and cloud management, but it also gave me full control over my own infrastructure. I now have a fully functional, secure, and remote-accessible homelab that meets all my personal and professional needs without relying on third-party services.

Even though the hardware is modest, the ability to experiment, learn, and have control over my setup has been invaluable. There’s something incredibly satisfying about knowing you’ve built something from scratch that works just the way you want it.

Looking Ahead

My homelab is still in its early stages, and I’m excited to expand it in the future. I plan to integrate more applications, experiment with automation, and scale up the setup as needed. One of my future goals is to upgrade to a more efficient and compact form factor machine—specifically, an HP EliteDesk 800 G5 High Performance Mini PC featuring an Intel Core i5 9th Gen processor, 16 GB DDR4 RAM, and a 256 GB NVMe SSD (refurbished). This device not only supports RAM upgrades up to 64 GB but also allows for storage expansion, making it an ideal candidate for running Proxmox VE, the open-source virtualization platform.

If you’ve ever considered building your own homelab, I highly recommend taking the plunge. It’s a fantastic way to develop new skills, explore emerging technologies, and gain a hands-on understanding of how systems operate behind the scenes. The possibilities are endless—and the best part? You’re in full control of your learning journey.

– Mahesh Palamuttath

Setting Up a WhatsApp HTTP API for Libraries: A Smart Way to Automate Communication

Disclaimer:
Whatsapp-web.js is not affiliated with, endorsed, or authorized by WhatsApp or its affiliates. "WhatsApp" and related marks are registered trademarks of their respective owners. Use of unofficial methods may lead to account blocks, as WhatsApp does not support bots or unofficial clients. For critical business use, we recommend official solutions like Twilio or the WhatsApp Business API. [!IMPORTANT] It is not guaranteed you will not be blocked by using this method. WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn't be considered totally safe.

WhatsApp is one of the most widely used messaging platforms today. With its ease of use and popularity among students and faculty, it has great potential for communication in libraries. However, WhatsApp does not provide a direct API for all users, especially for free. But with a bit of technical setup, it’s possible to create your own WhatsApp HTTP API that can send messages programmatically.

In this post, I’ll walk you through the benefits of setting up your own WhatsApp HTTP API using whatsapp-web.js and how it can be used effectively in a library context. A detailed step-by-step technical guide is linked at the end for those who want to set it up on their own server.

Why Use WhatsApp for Library Communication?

Libraries need to reach out to users regularly. This could be for reminding users about due dates, informing them about reserved book availability, sending workshop or event updates, or simply sharing links to library services. Traditional methods like email or printed notices are slow or often ignored.

On the other hand, WhatsApp messages are quick, direct, and more likely to be read. By automating WhatsApp messaging, libraries can save time and ensure users receive timely updates.

What is the WhatsApp HTTP API?

This is a self-hosted solution built using Node.js and a library called whatsapp-web.js. It simulates WhatsApp Web in the background and allows you to send messages via a simple HTTP POST request. That means other systems or tools (like your library management system or a Google Sheet) can send WhatsApp messages by making a request to your server.

This is not the official WhatsApp Business API but is ideal for academic or personal use cases where automation is needed.

Key Benefits for Libraries

Here are some practical advantages of using a WhatsApp HTTP API in libraries:

  • Automated notifications: Due dates, fines, or reservations can be notified instantly.
  • Higher engagement: WhatsApp messages have higher open and response rates compared to emails.
  • Seamless integration: Can be connected with systems like Koha ILS, Google Apps Script, or room booking systems.
  • User convenience: Users already use WhatsApp, so there’s nothing new for them to learn.
  • Low-cost solution: No recurring fees or vendor lock-in.

How to Set It Up

Setting this up involves:

  • Installing Node.js and Chromium on a Linux system (Debian/Ubuntu works well).
  • Using whatsapp-web.js to interact with WhatsApp Web.
  • Creating a basic Express server in Node.js.
  • Exposing an API endpoint like /send that accepts phone numbers and messages.
  • Running the server in the background using PM2 for reliability.

Once configured, sending a message is as simple as sending a POST request with the phone number and message content.

You can use tools like curl, Postman, or even Google Apps Script to make the API call. Here’s a simple example using curl:

curl -X POST http://localhost:3000/send \
-H "Content-Type: application/json" \
-d '{"number":"919567664972","message":"Hello from the library!"}'

This message will be delivered to the given WhatsApp number.

Want to Set This Up?

If you’re interested in trying this out for your own library or institution, I’ve created a complete configuration guide with step-by-step commands.

Read the full guide here: https://libtechnophile.blogspot.com/2025/05/how-to-set-up-whatsapp-http-api-for.html

Final Thoughts

This WhatsApp HTTP API is a simple yet powerful solution for modern library communication. It helps reduce workload, improves response times, and ensures better user engagement. With free and open-source tools, even small libraries can now offer professional-level digital communication.

If you have any questions or need help with implementation, feel free to get in touch. I’d be happy to help you get started.

MiniOS: A Lightweight Debian-Based Linux Distribution

MiniOS is a lightweight and efficient Linux distribution designed to offer flexibility and performance, especially on low-resource systems. Built on the solid foundations of Debian and MX Linux, MiniOS is suitable for both advanced users seeking full control over their environment and those who require a ready-to-use desktop system. This article explores MiniOS and its three main variants: Standard, ToolBox, and Ultra.

What is MiniOS?

MiniOS is a minimal Linux operating system that provides users with the essential tools to build, maintain, or use a complete system with minimal overhead. Its modular nature makes it suitable for a variety of use cases, including system recovery, education, and daily desktop usage.

MiniOS Variants

1. MiniOS Standard (Base OS: Debian)

This is the most minimal version of MiniOS. It is designed for users who prefer to construct their operating system from the ground up. The Standard edition provides only the essential components and a lightweight window manager such as Openbox or Fluxbox. It does not include pre-installed applications, offering maximum flexibility and customization.

2. MiniOS Toolbox (Base OS: MX Linux)

ToolBox is a utility-focused edition tailored for system maintenance, diagnostics, and recovery. It comes pre-installed with a range of essential tools such as GParted, Clonezilla, and other disk and network utilities. This edition is designed to run in live mode, making it portable and ideal for troubleshooting tasks.

3. MiniOS Ultra (Base OS: MX Linux)

Ultra is the most feature-rich variant of MiniOS. It includes a complete desktop environment and essential applications such as a web browser, media player, and file manager. Despite its functionality, Ultra remains lightweight and is optimized for use on older or low-spec hardware.

Variant Base OS Description Target Users
MiniOS Standard Debian Minimal system, highly customizable Developers, advanced Linux users
MiniOS ToolBox MX Linux Portable toolkit for system recovery IT professionals, sysadmins
MiniOS Ultra MX Linux Lightweight desktop with essential apps Home users, schools, libraries

MiniOS is a versatile Linux distribution that addresses diverse needs through its three tailored variants. Whether you are a developer needing a clean slate, a technician in search of a live recovery toolkit, or an end user looking for a responsive desktop on older hardware, MiniOS provides a reliable and efficient solution. Its Debian and MX Linux base ensures stability and compatibility while maintaining a small footprint.

To learn more or to download MiniOS, visit the official website: https://minios.dev

Home Lab: Building Your Tech World from Home

In this modern era, technology has become an inseparable part of our daily lives. For IT professionals, software developers, and anyone interested in learning new things, setting up a home lab can be extremely beneficial for gaining knowledge and conducting new experiments. Let’s examine what a home lab is and why you should own one.

What is a Home Lab?

Simply put, a home lab is a setup in your home where you run your own computer servers or networked computers for personal use. This doesn’t have to be a large server system. It can even be set up using an old laptop or a compact mini PC. Primarily, it’s a self-controlled space where you can install software, configure networks, and test various operating systems without affecting your main computer.

Why Should You Own a Home Lab?

There are many reasons to set up a home lab:

  • Excellent Way to Learn: A home lab is very helpful for in-depth learning about technologies like Linux, networking, and virtualization. It allows you to experiment with new things and learn from your mistakes without causing any damage to your primary computer.
  • Platform for Innovation: IT professionals and system administrators can test the possibilities and limitations of new tools or ideas in their home lab before implementing them in their professional environment.
  • Cost-Effective Tech Solutions: Instead of paying large sums for cloud-based services, you can host many services yourself. Setting up your own media server or personal cloud storage can provide long-term financial benefits.
  • Privacy and Control: You gain complete control over your information and data. This helps you avoid over-reliance on commercial cloud services and ensures your privacy.
  • A Rewarding Hobby: For individuals interested in technology, building and modifying a home lab can become an enjoyable hobby. It helps you gain new knowledge and develop your technical skills.

What Can You Do in a Home Lab?

The possibilities of a home lab are endless. Here are some common uses:

  • Media Server: Store all your movies, music, and pictures in one place and access them from any device (using software like Plex or Jellyfin).
  • Development Servers: Create a dedicated environment to develop and test websites and applications.
  • Video Surveillance System: Set up your own security surveillance system at a low cost (using open-source tools like ZoneMinder or Shinobi).
  • Remote Desktop Access: Remotely access your office computer or other devices from home (using tools like Apache Guacamole).
  • Personal Cloud: Host your own files, calendars, and contacts (using software like Nextcloud or ownCloud).

What Do You Need to Get Started?

You don’t need the latest and most powerful hardware to start a home lab. An old laptop, a Raspberry Pi, or a small mini PC will suffice. Install any Linux distribution on it (Ubuntu and Debian are suitable for beginners). Then, you can start experimenting using virtualization tools (VirtualBox, Proxmox VE) or containerization tools (Docker).

For beginners, operating systems like CasaOS and ZimaOS can help simplify home lab management. They make setting up servers and installing applications very easy.

A home lab is an excellent way to understand technology more deeply, learn new things, and create your own digital world from the comfort of your home. Whether you are a student, an IT professional, or just someone interested in technology, a home lab will undoubtedly open new doors for you. By setting up your own home lab, you can gain new knowledge every day and improve your technical skills.

Digitizing Library Archives with Paperless NGX: A Game-Changer for Searchable PDFs

Libraries, as we know, have always been keepers of knowledge—both past and present. But what happens when that knowledge is locked away in file cabinets, old scanned documents, or decades of paper-based reports and notices? That’s the challenge we faced in our library too.

We’ve had a growing pile of digitized content—meeting minutes, handwritten letters, internal circulars, scanned newspaper clippings—you name it. While scanning these into PDFs was a start, they weren’t really useful. Sure, they were “digital,” but they weren’t searchable. And for a library, that’s a big limitation.

That’s when I came across Paperless NGX.

What is Paperless NGX?

Paperless NGX is a free, open-source document management system. It’s designed to help organize, tag, and store documents in a way that’s both efficient and future-friendly. But what caught my attention—and eventually won me over—is its built-in OCR (Optical Character Recognition) capability.

This isn’t just some add-on. It’s part of the core experience. Once a document is uploaded—be it a PDF, a scanned image, or even a photo of a document—Paperless NGX quietly processes it using a tool called ocrmypdf.

And here’s the best part:

Even images converted into PDFs get a hidden text layer that becomes fully searchable.

Yes, even that scanned, handwritten note from 2005 with faded ink can be indexed and searched. That’s powerful.

Why It Matters for Libraries

For libraries, this changes everything. Many of us are working with physical archives—some of which have already been scanned, others waiting to be digitized. Until now, those scans were mostly just static images in a digital wrapper. We could store them, but searching through them meant opening files one by one.

With Paperless NGX, the workflow is different:

  • Upload the document.
  • It automatically runs OCR in the background.
  • It becomes searchable by its actual content.

Is It Hard to Set Up?

Not at all. If you’re familiar with Docker, the developers have made it incredibly simple with an installation script. Within minutes, we had it running on a spare Ubuntu server. You just choose your database (SQLite works great for starters), set your folders, and it’s ready to go.

Of course, there’s room to grow:

  • You can tag documents
  • Organize by type or date
  • Set up folders to automatically watch and import documents
  • Even configure workflows and email-based imports

But even with the basic setup, it’s more than enough to start building a searchable digital archive.

If your library is thinking about building a digital archive, or if you’re sitting on a mountain of scanned files that no one really wants to open one by one, give Paperless NGX a try.

It’s not just about going paperless—it’s about making what you already have more useful, more accessible, and more alive.

Want help getting started? Feel free to reach out—I’d be happy to share tips from our own setup.

– Mahesh Palamuttath

Why Every Higher Education Institution Should Subscribe to the “In-Out Plus”

In the day-to-day functioning of educational institutions, communication is a cornerstone. Whether it is notifying students of a last-minute class cancellation, sending a gentle reminder about a library book due date, or coordinating a campus-wide event, the process often becomes fragmented and difficult to manage.

Many institutions still rely heavily on WhatsApp, email, or physical notice boards, which are either not centralised, difficult to track, or simply ineffective. The “In-Out Plus” App by PlayTech offers a robust alternative. It is a centralised and secure mobile application designed specifically for colleges and universities to streamline communication, notifications, library updates, and even campus gate registers.

Key Features and Benefits

1. Unlimited Push Notifications

The app supports unlimited push notifications which can be sent to individuals, groups, departments, or the entire institution. Notifications are trackable, so senders can view delivery status and reporting. This feature eliminates the need for bulk SMS or third-party messaging tools. The app also provides ready-to-use templates, making it easy to send structured messages quickly.

2. Koha LMS Integration

For institutions using the Koha Library Management System, In-Out Plus offers a seamless and secure integration. OPAC can be accessed directly through the app. Students and staff receive real-time push notifications for check-outs, check-ins, due date reminders (2 days before, 1 day before, and on the due date), renewals, and fines.

Importantly, this integration works without exposing the Koha system or its database to the internet. There is no need for a static IP or cloud deployment, which addresses common concerns regarding data privacy and infrastructure costs.

3. Campus Feed and Community Module

The app includes a centralised feed system where moderated posts and polls can be shared with the campus community. Departments, clubs, extracurricular groups, and academic units can create their own spaces (called “Squads”) to post updates and conduct polls.

Students can join public groups or be invited to private ones. This controlled environment enables collaboration and information sharing while keeping communication professional and focused. Students cannot comment on posts, ensuring that content remains distraction-free and relevant.

4. Gate Register System

The gate register feature simplifies the process of managing library and campus entries. Previously dependent on Koha and additional infrastructure (computers, barcode scanners, etc.), institutions can now manage visitor logs directly through the app.

Each student or staff member can check in or out using their mobile device, and new locations can be added by simply printing a barcode generated by the app. All location data can be managed via a single dashboard, and users can view their own visit reports directly from the app.

5. Virtual Achievement Board

Recognising student achievements can have a significant impact on motivation and campus spirit. The In-Out Plus App includes a virtual achievement board where institutions can highlight awards, recognitions, and contributions from students, fostering a culture of encouragement and visibility.

Why It Matters

Educational institutions often face the challenge of managing multiple communication channels while trying to maintain efficiency and oversight. The In-Out Plus App by PlayTech addresses this challenge by bringing all communication, notifications, library updates, and entry logs into a single, cohesive mobile application.

It replaces disjointed systems with a structured, accountable, and private platform that benefits administrators, faculty, students, and parents alike.

The In-Out Plus App is a practical solution for any library or higher education institution aiming to modernise its communication systems without compromising on data privacy or incurring heavy infrastructure costs. It offers everything an academic campus needs to stay connected, organised, and efficient.

For more details or to request a demonstration, institutions can contact:

Mahesh Palamuttath
Library Technologist
Mobile: +91 9567 664 972
Email: mail@maheshpalamuttath.info

A Sweet Goodbye: Wrapping Up the 4th Batch of DLA

Yesterday marked the informal end of the 4th Batch of the Diploma in Library Automation (2024–25) at the Department of Library and Information Science, Rajagiri College of Social Sciences (Autonomous), Kochi, and I’m still processing the whirlwind of emotions and memories that came with it.

This batch was something special. Not only were you all fully present and enthusiastic learners, but you were also warm, kind, and full of life. The last day was proof of that, from the surprise cake-cutting ceremony to a thoughtful feedback session, and yes… the sweet gift you gave me, a lovely watch (and if you know me, you know how much I adore wearing watches!).

These small gestures speak louder than words. They’re not just tokens, they’re memories that I’ll hold close for a very long time.

And naturally, we froze the moments, smiles, group shots, and laughter that now exist both in our hearts and in pixels.

What made this batch even more lively was the diversity it brought. There were 6 participants from Tamil Nadu out of the total 30. It was a pleasure to meet each one of you and to witness how all of you embraced every bit of the course, from Linux fundamentals to Koha, DSpace, Cloud Technology, and everything in between.

As a trainer, nothing makes me happier than knowing you’ve got everything you need for a tech-driven librarianship journey. You’ve equipped yourselves not just with tools, but with a mindset of innovation, and that’s powerful.

To each one of you: thank you.

For being learners, contributors, and most of all, wonderful human beings.

With appreciation,
Mahesh Palamuttath

Snapshots

Self-Host Your Own Tunneled Reverse Proxy Server – Pangolin

In today’s digital landscape, secure and efficient remote access is crucial for self-hosted applications. Many users rely on cloud-based solutions like Cloudflare Tunnel, Ngrok, or Tailscale. However, for those who prioritize self-hosting and control over their infrastructure, Pangolin offers a powerful open-source alternative. Pangolin allows users to set up a tunneled reverse proxy server while maintaining privacy and security. In this blog post, we’ll guide you through installing and configuring Pangolin on a Linux server.

Prerequisites

Before you begin, ensure you have the following:

  • A Linux VPS running a recent version of Debian, Ubuntu, or another supported distribution.
  • A domain name that you control.
  • Access to your domain’s DNS settings to create required records.
  • A public IP address assigned to your VPS.
  • Docker Installed
  • Basic knowledge of Linux commands and SSH access to your server.

Step 1: DNS Record Setup

Before installing Pangolin, you need to configure your DNS settings. In your DNS service, create A (or AAAA for IPv6) records pointing at your VPS hosting Pangolin.

Wildcards

You will need a wildcard subdomain for each level you want to create, and many providers do not support multiple consecutive wildcards. For example, if you want your resource’s domain to be app.example.com, then you should create *.example.com.

If you plan to use a base domain for a resource, you will need to create a separate A record for that domain.

The Root

If you intend to use the root of your domain, then you need an additional A record pointing at the IP of your VPS. For example, if you want to use example.com as a resource, you must create an A record for example.com pointing at your VPS.

Step 2: Install Docker

wget gist.githubusercontent.com/maheshpalamuttath/f454a85ca8704d75de5c7fb2eb803f61/raw/fd8e600eaee2845b716c28f6e15e12227eae21a6/install_docker.sh

sudo chmod +x install_docker.sh

sudo ./install_docker.sh

Step 2: Download and Install Pangolin

To install Pangolin, execute the following command in your terminal:

mkdir -p docker/pangolin

cd docker/pangolin

wget -O installer "https://github.com/fosrl/pangolin/releases/download/1.1.0/installer_linux_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')" && sudo chmod +x ./installer

sudo ./installer

The above command downloads the appropriate installer for your system architecture, grants execution permissions, and runs the installer.

Step 3: Basic Configuration

During installation, the setup wizard will prompt you for basic configuration details:

1. Define Base and Dashboard Domain Names

  • Base Domain Name: Enter your root domain (e.g., example.com).
  • Dashboard Domain Name: Specify the subdomain where Pangolin will be hosted (e.g., pangolin.example.com).

2. SSL Certificate Setup

Provide an email address for Let’s Encrypt SSL registration. Ensure you have access to this email.

3. Admin User Setup

You’ll be asked to create an admin user. Provide:

  • Admin Email: (e.g., admin@example.com)
  • Admin Password: Ensure it meets security requirements (at least 8 characters, including uppercase, lowercase, numbers, and special characters).

4. Security Settings

Signup Without Invite: Choose whether users can sign up without an invite (recommended to keep disabled for private deployments).

Organization Creation: Allow or restrict users from creating their own organizations.

Step 4: Email Configuration (Optional)

To enable email notifications and verification requests, configure SMTP settings:

  • SMTP Host: Your mail server hostname
  • SMTP Port: Default is 587
  • SMTP Username: Your email username
  • SMTP Password: Your email password
  • No-reply Email: The email address used for outgoing messages

Step 5: Finalizing Setup

Once the installation is complete, restart the Pangolin service:

sudo systemctl restart pangolin

Then, open your browser and visit https://pangolin.example.com to log in with your admin credentials.

Reference: https://docs.fossorial.io/Getting%20Started/quick-install

My First WordCamp Kerala: More Than Just a Tech Conference

On November 9, 2024, I had the opportunity to attend my first WordCamp Kerala, a WordPress conference that was nothing short of extraordinary. It’s funny to think that, despite using WordPress for the past five years, this was my first time immersing myself in the vibrant WordPress community in person. The excitement was palpable, and the day was filled with insights, connections, and newfound inspiration.

The ticket for the event was reserved by Manoj Karingamadathil, a digital humanitarian and open-access activist whose multifaceted work greatly inspired me. Manoj’s dedication to biodiversity conservation, the preservation of classical Malayalam literature, and his advocacy for free and open-source software deeply align with the values I cherish.

Manoj’s connection to my world runs deeper than just our shared interests. He is the life partner of Jameela P., a Library and Information Assistant at the Indian Naval Academy and someone I’ve exchanged ideas with over the years. Even though I haven’t had the chance to meet Jameela in person yet, I feel a sense of kinship with her and look forward to future programs where we might finally connect face-to-face.

Another remarkable individual I met was Kunjappy. The moment I saw him, I was reminded of my sadu (my sister’s son), with his boundless energy and a spirit that seemed as unstoppable as a revving engine ready to conquer new horizons. It’s amazing how meeting people like Manoj reminds me of the importance of simplicity and shared vibes.

Attending WordCamp Kerala wasn’t just about learning the latest in WordPress development and community engagement. It became a moment of realization: as a library professional, my contributions may be meaningful, but there is also so much more to be done as a citizen of this world. Being surrounded by people who actively work toward a better society has reignited a spark in me to think beyond the boundaries of my profession.

Reflecting on this experience, I feel incredibly grateful. The WordCamp Kerala event wasn’t just a gathering of WordPress enthusiasts but a confluence of individuals who are passionate about making a difference.

Snapshots from #WordCampKerala2024

Automating WordPress Backups with a Shell Script

In the digital age, data is invaluable, especially for websites that rely on content management systems like WordPress. Regular backups are essential to safeguard your website against data loss due to various reasons, including server failures, malware attacks, or accidental deletions. In this post, we’ll walk through a shell script designed to automate the backup process for a WordPress site, ensuring you have secure copies of your database and files.

Why Backup Your WordPress Site?

Backups serve as your safety net. They allow you to quickly restore your site to a previous state in case of issues. Here are some key reasons to regularly back up your WordPress site:

  • Data Loss Prevention: Accidental changes or deletions can happen. A backup allows you to revert to a working version.
  • Malware Recovery: If your site gets compromised, having a clean backup is crucial for recovery.
  • Server Failures: Hardware or software failures can lead to data loss. Backups ensure you can restore your site.

The Backup Script

Here’s a breakdown of a simple yet effective backup script for a WordPress site:

#!/bin/bash

# 1: Define backup filenames with timestamps.
db_backup_name="wp-db-backup-$(date +%d-%m-%Y-%H.%M).sql.gz"
wpfiles_backup_name="wp-content-backup-$(date +%d-%m-%Y-%H.%M).tar.gz"

# 2: Database connection info.
db_name="wordpress"
db_username="wordpress"
db_password="wordpress123"

# 3: Path to WordPress root directory and wp-content.
wp_root_folder="/var/www/html/wordpress"
backup_folder_path="/home/mahesh/backups/wordpress"

# 4: Backup MySQL database.
mysqldump --opt -u"$db_username" -p"$db_password" "$db_name" | gzip > "$backup_folder_path/$db_backup_name"

# 5: Navigate to WordPress root and create a tarball of wp-content only.
cd "$wp_root_folder" || exit
tar -czf "$backup_folder_path/$wpfiles_backup_name" wp-content

# 6: Delete all but 3 most recent database backups.
find "$backup_folder_path" -maxdepth 1 -name "*.sql.gz" -type f -printf "%T@ %p\n" | sort -rn | awk 'NR>3 {print $2}' | xargs -r rm --

# 7: Delete all but 3 most recent wp-content backups.
find "$backup_folder_path" -maxdepth 1 -name "*.tar.gz" -type f -printf "%T@ %p\n" | sort -rn | awk 'NR>3 {print $2}' | xargs -r rm --

Download the Script: gist.githubusercontent.com/maheshpalamuttath/482f1e43bc170d822fc4b19f368cd655/raw/8e2e96e40b2159aece20b6a0143f9383723b8317/wp-backup.sh

Breakdown of the Script

1. Defining Backup Filenames
The script starts by defining the names for the backups with a timestamp, ensuring that each backup is uniquely named. This prevents any accidental overwriting of existing backups.

db_backup_name="wp-db-backup-$(date +%d-%m-%Y-%H.%M).sql.gz"
wpfiles_backup_name="wp-content-backup-$(date +%d-%m-%Y-%H.%M).tar.gz"

2. Database Connection Information
Next, the script defines the database connection information, including the database name, username, and password. This allows the script to connect to the MySQL database to create a backup.

db_name="wordpress"
db_username="wordpress"
db_password="wordpress123"

Security Note: It is advisable to avoid hardcoding sensitive information directly into scripts. Consider using environment variables or a configuration file that has restricted access.

3. Specifying Directories
The paths to the WordPress root directory and the backup location are specified. This ensures that the script knows where to look for the files to back up and where to store the backup files.

wp_root_folder="/var/www/html/wordpress"
backup_folder_path="/home/sasc/backups/mahesh/wordpress"

4. Backing Up the MySQL Database
The mysqldump command creates a backup of the WordPress database, compressing it with gzip to save space. The output is redirected to a file named based on the current timestamp.

mysqldump --opt -u"$db_username" -p"$db_password" "$db_name" | gzip > "$backup_folder_path/$db_backup_name"

5. Creating a Tarball of wp-content
The script changes the directory to the WordPress root and creates a tarball of the wp-content directory, which contains all your themes, plugins, and uploaded files.

cd "$wp_root_folder" || exit
tar -czf "$backup_folder_path/$wpfiles_backup_name" wp-content

6. Cleaning Up Old Backups
To manage disk space, the script includes commands to delete old backups, keeping only the three most recent database backups and wp-content backups.

find "$backup_folder_path" -maxdepth 1 -name "*.sql.gz" -type f -printf "%T@ %p\n" | sort -rn | awk 'NR>3 {print $2}' | xargs -r rm --
find "$backup_folder_path" -maxdepth 1 -name "*.tar.gz" -type f -printf "%T@ %p\n" | sort -rn | awk 'NR>3 {print $2}' | xargs -r rm --

To set up this backup script on your server to run at regular intervals, you can use cron, the default job scheduler on Linux. Here’s a step-by-step guide:

Save your backup script with a .sh extension in a location that you can access. For example:

sudo su
vim /usr/local/bin/wp_backup.sh

Copy the script into this file, save it, and exit.

Give the script execute permissions so it can run:

chmod +x /usr/local/bin/wp_backup.sh

Run the script manually to ensure it works as expected:

/usr/local/bin/wp_backup.sh

If there are any errors, they should show up now, and you can troubleshoot as needed.

Use cron to automate the backup process. To edit the cron jobs:

crontab -e

Add a new line at the end of the file to specify when you’d like the backup to run. For example, to run the backup script every day at 2:00 AM, add this line:

0 2 * * * /usr/local/bin/wp_backup.sh >> /home/sasc/logs/wp_backup.log 2>&1

This command means:

0 2 * * * - Run at 2:00 AM every day.
/usr/local/bin/wp_backup.sh – Path to your backup script.
>> /usr/local/bin/logs/wp_backup.log 2>&1  – Save output and errors to a log file for troubleshooting.

If you’re using a log file, create a directory for it (Optional):

mkdir -p /usr/local/bin/logs

After adding the cron job, you can verify it with:

crontab -l

Your backup script is now set to run automatically on your server specified interval!

Use Rclone for Synching backup files into Google Drive: https://libtechnophile.blogspot.com/2020/07/using-google-drive-on-debianubuntu-with.html

Automating your WordPress backups with a shell script is a practical solution to ensure your data is safe and easily restorable. By regularly running this script, you can avoid the headaches of data loss and keep your site secure. Remember to periodically check your backup files and test the restoration process to ensure everything works as expected.