Checking you backup with hashdeep II
|The first part of the article covered the general use of Hashdeep and the creation of files containing all hash values. Today, we’re talking about checking backups on OpenMediaVault and external drives.
Daily Backup and Daily Comparison
The NAS is used daily, including to back up my LXC containers or virtual machines, for example. As part of this backup of multiple computers from the network, a year’s worth of photos is also checked with Hashdeep, i.e., an audit is performed (lines 28-36 of the script). A complete audit would take too long.
The output then arrives via email as usual with a cron job, so I can see whether the audit was successful or not. With DNG or TIFF files, changes are written to the file, so the checksum no longer matches. This is unfortunate, but it can’t be changed.
Sometimes, if you know that the changes are due to the files in question being edited in Lightroom, for example, you have to restart the generation of hashes for the respective year.
Checking external backups from USBbackup
In addition to the backup on the NAS with a ZFS file system, I back up photos and video clips to external hard drives every day using the USBbackup plugin.
For this purpose, I’ve been using an Icy Box enclosure for some time now, which holds four standard 3.5-inch hard drives. Two of the drives are for photos, one for videos, and the fourth for backups of the virtual machines with Proxmox.
There’s also a third hard drive for photos, which is swapped with one of the existing hard drives every Monday, so I have three copies.
But how can I check these backups? The USB backup plugin, for example, doesn’t have the option to integrate hook scripts like Proxmox Backup. However, since a script is created for virtually every disk used, there’s a way around this, albeit not as elegantly.
The /var/lib/openmediavault/usbbackup.d directory contains the systemd files that actually call rsync. This could be, for example, a service file like openmediavault-usbbackup-0ba376885cded2fab832bf1cb0828ecc.service.
[Unit]
Description=Execute the rsync backup jobs when /dev/disk/by-uuid/4d554c2d-93cb-4f8d-9b00-8a541eb2217f is plugged in
BindsTo=dev-disk-by\x2duuid-4d554c2d\x2d93cb\x2d4f8d\x2d9b00\x2d8a541eb2217f.device
After=local-fs.target dev-disk-by\x2duuid-4d554c2d\x2d93cb\x2d4f8d\x2d9b00\x2d8a541eb2217f.device
Requisite=local-fs.target dev-disk-by\x2duuid-4d554c2d\x2d93cb\x2d4f8d\x2d9b00\x2d8a541eb2217f.device
[Service]
Type=oneshot
RemainAfterExit=false
ExecStart=/root/bin/foto2.sh
#/var/lib/openmediavault/usbbackup.d/systemd-0ba376885cded2fab832bf1cb0828ecc
[Install]
WantedBy=dev-disk-by\x2duuid-4d554c2d\x2d93cb\x2d4f8d\x2d9b00\x2d8a541eb2217f.device
And there, I have the call in ExecStart for each disk separately on my directed by a separate script. This script calls the original usbbackup backup and then calls Hashdeep after the corresponding hard drive has been mounted.
#!/bin/bash
#!/bin/bash
# $Id: foto2.sh 328 2025-01-07 17:31:10Z pm $
# $Rev: 328 $
# $Author: pm $
##################################
/var/lib/openmediavault/usbbackup.d/systemd-0ba376885cded2fab832bf1cb0828ecc
DOW=$(date +%u)
# the next 2 scripts are executed on 1 and 4
if [ $DOW -eq 4 ]; then
sleep 1m
outfile=/var/log/hashdeep.log
# outfile=$(mktemp)
/root/bin/wrapper.sh usb-foto "/dev/disk/by-uuid/4d554c2d-93cb-4f8d-9b00-8a541eb2217f" "/root/foto2" | tee ${outfile}
mail -E -s "Fotos 2 hashdeep" -a "From: <root>" root <${outfile}
# rm ${outfile}
fi
Here, the Rsync backup is first called as part of the actual USB backup process, followed by my wrapper script, which then performs an audit of the hashes on the then mounted USB drive. I know it’s not very elegant, but it works. Since these scripts are only called on certain days of the week and, as already mentioned, the backup disks also rotate, all years and all three disks should normally be checked after a little over a year.
Conclusion
With these scripts, I get additional security for the photos and video clips when it comes to backups. Even if it seems cumbersome, it’s worth it to me, if only for all the memories attached to them (there are a few good photos, of course 😉
ciao tuxoche