Backup and Restore Linux OS with Rsync

ryantehhoonmeng

Ryan Teh Hoon Meng

Posted on April 8, 2024

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!

💖 💪 🙅 🚩
ryantehhoonmeng
Ryan Teh Hoon Meng

Posted on April 8, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related