Recovering from disaster

So running a cron with the above daily should be sufficient to keep the documentation in place?

Out of curiosity though, why daily?? why not just a once off and then refer back to it? All we really need is the partition breakdowns and keep it stored somewhere? Why run it daily?

1 Like

Itā€™s a lightweight cron job that takes virtually no CPU or memory and just ensures the data is bang up to date, even if you change something and forget to document. Furthermore, depending upon your backup regime it ensures that the file is caught by every backup, and therefore can be found by looking in the latest backup whether full, incremental, differential or rsync.
Itā€™s something I developed when I was running big multi-user machines before I retired. Try working out how you had configured around 100 spindles spread over 10 diskfull and 30 diskless nodes with 4 hardware RAID controllers on a SAN as quickly as possible. I never actually needed it in anger, but like a tightrope walkerā€™s safety net I was glad it was there!

(edit) One other point that I should have mentioned: I hope itā€™s obvious, but TEST before disaster. Donā€™t rely upon anything you havenā€™t tested. Can you read you backups on another machine for instance?

2 Likes

So I assume you just overwrite the file daily? You donā€™t create new files alongside the previous files. Iā€™m only mentioning this for clarity.

Backups could retain earlier versions.

Iā€™m referring to the daily cron that @MartinR executes. My question is more to ascertain whether he appends to the same file, overwrites the existing file or creates separate files daily.

Yes, overwritten daily. It therefore reflects the configuration from which the backups come. It really is the simplest of scripts:

#!/bin/sh
{
echo "Disk report at $(date +'%T %d/%m/%y')"
echo "---------------------------------------------"
echo ""
echo ""
echo "Mounted disks"
echo "============="
df -hl
echo "---------------------------------------------"
echo ""
echo ""
echo "Swap usage"
echo "=========="
swapon -s
echo ""
echo ""
echo "---------------------------------------------"
echo "Partition tables"
echo "================"
fdisk -l 2>/dev/null
echo ""
echo ""
echo "---------------------------------------------"
echo "LVM"
echo "==="
echo ""
echo "lvs"
lvs
echo ""
echo "vgs"
vgs
echo ""
echo "pvs"
pvs
echo ""
echo ""
echo "---------------------------------------------"
echo "RAID"
echo "===="
mdadm --detail --scan --verbose
} >/df-h

Not very elegant, but frankly so simple itā€™s not worth fiddling with it.

1 Like

Thank you @MartinR :smiley: