What to do if you can’t restore your files
Michael Terry

Creative Commons Attribution-Share Alike 4.0 Unported License

# When Everything Goes Wrong

Déjà Dup may fail. Maybe it crashes or gives you an error when you try to restore. When you really need your data back, the last thing you want do deal with is a bug. Consider filing a help request but in the meantime, here are some approaches to workaround a misbehaving Déjà Dup and get your data back.

This is going to get technical. If none of this makes sense to you, don’t be afraid to ask for help.

These instructions assume you are have a command line available. Open a Terminal window first.

# Restic or Duplicity?

Over time, Déjà Dup has used different backup tools under the covers. Originally, it used Duplicity. Nowadays, it uses Restic.

Your backup might be in either format, depending on when you created it.

Look in the folder where your backup is kept:

If the filenames all start with duplicity-, then it's a Duplicity backup. Read the Duplicity sections below.

If you see a config file and a few folders like keys, then it's a Restic backup. Read the Restic sections below.

# Restoring with Restic

On the assumption that Déjà Dup is just not working for you right now, let’s use the command line tool Restic that is used by Déjà Dup behind the scenes to back up and restore your files.

If you want more information about Restic than presented here, run restic --help.

The first thing we’ll try is a simple restore of all your data. Assuming your files are on an external drive mounted as /media/backup and you chose to encrypt the backup, try this:

    restic restore --repo=/media/backup --target=/tmp/restore latest

If you didn’t encrypt the backup, add --insecure-no-password to the command.

If you need to do more advanced debugging, read their troubleshooting guide.

# Restoring with Duplicity

On the assumption that Déjà Dup is just not working for you right now, let’s use the command line tool duplicity that is used by Déjà Dup behind the scenes to back up and restore your files.

If you want more information about Duplicity than presented here, read its online documentation.

The first thing we’ll try is a simple restore of all your data. Assuming your files are on an external drive mounted as /media/backup and you chose to encrypt the backup, try this:

    duplicity restore file:///media/backup /tmp/restore

If you didn’t encrypt the backup, add --no-encryption to the command.

## Other Storage Locations

If you backed up to a remote or cloud server, the syntax you use with Duplicity will be different than the external drive example above.

Read the Duplicity documentation for instructions on how to connect to your server, or try downloading all the Duplicity files yourself to a local folder and following the simpler example above.

## Restoring Duplicity Files by Hand

If even duplicity isn’t working for you, there may be little hope. The backup file format is complicated and not easily manipulated. But if you’re desperate, it’s worth a try.

If you used a remote or cloud server to store your backup, first download all the duplicity files and place them in a folder on your computer. Then enter that folder in your terminal.

Duplicity stores your data in small chunks called volumes. Some volumes belong to the periodic ‘full’ or fresh backups and others to the ‘inc’ or incremental backups. Starting with a full backup set of volumes at volume 1, you’ll need to restore files volume by volume.

If you encrypted your backup, first you must decrypt the volume with gpg. Say you have duplicity-full.20110127T131352Z.vol1.difftar.gpg:

    gpg --output duplicity-full.20110127T131352Z.vol1.difftar --decrypt duplicity-full.20110127T131352Z.vol1.difftar.gpg

Or to do all at once (make sure you have plenty of space!):

    gpg --multifile --decrypt duplicity-full.20110127T131352Z.*.difftar.gpg

Now you have either a .difftar or a .difftar.gz volume (depending on whether you had to decrypt it or not). Use tar on whichever one you have to extract the individual patch files:

    tar xf duplicity-full.20110127T131352Z.vol1.difftar

Or again, to do all at once:

    for t in duplicity-full.20110127T131352Z.*.difftar; do tar xf $t; done

Now the patch files will be in multivolume_snapshot and snapshot folders. Each file that spanned multiple volumes will be in multivolume_snapshot. Let’s say you backed up /home/jane/essay.txt:

    cd multivolume_snapshot/home/jane/essay.txt
    cat * > essay.txt

To recover data from incremental backups, use rdiff to stitch the files together. See man rdiff for usage.