I have a pair of external USB drives I used to do backups. It is really no great inconvenience to perform backups. I get the drive (or both) out of the drawer, plug them in, then run (as root) a script that is a wrapper around rsync. Even after 8 months, a single backup took less than an hour.
The trick is twofold. One is not to be complacent because you keep thinking "I know I need to do a backup, and will real soon". Therein lies the root of all self deception and the old saying about the road to hell being paved with good intentions. Intentions are useless, in fact worse than useless because the deceive you into thinking you are on the right track. Ask every smoker. Ask every out of shape and overweight person.
What I need is a reminder (along with a policy). My policy is to do backups every month. Maybe I should every week, but once a month would be a big improvement over once a year. In the good old days, I would use a cron job to send me mail as a reminder, but my home machine won't run the old command line "mail" program without setting up sendmail.cf and I want nothing to do with that. It would appear that Google Calendar is a viable option. I can set an Event or a Reminder and then specify that I want the notification via email. In fact an Event will hand notifications to Chrome if I allow it to (and I do). So I have a good chance of being pestered to do backups via either my browser or email, which sounds promising.
Another thing I did after I recovered from the whole mess is to make backup copies of my disklabels. This is easy to do by running "dd" with a count of 4 blocks (less would do). The "fdisk" command is happy to run on image files as well as devices.
The crucial thing when a disaster like this happens is not to panic. Don't do anything at all until you are absolutely sure of what you need to do. You can easily make a recoverable situation worse or impossible. That being said, what I did was to break out my tablet and start doing searches on "linux recover disklabel". It turns out there is a tool called testdisk that is just the thing for this. It is somewhat cryptic to use, but ultimately it did the job.
Note my policy above of now making backup copies of disklabels. If I only had known the offsets and sizes of partitions, I could have run fdisk to regenerate the partition tables. For that matter, I could have simply used "dd" to write the saved partition table back onto the disk.
Once I got brave enough to tell testdisk to write the recovered disklabel back to the disk, I had my old sdb5 partition available as sdb3 I have some intervening partitions that I was not actually using and did not bother to recover those -- and probably never will. After this I mounted the partition in question readonly as follows:
mount -o /dev/sdb3 /u1Then I ran backups of /u1 -- two hours later, I edited /etc/fstab to now mount sdb3 on /u1 instead of the old sdb5. Then I did the following:
umount /dev/sdb3 fsck -f /dev/sdb3 mount /u1And I am back in business.
Adventures in Computing / [email protected]