Avoiding data corruption in backups
Alternatives
There are a number of alternatives with a long, successful history in the field of integrity verification.
AIDE, a host-based intrusion detection system, can be repurposed for verifying the integrity of the files in a given folder [3].
You can use mtree
, a popular program from the BSD world, to verify that the contents of a directory tree match a specification. For example, mtree
could be used to create a specification file from a folder containing known good data:
$ mtree -c -k md5digest -p Foals > /var/specification
Then, you can verify the contents of Foals
against the specification file with:
$ mtree -f /var/specification -p Foals
mtree
isn't popular in the Linux ecosystem, but you can find it in some repositories [4].
Finally, bitrot
, a python script, can locate files damaged because of hardware defects. While it does not locate files lost because of human error or certain sorts of software error, it is very easy to set up and run despite its limited nature. If you are interested in using bitrot
, I recommend reading SolËne Rapenne's tutorial [5].
Limitations
Creating a checksum of every file within the folder you intend to backup is time consuming. For datasets that are larger than a couple of terabytes, the process may take more than half an hour.
Generating a checkum file and verifying it against the previous checksum file before each backup is only practical if the data being backed up doesn't change often. If you try this approach with a busy folder, comparing both checksum files will throw more differences than it would be reasonable to verify manually. For this reason, I recommend this method for folders which don't change often, such as directories full of family pictures or ebooks, in which files are usually added but rarely modified or removed.
Should it be necessary to verify the integrity of a folder whose contents change frequently, then I recommend using bitrot
, because this tool only throws warnings for files whose checksum have changed but which have not suffered any changes to their modification times.
Conclusions
Having multiple backups of your data and keeping old versions of your files are great measures for preventing data loss, but they are not enough. In order for a backup strategy to work, you must be able to verify that your backup files are uncorrupted.
While many tools exist for verifying the integrity of your data, you don't need a complex solution. The coreutils package lets you manage moderate amounts of data.
Ultimately, discipline is the most important factor when it comes to data integrity. You need to define a routine and stick to it. This, in my experience, is where most users fail.
Infos
- rsync: https://rsync.samba.org
- ZFS: https://docs.freebsd.org/en/books/handbook/zfs/
- "Detect evidence of break-in attempts with host-based intrusion detection systems" by Tobias Eggendorfer, Linux Magazine, issue 183, February 2016: https://www.linux-magazine.com/Issues/2016/183/Host-Based-IDS
- NetBSD's version of mtree: https://repology.org/project/mtree-netbsd/versions
- SolËne Rapenne's bitrot tutorial: https://dataswamp.org/~solene/2017-03-17-integrity.html
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.
-
ZorinOS 17.1 Released, Includes Improved Windows App Support
If you need or desire to run Windows applications on Linux, there's one distribution intent on making that easier for you and its new release further improves that feature.
-
Linux Market Share Surpasses 4% for the First Time
Look out Windows and macOS, Linux is on the rise and has even topped ChromeOS to become the fourth most widely used OS around the globe.
-
KDE’s Plasma 6 Officially Available
KDE’s Plasma 6.0 "Megarelease" has happened, and it's brimming with new features, polish, and performance.
-
Latest Version of Tails Unleashed
Tails 6.0 is based on Debian 12 and includes GNOME 43.
-
KDE Announces New Slimbook V with Plenty of Power and KDE’s Plasma 6
If you're a fan of KDE Plasma, you'll be thrilled to hear they've announced a new Slimbook with an AMD CPU and the latest version of KDE Plasma desktop.
-
Monthly Sponsorship Includes Early Access to elementary OS 8
If you want to get a glimpse of what's in the pipeline for elementary OS 8, just set up a monthly sponsorship to help fund its continued existence.