1

To my surprise and delight I was able to do this. I figured I should document it somewhere. It synthesizes a couple other answers I found to guide me but focuses on a case that I haven't seen addressed directly.

This is my situation: a couple years ago I replaced my home computer. My old computer was running Ubuntu 14. My new one is running Ubuntu 16. On the old computer, I was making regular backups to an external drive using backups/deja-dup/duplicity.

A couple days ago, the hard drive on my old computer (Ubuntu 14 one) died. I had copied over most the important stuff to my new computer (Ubuntu 16). However, there was a projects folder that still had some older projects that I hadn't gotten around to copying over. So I wanted to see if I could restore this folder from the backups on the external drive.

This is the path of the folder from my old computer I wanted to restore:

  • /home/klenwell/projects

This is the path of the folder on my external drive where the backups were being saved (after plugging external drive into new computer):

  • /media/klenwell/my-external-drive/u2014

I wanted to restore it to a folder at this path on my new computer:

  • /tmp/restored/u2014/projects
klenwell
  • 3,889

1 Answers1

0

First, a quick refresher from question above on the key paths I'll be working with here:

  • Folder from old dead computer I want to restore: /home/klenwell/projects
  • Folder of old computer backups on external drive (when plugged into new computer): /media/klenwell/my-external-drive/u2014
  • Folder on new computer where I want restore folder: /tmp/restored/u2014/projects

Command Line

From command line, here at the command I ran to restore the backup. See the next section for a step-by-step guide with explanation:

# backup new project directory (to be safe)
mkdir /tmp/new-projects-backup
cp -R ~/projects /tmp/new-projects-backup

# review list of backed up paths from old computer
sudo duplicity list-current-files file:///media/klenwell/my-external-drive/u2014 > /tmp/u2014-backup-list.txt
less /tmp/u2014-backup-list.txt

# make destination folder for restored directory
mkdir /tmp/restored/u2014/projects

# restore backup
sudo duplicity restore \
  --file-to-restore home/klenwell/projects  \
  file:///media/klenwell/my-external-drive/u2014 \
  /tmp/restored/u2014/projects

# confirm folder has been restored
ls -al /tmp/restored/u2014/projects

Step-By-Step Guide

Here's a break down of the commands below with explanations for each command:

  1. Plug in external drive to new computer and confirm it's accessible:

    ls -al /media/klenwell
    

    Notes:

    • In reality, the mounted external drive's directory name a random string like ksdfd987s-0sll1332-skd09233.
    • To simplify this guide, I will assume it was named my-external-drive and backups were in folder u2014.
  2. Confirm I can see backed up files from older computer:

    sudo duplicity list-current-files file:///media/klenwell/my-external-drive/u2014 > /tmp/u2014-backup-list.txt
    less /tmp/u2014-backup-list.txt
    

    Notes:

    • I needed to use sudo to deal with this import error: https://lists.nongnu.org/archive/html/duplicity-talk/2013-10/msg00002.html
    • I needed to know the password I used to encrypt backups on my old computer meaning I entered 2 password: my sudo password and my backups password.
    • Note the file:// prefix for my backups folder path.
    • It took a few minutes to generate the output file.
  3. Back up /home/klenwell/projects on my new computer just to be safe in case duplicity tries to restore the backup folder to same path for some strange reason:

    mkdir /tmp/new-projects-backup
    cp -R ~/projects /tmp/new-projects-backup
    
  4. Here's where the magic happens (it was a somewhat large directory so it took a few minutes in my case):

    sudo duplicity restore \
      --file-to-restore home/klenwell/projects  \
      file:///media/klenwell/my-external-drive/u2014 \
      /tmp/restored/u2014/projects
    
  5. And to confirm all went well, I should now see my old project directory restored:

    ls -al /tmp/restored/u2014/projects
    

References

klenwell
  • 3,889