DEV Community

Ryan Teh Hoon Meng
Ryan Teh Hoon Meng

Posted on

2

Backup and Restore Linux OS with Rsync

As a Software Engineer tackling challenges in the realm of Software Engineering, I recently encountered the task of efficiently backing up and restoring an Ubuntu OS running on a Single Board Computer (SBC). This seemingly straightforward task proved to be more complex than anticipated, requiring a solution tailored to the unique constraints of SBCs.

Initially, my approach involved exploring tools like Clonezilla for creating OS images. However, the nature of SBCs presented compatibility hurdles that made this traditional method less viable. Fortunately, my search led me to an invaluable resource on GitHub—specifically, the BackupJetson repository.

Inside this repository, I discovered two shell scripts, backup-rootfs.sh and restore-rootfs.sh, designed to streamline the backup and restoration process using Rsync. Rsync, a powerful file-syncing tool, proved to be the linchpin of this solution, offering efficient snapshot creation and restoration capabilities suited for SBC environments.

To put these scripts to the test, I executed sudo bash backup-rootfs.sh -d /recovery/ to generate a root filesystem snapshot within the designated /recovery/ directory. With this baseline in place, I deliberately disrupted the OS—tampering with SSH keys, uninstalling and installing packages—to simulate a compromised state.

With the system in disarray, I then invoked sudo bash restore-rootfs.sh -d /recovery/backup-rootfs-04-08-2024/ and initiated a reboot. This step was crucial, as it allowed for the full restoration of services and configurations essential for the OS's functionality.

Upon reboot, I was delighted to find the OS had reverted to its original, pristine state captured during the backup. This seamless restoration underscores the efficacy of the Rsync-based solution.

In conclusion, the journey to streamline OS backup and restoration on Single Board Computers has been both enlightening and rewarding. Through tools like Rsync and the BackupJetson repository, the once-daunting task of managing OS snapshots on SBCs has become accessible and efficient—a testament to the ingenuity and collaborative spirit of the open-source community.


As a Software Engineer with several years of experience, I often encounter challenges that require unique, context-specific remedies. By sharing these insights through blogging, I aim to contribute to the collective knowledge of the developer community while creating a personal repository of proven strategies.

Stay tuned for more insights and solutions as I continue to explore the fascinating intersection of software engineering and embedded systems!

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay