What to do if you can’t restore your files

# What to do if you can't restore your files.

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 bug report 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.

Open a Terminal window by pressing CtrlAltT.

Create the directory in which you will place your restored files. This guide will use /tmp/restore:

    mkdir -p /tmp/restore

# Restoring with Duplicity

On the assumption that Déjà Dup is just not working for you right now, you’re going to 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, run man duplicity.

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 --gio file:///media/backup /tmp/restore

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

## Other Backup 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. See below for how to connect to your chosen backup location.

Remember to add --no-encryption to any example commands if your backup is not encrypted.

If duplicity appears to be having trouble connecting to your server, try downloading all the duplicity files yourself to a local folder and following the simpler example above.

### Amazon S3

Look up your Amazon S3 access key ID and secret access key and replace instances of ID and SECRET in the example below with those respective values.

You may have specified a folder in which to put the backup files. In the example below, replace any instance of FOLDER with that path.

    export AWS_ACCESS_KEY_ID=ID
    export AWS_SECRET_ACCESS_KEY=SECRET
    duplicity s3+http://deja-dup-auto-LOWERCASE_ID/FOLDER /tmp/restore

### Rackspace Cloud Files

Look up your Rackspace username and API key and replace instances of USERNAME and KEY in the example below with those respective values.

You may have specified a container in which to put the backup files. In the example below, replace any instance of CONTAINER with that name.

    export CLOUDFILES_USERNAME=USERNAME
    export CLOUDFILES_APIKEY=KEY
    duplicity cf+http://CONTAINER /tmp/restore

### FTP

Look up your server address, port, username, and password and replace instances of SERVER, PORT, USERNAME, and PASSWORD in the example below with those respective values.

You may have specified a folder in which to put the backup files. In the example below, replace any instance of FOLDER with that path.

If you chose to not log in with a username, use anonymous as your USERNAME below.

    gvfs-mount ftp://USERNAME@SERVER:PORT/FOLDER
    duplicity --gio ftp://USERNAME@SERVER:PORT/FOLDER /tmp/restore

### SSH

Look up your server address, port, username, and password and replace instances of SERVER, PORT, USERNAME, and PASSWORD in the example below with those respective values.

You may have specified a folder in which to put the backup files. In the example below, replace any instance of FOLDER with that path.

    gvfs-mount ssh://USERNAME@SERVER:PORT/FOLDER
    duplicity --gio ssh://USERNAME@SERVER:PORT/FOLDER /tmp/restore

### WebDAV

Look up your server address, port, username, and password and replace instances of SERVER, PORT, USERNAME, and PASSWORD in the example below with those respective values.

You may have specified a folder in which to put the backup files. In the example below, replace any instance of FOLDER with that path.

If you chose to use a secure connection (HTTPS) when backing up, use davs:// instead of dav:// in the example below.

    gvfs-mount dav://USERNAME@SERVER:PORT/FOLDER
    duplicity --gio dav://USERNAME@SERVER:PORT/FOLDER /tmp/restore

### Windows Share

Look up your server address, username, and password and replace instances of SERVER, USERNAME, and PASSWORD in the example below with those respective values.

You may have specified a folder in which to put the backup files. In the example below, replace any instance of FOLDER with that path.

If you specified a domain for your Windows server, add it to the beginning of USERNAME with a semicolon between them. For example, domain;username.

    gvfs-mount smb://USERNAME@SERVER/FOLDER
    duplicity --gio smb://USERNAME@SERVER/FOLDER /tmp/restore

# Restoring 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.