restore a specific folder using Duplicity

So backing up is one thing, but there's always the fear of the unknown: how easy will it be to restore everything in the event of a catastrophe? I had a catastrophe last night, and had to get my feet wet.

I had been messing around with resizing partitions and I don't know how but my whole home partition got deleted. I discovered this when at boot Ubuntu started complaining that /home was not present and did I want to skip it or manually recover it. I booted into a live environment and saw that my /home partition was now 'unalocatted space'. Gone. Lucky I had backed up everything using Deja Dup before I started. I created a new partition in it's place and pointed the /home line of /etc/fstab to the new partition.

I then couldn't boot into a desktop environment because all my config files were gone. I needed to boot into safe mode to restore my backed up files from my USB device using the command line.

After booting into safe mode I had to make my filesystem writeable with

mount -o remount,rw /

Then I mounted the USB disk to /media:

mount -t ext4 /dev/sdg1 /media

I didn't need to restore everything, and didn't have space either, because my backup contained my whole music collection among other things. I just wanted the home folder.

I used Duplicity to restore just the home folder using --file-to-restore, the location of the backup prepended with file:// and the location I wanted the restore to go to.

duplicity --file-to-restore=home file:///media/backup /media/recovered

It copies some signatures, asks for your encryption password, and then restores the files. I then had to mount the new home partition and copy the files over to there.

Was such a relief to get everything back. Only finally started backing up a few weeks ago. Didn't expect to have to use it so soon!