Last active
July 30, 2023 00:45
-
-
Save jrwarwick/c00169eceef30e77cd44a433729d0e87 to your computer and use it in GitHub Desktop.
Backup verification script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lets say you are backing up to external media like a usb hardisk drive. once in a while, you should restore the backup to an alternate location and verify and validate the restorability and fidelity of the backup. | |
# Following a mass file restore from backup to alternate location, perform comparison with original to confirm the backup is good and restorable | |
#On test restore host: | |
# zpool create -f tank /dev/sdb | |
# zpool list | |
mount /dev/sdc1 /mnt/bup/ #where sdc1 is the device for the external usb hdd you just plugged in | |
ls /mnt/bup | |
ls /mnt/bup/originhostname/ | |
ls -lFh /mnt/bup/originhostname/originhostname.garage.zfs | |
cat /mnt/bup/orignhostname/originhostname.garage.zfs | zfs receive -Fdu tank | |
zfs list tank -o mountpoint | |
MOUNT_POINT=$(zfs list tank -o mountpoint | tail -1) | |
mkdir -p $MOUNT_POINT | |
zfs mount tank | |
cd $MOUNT_POINT | |
zfs status | |
find `pwd` > /tmp/all_zfs_restored.txt | |
shuf /tmp/all_zfs_restored.txt | tail -1000 | sed -e 's/^/"/' -e 's/$/"/' | xargs md5sum > /tmp/backup_restore_samples.txt 2>/dev/null | |
scp /tmp/backup_restore_samples.txt $USERNAME@originhost:/tmp | |
# IF os has fancy modern gnu md5sum: | |
##ssh $USERNAME@originhost "md5sum --check /tmp/backup_restore_samples.txt > /tmp/backup_restore_verify.log ; cat /tmp/backup_restore_verify.log | grep -v ' OK$'" | |
# ELSE | |
#now on originhost: | |
cat /tmp/backup_restore_samples.txt | awk '{print $2}' | sed -e 's/^/"/' -e 's/$/"/' | xargs md5sum > /tmp/originals_hashes.txt | |
##maybe... diff /tmp/originals_hashes.txt /tmp/backup_restore_verify.log | |
cat originals_hashes.txt | awk '{print $2}' | xargs -J % grep -h % originals_hashes.txt backup_restore_samples.txt | |
#maybe someway to only show those that don't have matching twin lines |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment