Wednesday, 8 March 2017

Backups? Who needs stinking backups!

It's not often that I get to write about a success followed by a failure... followed by a success.

I run Linux on my corporate machine (Ubuntu in one flavour or another) and I had not upgraded in a while. This meant that my version of Ubuntu was End of Life and I need to completely re-image my laptop to get onto something more current.

Therefore, I did what anyone would do... backup my data.

I then attempted a restore to make sure that the data was still valid and "restorable" and proceeded to re-image my machine.

I hate to name and shame, but I used Deja-dup which is the default Ubuntu backup software to create my backups and check that everything was working.

However, after re-imaging my machine and installing the latest version of Ubuntu, I tried to restore my backup and lo-and-behold, Deja-dup tells me "There is no backup...."


Are you might assume, I went ahead and tried to find what I could do - I saw that all the backup files (duplicity-full.xxxx.tardiff.gz) were in the backup location so I didn't think anything about it...

I tried re-launching the application and when I did it tried to make a backup. I didn't want a backup, so I stopped it. Then started the app again and tried to restore with the same error message.

I decided I would try something else, so I go to the directory where my backup was located and.... it was empty! Actually, there was a duplicity-checksum file that had been created by the previous backup attempt.)


I couldn't believe my eyes. I wanted to die! I had not only documents but also code I had written. I had over a year's worth of work, notes, and items that I had saved... ALL GONE!


So, I started looking for what I could do to recover something that was recently deleted. I found ext4magic and extundelete...

I installed both, made my partition read-only (which was an encrypted drive.)

sudo mount -o remount,ro /dev/mapper/luks-<uid-of-drive>

I then proceeded to read the documentation on both and decided that extundelete was worth a shot...

I created a temporary directory to try to restore into and ran the application (and crossed my fingers) ...

sudo extundelete /dev/mapper/luks-<uid-of-drive> -o RESTORE/ --restore-all

I waited. And finally...

42GB recovered!

I then copied them over to another drive (for safe keeping) and tried to restore from those files... Still, Deja-dup said, "No backup found!" $!*&"!

I went and looked for what I could do to recover if I didn't have Deja-dup and I found that I could simply gunzip and untar the files. That it would create a "snapshot" directory and a "multivol-snapshot" directory. Everything in the "snapshot" directory was the file in the original state... while the other one contained parts which had to be put together.

Well, I did it... and I've recovered almost all the stuff I had.

Now to switch to something that I have used before and that works quite well... Back-in-time.